Skip to content

xUnit Configuration ​

Set properties in MyGame.xunit/MyGame.xunit.csproj. Reference 2dog.xunit and explicitly select 2dog.engine or 2dog.engine.double. 2dog.xunit compiles its collection definitions into your test project. 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:

bash
dotnet test MyGame.xunit -c Editor

The generated Editor configuration also 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.

Tests use the game directory and its imported resource cache. See Resource Import to require or force an import, and Testing with xUnit for fixture and runner settings.

Microsoft.Testing.Platform ​

The host uses xUnit's own runner on MTP v2. Projects that 2dog sets up reference xunit.v3.mtp-v2 and Microsoft.Testing.Extensions.CodeCoverage, and set these properties:

xml
<PropertyGroup>
    <OutputType>Exe</OutputType>
    <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

Run it from the project root; see Test runners for the global.json that selects MTP.

bash
dotnet test MyGame.xunit
dotnet test --project MyGame.xunit --coverage --coverage-output-format cobertura

Coverage reports go to TestResults/. To move an older VSTest host to MTP, add the properties above and replace xunit.v3 with xunit.v3.mtp-v2. For the other steps, see Microsoft's migration guide.

2dog delegates discovery, filters, result reporting and cancellation to xUnit. The 2dog entry point keeps Godot on its owner thread. On macOS, that thread is the process main thread. See xUnit's official MTP documentation for runner options and IDE support.

2dog is Free and Libre Open Source under the MIT License.
2dog is not affiliated with or endorsed by the Godot Foundation.
Godot is licensed under the MIT License; the Godot logo is by Andrea Calabró under CC BY 4.0. @icons made by Voxy under the MIT License.
Continuous Integration compute graciously supported by Blacksmith.