1

Resolved

IUseFixture<T> doesn't capture exceptions

description

If an exception happens in the constructor of a T class of an IUseFixter<T> (so for example, an exception happens while creating/loading some data), nothing is written in the xUnit GUI. The tests aren't run but no green/red dot is shown.

Using xUnit 1.9.2, Visual Studio 2012, .NET 4.0 64 bits.

Example code:
public class Data1 {
    public Data1() {
        Debug.WriteLine("Creating Data1");
        throw new Exception("Data exception!");
    }
}

public class Class2 : IUseFixture<Data1> {
    public Class2() {
        Debug.WriteLine("Creating Class2");
    }

    [Fact]
    public void Test1() {
        Debug.WriteLine("Hello world");
    }

    [Fact]
    public void Test2() {
        Debug.WriteLine("Now an exception");
        throw new ArgumentException("Argument!");
    }

    public void SetFixture(Data1 data) {
        Debug.WriteLine("SetFixture");
    }
}

comments