Build/Test Issues

XUnit theories are not found by NCrunch if I am using Fluentvalidations instead of regular Asserts

Started by royboy23 on 3,264 views

Hi,

I stumbled across a very odd looking quirk of the combination between Ncrunch / XUnit / FluentAssertions. If I create a new XUnit testing library with a this single test class, then NCrunch does not find the test, even though Resharper does:

public class FluentAssertionsTestClass
{
[Theory, InlineData(1)]
public void FluentAssertionsTheory(int param)
{
true.Should().Be(true);
}
}

However, if I add the following class anywhere in the same library, then *both* test classes are spotted by NCrunch:

public class RegularAssertionsTestClass
{
[Theory, InlineData(1)]
public void RegularAssertionsTheory(int param)
{
Assert.True(true);
}
}

However, everything works as I expected when using [Fact] instead of [Theory].

Is this a bug in NCrunch or in XUnit?

Edited

Hi, thanks for sharing this issue.

Can you confirm which version of Xunit you are using?
Hi Remco,

thanks for your quick reply. I'm using XUnit 1.9.2.1705
royboy23 wrote:
thanks for your quick reply. I'm using XUnit 1.9.2.1705


Thanks - this makes sense. There is a limitation present with Xunit v1 where NCrunch is unable to detect the reference to this framework unless there is a [Fact] declared in the project.

This is because NCrunch actually works with Xunit v1 indirectly (through Gallio), so it's a fairly heavyweight abstraction.

If you upgrade to Xunit v2 (where NCrunch is integrated directly), you won't see this problem.

Post a reply

Log in to reply.