Download

How to get Automation testing in C++ to work

Hey Guys,

I am trying to figure out how I can write my automation tests in c++. I got my first editor test up and running.


IMPLEMENT_SIMPLE_AUTOMATION_TEST(FYourTestClass, "Name.To.Your.Test", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
bool FYourTestClass::RunTest(const FString& Parameters)
{
	return true;
}


It also shows up in the editor. What I want to do next is, spawning an actor. But I cant access my world object. I am looking into AutomationCommon and EngineAutomationTest but cant get these examples to work.
Anyone experience with automated testing so far?
Any help or exampels appreaciated. Couldnt find any tutorials beside the Unreal Automation Docu which is not up to date and not very helpful either :frowning:

Cheers Pascal

I got a little bit closer. Since I run the test inside the editor I dont have a game world up and running. I only have the editor but neiter PIE nor Game. So how do I start a game then.
I thought about this GEngine->CreateNewWorldContext(EWorldType::PIE);
but somehow this has no effect at all.
Any ideas or should I run the tests from command line, something like this:

“C:\Program Files\Epic Games\4.12\Engine\Binaries\Win64\UE4Editor.exe” “PathToProject” -ExecCmds=“Automation RunTests SourceTests” -unattended -nopause -testexit=“Automation Test Queue Empty” -log=output.txt -game

Cheers Pascal

I am getting closer. I can now run my tests via command line.
“C:\Program Files\Epic Games\4.12\Engine\Build\BatchFiles\RunUAT.bat” BuildCookRun -project=“E:\Projects\MyProject\MyProject.uproject” -run -RunAutomationTest=Name.To.Your.Test -unattended -NOP4 -game
But some of the Latent Commands do not work. This is my test so far:


IMPLEMENT_SIMPLE_AUTOMATION_TEST(FYourTestClass, "Name.To.Your.Test", EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext | EAutomationTestFlags::EngineFilter)
bool FYourTestClass::RunTest(const FString& Parameters)
{
	UE_LOG(LogTemp, Log, TEXT("Start Test"));
	ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommandMyOwn(TEXT("StartFPSChart")));
	ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(1.0));
	ADD_LATENT_AUTOMATION_COMMAND(FExecStringLatentCommandMyOwn(TEXT("setres 640x480")));
	ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(2000.0));
	ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommandMyOwn(TEXT("StopFPSChart")));
	return true;
}

The test changes the resolution but instantly fisnishes afterwards without waiting. Also no csv file is created from the StartFPSChart command.
Any ideas?