# FAutomationEditorCommonUtils::CreateNewMap crashes the test in UE5

**URL:** <https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984>\
**Category:** C++\
**Tags:** Automation-Driver, unreal-engine, UE5-0, question\
**Created:** [May 9, 2022, 6:10pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984 "2022-05-09T18:10:13Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [May 9, 2022, 6:10pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/1 "2022-05-09T18:10:13Z")

</div>

I’m trying to implement simple test im Unreal Engine 5, but I stuck on creating an empty map.

The following code crashes with this error:

```auto
[2022.05.09-17.50.13:609][519]LogAutomationController: Error: EditCondition attempted to use an invalid operand "WorldPartition".
[2022.05.09-17.50.13:609][519]LogAutomationController: Error: EditCondition attempted to use an invalid operand "TextureSizingType" (value error).

```

The code:

```cpp
IMPLEMENT_SIMPLE_AUTOMATION_TEST(DummyTest, "Tests.DummyTest", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)

bool DummyTest::RunTest(const FString& Parameters)
{
	UWorld* World = FAutomationEditorCommonUtils::CreateNewMap();
	return true;
}

```

I also tried to open existing map, and some other approaches of empty map creating, but all of them fail with this error.  
I also found engine tests, that uses this function, like FLandscapeEditorTest and it also fails.

Is it a known bug in Unreal Engine, or I configure smth wrong?

BTW: I tried both linux build and windows epic games build. Nothing helped.

UPD: It seems that map is created succesfully, and test finishes, but as somewhere in editor error is thrown, test is marked as “aborted”.

---

<div class="post-metadata">

**Author:** ![BrittanyRoseArt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brittanyroseart/32/88718_2.png) [@BrittanyRoseArt](https://forums.unrealengine.com/u/BrittanyRoseArt)\
**Post date:** [May 19, 2022, 6:32pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/2 "2022-05-19T18:32:00Z")

</div>

Bumping this because I’m having the same errors while running automated tests in UE5. This is not a new map in my case, as the map was created prior to switching engine versions to UE5.

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [May 19, 2022, 7:09pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/3 "2022-05-19T19:09:54Z")

</div>

Make sure you set in your Editor Settings the `Automation Testmap` to be an empty map in your project. For example I have `Maps/L_TestAutomation` in my project and I have it configured as the Automation Testmap. This is a completely empty map with nothing at all in it.

Before I configured that I was getting errors similar to what you are experiencing.

If that doesn’t help, it may be your UE version. In 5.0.0 it would always give me errors **the first** time I tried to run tests after starting the editor. Ignoring those and simply running the tests again would succeed. The errors were similar to what you’re seeing now. As of 5.0.1 it’s working great with no errors even at startup, but it still seems to require that empty map setup in the preferences.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![BrittanyRoseArt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brittanyroseart/32/88718_2.png) [@BrittanyRoseArt](https://forums.unrealengine.com/u/BrittanyRoseArt)\
**Post date:** [May 19, 2022, 9:26pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/4 "2022-05-19T21:26:06Z")

</div>

Setting an empty test level for the Automation map fixed it. Thanks so much!

---

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [May 20, 2022, 7:47am UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/5 "2022-05-20T07:47:04Z")

</div>

Yeah, thanks a lot @xi57. It fixed test run with Session Frontend in the editor. However, if I run it from terminal, or Rider, the issue is still here.  
@BrittanyRoseArt can you please share how you run your tests?

---

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [May 20, 2022, 8:01am UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/6 "2022-05-20T08:01:32Z")

</div>

Well, if I now run the same test twice. Second attempt works.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/6/f/76f329c3381571add812802337b3e67045e9dea0.png)

It looks like the second issue is in editor startup warnings. It looks like @xi57 also experienced it in 5.0.0 trying to run tests for the first time. But I also have it in 5.0.1.

---

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [May 20, 2022, 9:14am UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/7 "2022-05-20T09:14:58Z")

</div>

Well, it looks like at least I have a workaround for this.

```cpp
class FMyAutomationTest : public FAutomationTestBase {
public:
	FMyAutomationTest(const FString &InName, bool bInComplexTask)
		: FAutomationTestBase(InName, bInComplexTask) {
	}

	virtual void AddError(const FString &InError, int32 StackOffset) override {
		if (InError.Contains("will be marked as failing due to errors being logged")) {
			return;
		}
		if (InError.Contains("EditCondition attempted to use an invalid operand")) {
			return;
		}
		FAutomationTestBase::AddError(InError, StackOffset);
	}
};

```

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [May 20, 2022, 2:50pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/8 "2022-05-20T14:50:23Z")

</div>

It’s possible the WorldPartition errors have to do with the map that you have loaded when you first try to run your tests.

At the moment the map I have loaded by default is _super simple_.

If you have a UE5 map with a WorldPartition as your default, that could be the reason you get errors the first time you run your tests, but not on any subsequent times.

If possible, try to swap your map before you run tests for the first time. Make sure it’s a UE4 vanilla empty map.

As for your question about running tests from the command line, I haven’t tried that (I’m a UE noob honestly) but maybe you can pass some parameter like `-StartMap L_AutomationTestmap` so that it’s loading up the automation test map rather than whatever the default editor map is? Just a wild guess.

---

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [May 20, 2022, 5:28pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/9 "2022-05-20T17:28:29Z")

</div>

I’m using just empty map, so it doesn’t seem it has World Partition. Anyway, I think I’m pretty happy with my workaround for a moment, so I could just wait for epics to fix this bug in the engine 🙂  
Anyway, thanks a lot @xi57 I’ve spent almost 2 days trying to make tests work and almost gave up.

---

<div class="post-metadata">

**Author:** ![jeff.sult](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jeff.sult](https://forums.unrealengine.com/u/jeff.sult)\
**Post date:** [May 24, 2022, 10:42pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/10 "2022-05-24T22:42:59Z")

</div>

Setting the test map has done nothing for me either. I’ve done some digging in order to figure out why this might be happening and it’s quite a rabbit hole.

First of all, I actually don’t know why setting that map would work in the first place. `UAutomationTestSettings::AutomationTestmap` is only used in a handful of places in-engine, where the test explicitly loads that map rather than creating a new one. (See `FStatsVerificationMapTest::RunTest` for an example.) I’ve done some testing myself by placing an object in the test map and attempting to query for it during a test, and that query comes back empty, indicating that the map isn’t getting loaded when using `FAutomationEditorCommonUtils::CreateNewMap`. If this is working for you, then that’s fantastic, but I have zero idea why that would be the case.

The specific bug seems to be that an editor details customization for the world settings, `FLightmapCustomNodeBuilder`, is attempting to rebuild itself as part of handling `FEditorDelegates::MapChange`, but that customization is actually a stale one left over from the previous map. Rebuilding it walks down the tree until it starts trying to evaluate EditCondition metaproperties, at which point it realizes that its world settings pointer is stale and unhelpfully informs us about an invalid operand. This customization is deconstructed shortly thereafter.

**This has nothing to do with WorldPartition.** I’ve inserted other properties into my world settings object with `meta=(EditCondition = "foo == nullptr")` and those cause tests to fail as well.

The fact that this only causes tests to fail once is another quirk of the engine. It appears that these operand errors are only ever written to the log once, even though they fire every single time. I don’t know if this is intended behavior, and if it isn’t then this could change with any patch, so I would not rely on this behavior to solve the problem.

I think the best solution at the moment is to use the hack @Fexolm posted and just suppress the errors. I don’t like doing this (especially because the “will be marked as failing due to errors being logged” is a useful error to capture) but until Epic resolves this there’s little else we can do unless we want to start rooting around in how editor customizations are spun up when switching maps.

---

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [May 25, 2022, 9:53am UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/11 "2022-05-25T09:53:50Z")

</div>

Interesting, thanks @jeff.sult for sharing your results 🙂

---

<div class="post-metadata">

**Author:** ![jeff.sult](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jeff.sult](https://forums.unrealengine.com/u/jeff.sult)\
**Post date:** [May 25, 2022, 7:30pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/12 "2022-05-25T19:30:16Z")

</div>

I’ve submitted a bug report with my findings. Keeping my fingers crossed that they’ll be able to look at it soon.

---

<div class="post-metadata">

**Author:** ![NorthWeapon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NorthWeapon](https://forums.unrealengine.com/u/NorthWeapon)\
**Post date:** [August 14, 2022, 6:37pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/13 "2022-08-14T18:37:11Z")

</div>

How do I use this workaround? I am creating simple unit tests:

```cpp
IMPLEMENT_SIMPLE_AUTOMATION_TEST(TestMovement, "Blarg.Blarg.TestMovement",
								 EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)

```

However it is currently using the `FAutomationTestBase` , how do I configure the unit tests to use the custom workaround subclass?

**Update: Figured it out (in case anyone else wants to use the workaround):**

Use `IMPLEMENT_CUSTOM_SIMPLE_AUTOMATION_TEST` like so to specify custom base:

```cpp
IMPLEMENT_CUSTOM_SIMPLE_AUTOMATION_TEST(TestMovement, FMyAutomationTest, "Blarg.Blarg.TestMovement",
								 EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)

```

---

<div class="post-metadata">

**Author:** ![Fexolm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fexolm](https://forums.unrealengine.com/u/Fexolm)\
**Post date:** [August 14, 2022, 7:32pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/14 "2022-08-14T19:32:59Z")

</div>

@NorthWeapon yep, you are right

---

<div class="post-metadata">

**Author:** ![oleksii-dtsc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@oleksii-dtsc](https://forums.unrealengine.com/u/oleksii-dtsc)\
**Post date:** [February 20, 2024, 11:07pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/15 "2024-02-20T23:07:45Z")

</div>

I’m having this issue with UE 5.3.2  
Tried setting up the Test Automation Map in editor settings (in the editor).  
Tried adding the workaround, but it doesn’t help.  
Happens only at start and only for the test marked with:  
`EAutomationTestFlags::SmokeFilter`  
so when I replaced it with:  
`EAutomationTestFlags::ProductFilter`  
it finally worked.

Still it doesn’t look ok to me, as access violation doesn’t look like a reasonable feedback even if `CreateNewMap()` can’t be used with `SmokeFilter`.

---

<div class="post-metadata">

**Author:** ![sg-mg-42](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sg-mg-42](https://forums.unrealengine.com/u/sg-mg-42)\
**Post date:** [July 22, 2024, 1:33pm UTC](https://forums.unrealengine.com/t/fautomationeditorcommonutils-createnewmap-crashes-the-test-in-ue5/552984/16 "2024-07-22T13:33:45Z")

</div>

If anyone else is having an issue writing automation tests where they rely on code which inherently throws errors by design and there is no workaround, here’s what worked for me.

Modify your `DefaultEngine.ini` file to include the following:

```auto
[/Script/AutomationController.AutomationControllerSettings]
bSuppressLogErrors=True
bSuppressLogWarnings=True
bElevateLogWarningsToErrors=False

```
