tomaszeman / Xunit.Extensions.Ordering

Xunit extension with full support for ordered testing at collection, class and test case levels. Full-featured AssemblyFixture implementation.
Apache License 2.0
53 stars 9 forks source link

Dynamic Ordering #1

Open JDCain opened 5 years ago

JDCain commented 5 years ago

Are you interested in adding Run Time Ordering to the project? I already have code for doing topological ordering of tests inside a class.

[TestCaseOrderer(DependencyOrderer.TypeName, DependencyOrderer.AssemblyName)]
public class OrderTests
{
    public static List<int> ExecutionOrder { get; set; } = new List<int>();

    [Fact]
    [TestDependency("OrderedTest1")]

    public void OrderedTest0()
    {
        ExecutionOrder.Add(0);
        Assert.Contains(1, ExecutionOrder);
    }

    [Fact]
    public void OrderedTest1()
    {
        ExecutionOrder.Add(1);
        Assert.DoesNotContain(0, ExecutionOrder);
    }
}
tomaszeman commented 5 years ago

Hi, dependency ordering is the only right solution I am just working on (vnext). Ordering is weak workaround. If you want to, make a push request or just send me the code, I can incorporate it into solution if it is complete solution.

JDCain commented 5 years ago

I'll fork and do a pull request then. I just wanted to check if it was useful before doing the work.

tomaszeman commented 5 years ago

It's the only right solution for the problem. I was coding before thinking and currently I have not enough time to code this myself :-) Ordering is bad practice even in integration scenarios. All what one needs (in some marginal cases when asm, collection, class fixtures are not enough) by doing integration testing with unit test framework is dependency tracking. Btw. you can start with vnext branch. There is e.g. separated test case orderer (more clean code). I can help you later - with code, code review. Feel free to use any code even if you decide to create separeted/own repo or nuget to be more motivated ;-). You decided to code right thing.

JDCain commented 5 years ago

@tomaszeman I did not see this message until after the pull request. #2 Let me know if you want me to close it and put it into the other branch.

tomaszeman commented 5 years ago

Good job J.D. Sent you invite ... Will look deeper later (try to run one test case from test explorer if all deps are executed I am not sure if this works)....

tomaszeman commented 5 years ago

bcs. this is the tricky part of solution....I thing will need to rewrite discoverer first...

JDCain commented 5 years ago

This was merged in, so closing.