Skip to content

NUnit Configuration ​

Set properties in MyGame.nunit/MyGame.nunit.csproj. Reference 2dog.nunit, which brings in 2dog.engine and NUnit. The scaffold also references NUnit3TestAdapter, Microsoft.NET.Test.Sdk and coverlet.collector for dotnet test and coverage collection.

The global settings control the game directory, resource import, analyzers and native variant.

ConfigurationDefault nativeUse
DebugdebugDevelopment tests with assertions
ReleasereleaseTests against the production engine
EditoreditorTests using Editor APIs and [Tool] scripts
bash
dotnet test MyGame.nunit -c Editor

The generated Editor configuration defines EDITOR and references 2dog.godotsharp.editor. Selecting the editor native alone does not add the managed reference needed to compile Editor API calls.

GodotTestFixture uses one headless engine per NUnit fixture with inherited SingleThreaded, NonParallelizable and FixtureLifeCycle(LifeCycle.SingleInstance) attributes. Keep these settings so engine startup, tests and disposal share one thread. Use derived [OneTimeSetUp], [SetUp], [TearDown] and [OneTimeTearDown] methods for your own lifecycle work; they may return Task.

Override CreateFixture() to configure a custom engine fixture and FailOnGodotErrors to change native error checking for a fixture. See NUnit for signal expectations, bounded waits and cleanup.