Writing Automation Tests: Do I need to build engine from source?

I’m trying to write some automation tests to capture perf stats from my game while it is running. The examples I found in EngineAutomationTests.cpp and in the Automation Technical Guide seem to reference private engine code (in particular, classes defined in AutomationTestCommon.h and AutomationTestCommon.cpp).

Does this mean we should be building the UE4 engine in order to write tests? Or copy a bunch of private code into my game?

Hello jcoombs,

I’ve put in a ticket to move the code in the AutomationTestCommons out of private so that you can easily use that code instead of having to copy and paste it. I’ll put a note in our ticket to reply back to this thread once a build with it is available.

Normally for performance capture we use a capture FPS command that will capture and dump the several pieces of performance data to a HTML file as well as a csv in the Game/Saved/Profiling folder.
Use StartFPSChart and StopFPSChart while in game to start and stop the charting.

For more info:
https://docs.unrealengine.com/latest/INT/Engine/Performance/index.html

I believe you can do this using this piece of code. This uses latent commands so that they’ll run over more than one frame.

/**
* Latent command to run an exec command that also requires a UWorld.
*/
DEFINE_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(FExecWorldStringLatentCommand, FString, ExecCommand);

/**
* Updates the latent command
*/
bool FExecWorldStringLatentCommand::Update()
{
	check(GEngine->GetWorldContexts().Num() == 1);
	check(GEngine->GetWorldContexts()[0].WorldType == EWorldType::Game);

	UE_LOG(LogEngineAutomationLatentCommand, Log, TEXT("Running Exec Command. '%s'"), *ExecCommand);
	GEngine->Exec(GEngine->GetWorldContexts()[0].World(), *ExecCommand);
	return true;
}


//Add this to your actual test code...
//Run the Stat FPS Chart command	
   ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommand(TEXT("StartFPSChart")));

//Wait for a determined amount of time in seconds.
ADD_LATENT_AUTOMATION_COMMAND(FEngineWaitLatentCommand(1.0));

//Run the Stat FPS Chart command		
ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommand(TEXT("StopFPSChart")));

Take note that this forum may have changed the whitespacing for that code…

Thanks, I got things working for now by copying some of test code into my project and use StartFPSChart/StopFPSChart commands as shown above.