How can automation testing be used for checking in game things?

I have written some automation tests for unreal replicating basic unit tests, all using the EAutomationTestFlags::ATF_SmokeTest flag. However, I have seen that it can be a lot more useful, making use of the in game and in editor flags, etc. I have tried to copy some of these from the engine tests etc which I have found, but still no idea where to go.

For example, how would I run the game, and have ti test that all maps load in game? (I have seen the test written for this but cannot get it to work).

The existing Load All Maps in Game test should work as-is. What kind of difficulties are you having with it?

Also, keep in mind that all tests marked with ATF_SmokeTest are run during every startup in non-Shipping builds, so you’ll want to avoid marking any tests that may take more than a few seconds with that flag (IIRC, ATF_SmokeTests will automatically fail if they take longer than 2 sec., but I’d have to double-check that).

At the moment I’m trying to grow my knowledge of the automation tool, so copying what is already in existence is what I am using for now to grow my knowledge - I would like to then be able to do things such as move my character, do different things and check everything possible with the automation tool.

The problem I am getting is no matter which example I look at, when I take across all relevant pieces of code to my tests file, I can never get it to work.

Could you clarify what you mean by “can never get it to work”? Does your test compile? Does it show up in the Automation Frontend? If it shows up, does it run but not do what you expect?

I don’t have a specific example of loadmaps right now as I kept deleting the code to compile. Here I have adapted someone elses code I found which should run an FPS check at several locations in the game. I actually can compile this (unlike any of the other attempts I’ve had) but when running the test in editor, it doesn’t appear to do much, just runs the test for a while then passes it, but with no output result (nothing in log even). Here is what I have:

CODE

So, what seems like is going on here in the code is that you’re mixing Latent logic with non-latent logic. When you add a latent command, what that does is fires it off to another thread that is going to eventually do what that command tells it to do, and then the code progresses. I don’t see a level load in here, so is this intended to be run while already within an existing level with an existing player character?

If it’s not, and the test is expected to do all of its setup on it’s own, and you don’t have a character before the start of the test, your latents may all be getting created way too early and as such, none of your characters are getting the movement commands. It’s enqueuing all of these latent commands in a fraction of a second, and your character iterator in MovePlayerTest may be trying to iterate before you have a character, thus telling zero things to move to each location. The fact that you weren’t even getting

UE_LOG(LogEngineAutomationTests, Display, TEXT("Unable to find character.")); 

to fire implies that your iterator is empty, showing that this may be the case.

What you could try to do is actually put another latent function at the beginning of the queue that is responsible for waiting until your iterator shows a character, and have that function then add all of your other latents once that is done. One that maybe looks like:

bool FWaitForCharacter::Update()
{
    for (TObjectIterator<ACharacter> it; it; ++it)
    {
        ACharacter* character = *it;
 
        if (character)
        {

            return true;
        }
        
    }
return false;
}

Continued in next post…

And do this instead of the hard sleep for 30 so you can know everything is ready. From there, you can then turn MovePlayerTest into another latent command whose job it is to enqueue all of the subtests (maybe via the globals you set up before) and then set up a latent DoCleanup whose job it is to enqueue all of the cleanup commands that is the last thing enqueued in the MovePlayerTest latent! You generally don’t want to mix latent and non-latent code as much as you can stay away from it, since non-latent code happens right away and latent is more fire and forget, which leads to weird timing issues! Hopefully this helps, and let me know if you have more questions!