Build/Test Issues

Unit test project with only xUnit.net theories in it is not picked up

Started by DanHil on 8,133 views

I have a unit test project that references both xUnit.net and xUnit.net Extensions.
The latter defines the TheoryAttribute which can be used to create data driven tests.

Now, my project doesn't contain a single [Fact] test, it only contains [Theory] tests. Additionally, it doesn't contain a single Assert from xUnit.net, so that the project in fact doesn't use xunit.dll directly but only xunit.extensions.dll.

This leads to the scenario that NCrunch doesn't pick up the tests in this project.

If I add a single line of code that directly uses xunit.dll anywhere in the project, NCrunch starts picking up all the tests again.
Hi Daniel -

This is a limitation inherent in the Gallio adapter NCrunch is using to find the Xunit tests. The adapter only fully activates if there is a reference somewhere to xunit.dll.

You may be able to work around this problem by changing the 'Framework utilisation type for Xunit' in your solution-level configuration, although this can also have performance implications. My recommendation is to simply include a reference somewhere in your code (perhaps a dummy test) to the Xunit framework so that the adapter can activate. There are future plans to re-integrate with Xunit around its v2 release, which should eventually solve this problem.
I've had this issue as well, and ended up using a dummy [Fact] to make sure all the [Theory] tests run.
Just hit it now. What does the progress look like?
Sorry, no fix is currently available for this issue. The current long term plan is to replace the current xUnit integration (which works through Gallio) with direct integration with xUnit. This will also include support for xUnit v2.
Hello,

I'm attempting to run xUnit 2.0.0 tests using NCrunch from VS 2015 RC.

Has the issue been resolved? NCrunch still doesn't appear to be picking up any tests.
Hi,

As far as I am aware, this issue is resolved. If you're seeing this in the latest version of NCrunch, can you share any sample code?
Considering that this is basic code - I'm a bit puzzled - NCrunch is not picking this up.
I'm using NCrunch for Visual Studio 2015 2.15.0.9

using Xunit;
using Assert = Xunit.Assert;

namespace My.Tests
{
// This project can output the Class library as a NuGet Package.
// To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build".
public class ConditionTests
{
[Fact]
public void X()
{
Assert.True(true);
}
}
}


Here's my project.json file :

{
"version": "1.0.0-*",
"description": "",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",

"dependencies": {
"System.Runtime": "4.0.20-beta-22907",
},

"frameworks": {
"dnx451": {
"dependencies": {
"xunit": "2.0.0"
}
},
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816",
"xunit": "2.0.0"
}
}
}
}

Edited

Right - here's the issue: NCrunch doesn't support the JSON based project files yet.

This area is still a work in progress. Likely it will be out before VS2015 is fully released.

Post a reply

Log in to reply.