These are great questions. I’m going to try and answer some here as well as try to get one of our other programmers to chime in as well with their input.
>>I’ve added UnrealEd.h but it doesn’t seem to have changed the footprint of the compile errors.
Are you using a project created from the engine downloaded from the launcher or Github? Projects created through the launcher are not able to create editor automation tests due to the fact that the editor source doesn’t come with it. Through Github it is expected to work.
>>First of all it’s not clear what the required minimum headers.
AutomationTest.h is really the minimum for an engine/runtime automation test. The UnrealEd.h include is something you’d need for writing editor automation tests.
>>I need all of those equivalents in place, levels need loading, pawns need spawning etc
For automation testing there are only a few helper functions and even fewer that are exposed for you to use. We do have a ticket in place to get the rest of them available. You can find some things in the AutomationCommon.h file.
>>I’ve tried copying above that is directly manipulating the viewport location/rotation
This is because, most likely, you’re attempting to use editor code and that isn’t possible using a project created from the launcher.
>>this is something where I’d expect to spawn a camera, set a view target and set the location of the camera.
I would imagine for in game automation camera movement that isn’t tied to a specific player you’d use the spectator camera.
Game Automation Example Code:
The below example was created using the First Person Code Template. I named this project AUTOTest.
The goal of this test is to verify that the playable characters can fire their weapons.
I will say this code could be better as I need a real way to verify that the weapon actually fired.
This code was placed in it’s own .cpp file.
#include "AutomationCommon.h" //To get the wait latent command.
DECLARE_LOG_CATEGORY_EXTERN(MYLOG, All, All);
* Latent command used to fire the players weapon since we want this to happen over multiple frames.
* @param InExampleCharacter - An existing character using our example character class.
DEFINE_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(FFireWeapon, AAUTOTestExampleCharacter*, InExampleCharacter);
//Log to display, so that it shows in the UFE results, which character is firing their weapon.
UE_LOG(AUTOLOG, Display, TEXT("Fired weapon for '%s'."), *InExampleCharacter->GetName());
//Function added to the character class that allows us to use the protected: function named "OnFire()".
* Gun Shoot - Verifies that the player can fire their weapon
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FFPSGunShoot, "Automation Tests.Gun Shoot", EAutomationTestFlags::ATF_Game)
bool FFPSGunShoot::RunTest(const FString& Parameters)
//Cycles through each character in the level using the AAUTOTestExampleCharacter class
for (TObjectIterator<AAUTOTestExampleCharacter> It; It; ++It)
AAUTOTestExampleCharacter* ExampleCharacter = *It;
else if (!ExampleCharacter)
UE_LOG(MYLOG, Error, TEXT("Unable to find and fire the weapon for '%s'."), *ExampleCharacter->GetName());
You can also add automation functional tests into your maps. I’m going to ping one of our programmers and see if he can give you more information on that.
hopefully this stuff helps.