Skip to content

xUnit Test Runner Crash during discovery of Test Inputs #16

@thygrrr

Description

@thygrrr

Test Case

[Collection("GodotHeadless")]
public class BasicTests(GodotHeadlessFixture godot)
{
    public static IEnumerable<object[]> paths = [[new NodePath("/root")]];

    [Theory]
    [MemberData(nameof(paths))]
    public void CanLog_NodePath(NodePath path)
    {
        GD.Print(path);
    }
}

Expected: Works, Observed: Crash

This will crash during discovery. The reason is that GodotSharp makes a round-trip to the native library here, which doesn't exist yet.

~/Projects/2dog/temp/MyGame> dotnet test
Restore complete (0.5s)
  MyGame.Tests net8.0 succeeded (0.1s) → MyGame.Tests/bin/Debug/net8.0/MyGame.Tests.dll
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.2)
[xUnit.net 00:00:00.04]   Discovering: MyGame.Tests
The active test run was aborted. Reason: Test host process crashed
  MyGame.Tests test net8.0 failed with 1 error(s) (0.8s)
    /home/tiger/Projects/2dog/temp/MyGame/MyGame.Tests/bin/Debug/net8.0/MyGame.Tests.dll : error TESTRUNABORT: Test Run Aborted.

Build failed with 1 error(s) in 1.6s

Workaround

Disable the enumeration during discovery.

[MemberData(nameof(paths), DisableDiscoveryEnumeration = true)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingworkarounda workaround exists

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions