I am currently trying to setup automated tests for our game. I got so far that I my tests show up in editor now and I can run them. What I am trying to achieve now is to spawn a new actor and test if it is initialized correctly. I cant access UWorld from my test. I found that there are the AutomationEditorCommonUtils but I always get the following error using them:
I have similar problem with testing objects like scene components. Whole UEEditor crashes with “FObjectInitializer::Get() can only be used inside of UObject-derived class constructor.” when trying to initialize such in the test.
I use a copy of GetAnyGameWorld() from AutomationCommon.cpp, which always returns the same UWorld* that has been used for loading the map with AutomationOpenMap(TEXT("...")).
You can then proceed to spawn the actor as you would in the game.
This works for me, but is quite hacky. I hope they have a better solution soon.
It only works if you’re in a PIE or Game session unless you modified the function. I make my test throw up a warning if the return value was null, telling people to start a PIE or game session to run the test. Fortunately this isn’t a problem for my specific test I’m working on even though it’s quite hacky.