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

Can't use it to have one test that runs at the last #1

Closed Jishun closed 5 years ago

Jishun commented 5 years ago

It's very easy to have one test that run before everyone else by adding a Priority attribute with everyone else left un-attributed

however, it is impossible to mark one test to run at the end without attributing all others, the code defaults the Priority to int.MaxValue which leaves no room to append anything later than default, suggest find a mid-value as a default to give flexibility

Thanks

asherber commented 5 years ago

Thanks, that's a good idea. Changing the default would be a breaking change, but I'll take a look at letting the user provide a default for a given class.

Jishun commented 5 years ago

Thanks for the quick response, looking forward to it! btw, quick idea, a bit hacky but changing the parameter type to long would extend the room...

asherber commented 5 years ago

You can now add a DefaultPriority attribute to a class to specify what priority gets assigned to tests without a Priority attribute. So you can do:

[DefaultPriority(0)]
public class MyTests
{
    [Fact]
    public void SomeTest() { }

    [Fact]
    public void SomeOtherTest() { }

    [Fact, Priority(10)]
    public void RunMeLast() { }
}