How do I create an automation test?

So I’ve spent my weekend trying to learn about automation tests. I understand that I can create them using one of two macros, but I don’t know how to implement something I want to do. I also just have some questions about testing in general.

Say I have an actor called AGrid. I would like to run a simple test where I make an empty map (I think you can do this with FAutomationEditorCommonUtils::CreateNewMap()), spawn an AGrid in that empty map, and check that everything is initialized correctly. I just can’t seem to make a version of this test that compiles.

Say I have an actor called ASquareGrid, with a function called AddTile(int x, int y, int z). Do I need to spawn a grid as described in the above paragraph, or is there a way to test the actor without spawning it in a map? Can I just declare ASquareGrid as a variable and call functions on it?

Some code examples would be useful, because I just can’t seem to find anything online. I’m also not sure if Automation Technical Guide | Unreal Engine Documentation is up to date.

Some code examples would be useful, because I just can’t seem to find anything online.

Hi Stormbreath!

Glad I’m not the only one using the AutomationTesting :smiley:

not sure if […] is up to date.

It’s not.

Use AutomationLoadMap(MapName); instead of FEngineAutomationTestUtilities::LoadMap(MapName); for example. And adding a test looks more like this:

IMPLEMENT_SIMPLE_AUTOMATION_TEST(FMyTest, "MyGame.SubElement", EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext | EAutomationTestFlags::ProductFilter)
bool FGamesTest::RunTest(const FString& Parameters) {
    TestTrue("Some Condition", false, true);

I recommend using the Engine’s tests as a base. I’ve been wanting to write an “up-to-date tutorial” for half a year now. I may find time to do so today and then post a link to it here.

Cheers, Jonathan.

I hope you do!

I actually did, aparently the same day and completely forgot to put the link here, sorry!

Oh yeah, I was actually using that lol. Thanks, really good tutorial! Would you happen to know the difference between UE4’s EditorTests module and RuntimeTests plugins? I’m currently setting up my tests like that, but I’m not sure if the plugins are set up differently or if thats just a clean way of keeping those tests separate.

Again thanks for the tutorial!

Awesome! Great to hear you like the tutorial.

I think it’s just a way to keep them organized. Especially since Editor tests don’t need to be bundled with the Game, i.e. you can deactivate the module for those.

Okay, cool thanks!

hi, the link doesn t work