Daily Usage Issues

XUnit - Theory not showing all inputs

Started by JKommer on 5,612 views

NCrunch does not seem to correctly detect all tests when using non-primitive type input parameters - the following code will show within NCrunch as a single test with no input arguments -

public class TestClass
{
private readonly string _input;

public TestClass(string input)
{
_input = input;
}
public override string ToString()
{
return _input;
}
}

public static IEnumerable<object[]> TestData
{
get
{
yield return new object[] { new TestClass("A")};
yield return new object[] { new TestClass("B")};
yield return new object[] { new TestClass("C")};
yield return new object[] { new TestClass("D")};

}
}


[Theory(DisplayName = "Custom Test ")]
[MemberData("TestData")]
public void Test(TestClass input) { }

This shows up as:

NCrunch:
  • Custom Test

XUnit:
  • Custom Test (input: A)
  • Custom Test (input: B)
  • Custom Test (input: C)
  • Custom Test (input: D)

Post a reply

Log in to reply.