Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement IXunitTestCollectionFactory

Tags:

xunit

I can't find any docs on using/implementing IXunitTestCollectionFactory.

I have some custom logic on how I want to resolve the existence of some test cases, from rummaging in the xunit source/samples, this seems to be the way to go.

public class Foo : IXunitTestCollectionFactory
{
    public Foo(ITestAssembly assembly, IMessageSink messageSink)
    {
        throw new NotImplementedException();
    }

    public ITestCollection Get(ITypeInfo testClass)
    {
        throw new NotImplementedException();
    }

    public string DisplayName
    {
        get { throw new NotImplementedException(); }
    }
}

This doesn't ever seem to get run, or at least the exceptions are swallowed and any real code I put in there doesn't seem to be run either.

I've tried adding this to the test assembly, but to no avail

[assembly: CollectionBehavior("MyAssembly.Foo", "MyAssembly")]

Where do I start? Are there any docs on this anywhere?

like image 820
Andrew Bullock Avatar asked Apr 02 '15 12:04

Andrew Bullock


1 Answers

This:

[assembly: CollectionBehavior("MyAssembly.Foo", "MyAssembly")]

Should be this:

[assembly: CollectionBehavior("MyNamespace.Foo", "MyAssembly")]
like image 70
Brad Wilson Avatar answered Sep 19 '22 12:09

Brad Wilson