Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

XUnit theories are not found by NCrunch if I am using Fluentvalidations instead of regular Asserts
royboy23
#1 Posted : Wednesday, January 27, 2016 7:03:52 PM(UTC)
Rank: Member

Groups: Registered
Joined: 3/3/2014(UTC)
Posts: 21
Location: Germany

Thanks: 3 times
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?
Remco
#2 Posted : Wednesday, January 27, 2016 9:57:32 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

Can you confirm which version of Xunit you are using?
royboy23
#3 Posted : Thursday, January 28, 2016 8:58:44 AM(UTC)
Rank: Member

Groups: Registered
Joined: 3/3/2014(UTC)
Posts: 21
Location: Germany

Thanks: 3 times
Hi Remco,

thanks for your quick reply. I'm using XUnit 1.9.2.1705
Remco
#4 Posted : Thursday, January 28, 2016 9:48:49 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
royboy23;8278 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.
1 user thanked Remco for this useful post.
royboy23 on 1/28/2016(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.246 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download