引入ITestOutputHelper,可以把信息输出在测试资源管理器的“测试详细信息摘要”中;如果使用dotnet test运行,加上-v d后,可以在控制台中看到该输出。
大石头 authored at 2023-12-29 17:49:41
668.00 B
NewLife.UnitTest
using System.Threading;
using Xunit;
using Xunit.Abstractions;

namespace XUnitTest;

[TestCaseOrderer("NewLife.UnitTest.DefaultOrderer", "NewLife.UnitTest")]
public class MethodOrderTests
{
    private readonly ITestOutputHelper _output;

    public MethodOrderTests(ITestOutputHelper output) => _output = output;

    [Fact]
    public void Test3()
    {
        _output.WriteLine("Test3");

        Thread.Sleep(1000);
    }

    [Fact]
    public void Test2() => Thread.Sleep(1000);

    [Fact]
    public void Test1() => Thread.Sleep(1000);

    [Fact]
    public void Test5() => Thread.Sleep(1000);

    [Fact]
    public void Test4() => Thread.Sleep(1000);
}