NUnit Configuration
Set properties in MyGame.nunit/MyGame.nunit.csproj. Reference 2dog.nunit and explicitly select 2dog.engine or 2dog.engine.double. The setup also references NUnit, NUnit3TestAdapter and Microsoft.Testing.Extensions.CodeCoverage for dotnet test and coverage collection.
The global settings control the game directory, resource import, analyzers and native variant.
Debug, Release, and Editor select the matching native variant. For tests that use Editor APIs:
dotnet test MyGame.nunit -c EditorThe generated Editor configuration defines EDITOR and references 2dog.godotsharp.editor. A test project that you create manually needs this managed reference to compile Editor API calls. The editor native variant alone does not add it.
See Testing with NUnit for fixture setup and runner rules, and Writing engine tests for waits and assertions.
Microsoft.Testing.Platform
The host runs on the official NUnit adapter's MTP bridge. Projects that 2dog sets up reference NUnit3TestAdapter 6.x for MTP v2 and set these properties:
<PropertyGroup>
<OutputType>Exe</OutputType>
<EnableNUnitRunner>true</EnableNUnitRunner>
</PropertyGroup>Run it from the project root; see Test runners for the global.json that selects MTP.
dotnet test MyGame.nunit
dotnet test --project MyGame.nunit --coverageCoverage reports go to TestResults/. To move an older VSTest host to MTP, add the properties above and update NUnit3TestAdapter to 6.x. For the other steps, see Microsoft's migration guide.
2dog leaves discovery, filters and results to NUnit's bridge and keeps Godot setup, tests and teardown on NUnit's fixture thread. See NUnit's official MTP documentation for runner options.
Cancellation
NUnit's adapter does not signal the test's cancellation token when the session is cancelled. Its forced stop also skips fixture teardown. To cancel tests reliably:
- Use NUnit's
[CancelAfter]. - Observe its token in async work and frame waits.
- Keep that timeout below any outer CI timeout.