Automation Testing GetWorld / Create Actor Instance / Spawn Actor

Hey everyone,

I am trying to write a simple automation test for my Actor-Class.
In order to test my functions and member-variables I need to spawn an actor / create an instance of the actor class in my test class. However I cannot use GetWorld() in my test-class because it is unidentified. From my understanding I need the UWorld property to spawn an Actor.

Does anyone have any experience with Simple Automation Tests with Objects?
Unfortunately there is very few documentation on Automation Testing / Unit Testing in Unreal Engine.

Hi kwioka,

You could try:

FWorldContext* world=GEngine->GetWorldContextFromGameViewport(GEngine->GameViewport);
UWorld* World=world->World();

Hi RecourseDesign,

the solution is building but I get an Exception at FObjectHandle LocalHandle = Handle (ObjectHandle.h) with a read access Violation.

I also tried

UWorld* World = FAutomationEditorCommonUtils::CreateNewMap();

and

UWorld* World = UWorld::CreateWorld(EWorldType::Game, false);

and with both I get thrown a an Exception:

Exception thrown at 0x00007FF8EBF95BB6 (UnrealEditor-EditorInteractiveToolsFramework.dll) in UnrealEditor-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0x0000000000001924.

I am getting the same error when I attempt to use the UWorld::CreateWorld(EWorldType::Game, false);

I need a world for my actor to test in ue5.1