asherber / Xunit.Priority

Provides an ITestCaseOrderer that allows you to control the order of execution of Xunit tests within a class.
Apache License 2.0
49 stars 2 forks source link

async test methods #8

Closed aandrieiev1998 closed 10 months ago

aandrieiev1998 commented 11 months ago

For async test methods ordering doesn't work? It is required to disable parallelization for that. Is there a way to achieve that?

asherber commented 11 months ago

Can you provide a simple class where ordering doesn't work for you?

aandrieiev1998 commented 11 months ago

Raw example:

using Xunit;
using Xunit.Priority;

public class Testorder
{
    [Fact, Priority(1)]
    public async Task Test1()
    {
        Assert.True(true);
    }

    [Fact, Priority(2)]
    public async Task Test2()
    {
        Assert.True(true);
    }

    [Fact, Priority(3)]
    public async Task Test3()
    {
        Assert.True(true);
    }

    [Fact, Priority(4)]
    public async Task Test4()
    {
        Assert.True(true);
    }
}
asherber commented 11 months ago

You need to apply the orderer to the class:


using Xunit;
using Xunit.Priority;

[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]
public class Testorder
{

}