AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology

Home Page:https://avaloniaui.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[AvaloniaTest] results in incorrect TestContext.CurrentContext.Test.MethodName in nunit

SimonCropp opened this issue · comments

[assembly: AvaloniaTestApplication(typeof(TestAppBuilder))]

public static class TestAppBuilder
{
    public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
        .UseSkia()
        .UseHeadless(new()
        {
            UseHeadlessDrawing = false
        });
}

public class CalculatorTests
{
    [AvaloniaTest]
    public void Should_Add_Numbers()
    {
        Assert.That(TestContext.CurrentContext.Test.MethodName, Is.EqualTo("Should_Add_Numbers"));
    }

    [AvaloniaTest]
    public void Cannot_Divide_By_Zero()
    {
        Assert.That(TestContext.CurrentContext.Test.MethodName, Is.EqualTo("Cannot_Divide_By_Zero"));
    }
}

result

Expected string length 18 but was 21. Strings differ at index 0.
  Expected: "Should_Add_Numbers"
  But was:  "Cannot_Divide_By_Zero"
  -----------^

   at TestableApp.Headless.NUnit.CalculatorTests.Should_Add_Numbers() in D:\Code\VerifyTests\Verify.Avalonia\src\NUnitTests\CalculatorTests.cs:line 13

@SimonCropp , @maxkatz6

This should be fixed by #16157