How to run xunit tests for a Net45-based class library project (Package)?

I have a class library project (Package), a new preview template in RTM RT 2015, from which I want to run Xunit tests.

The solution builds fine, but Test Explorer does not find any tests. From project.json you can see that I am only targeting net45, not dnx, so I use xunit.runner.visualstudio.

{ "dependencies": { "myproject": "", "xunit": "2.1.0-*", "xunit.runner.visualstudio": "2.1.0-*" }, "frameworks": { "net45": { "frameworkAssemblies": { "System.Runtime": "4.0.0.0" } } } } 

When I change the project type to a regular class library, tests are selected. However, since the code I'm trying to verify is a class library project (package), referencing it from a regular class library is problematic, and I was hoping this would work. Is this possible (or some options)?

Context

Usually this type of project is used for ASP.NET 5, Core CLR, etc. Despite the fact that I only target net45, I use it because I want to use a function where I can easily use the local source code instead of the nuget package (via the projects global.json attribute). This makes it easier to work on a package that depends on another, where I often make local changes.

+7
c # visual-studio-2015 xunit dnx
source share
1 answer

If you are using DNX beta version 7.0 than the xUnit declaration in project.json, you will need to look like this:

 "dependencies": { "xunit": "2.1.0-rc1-build3168", "xunit.runner.dnx": "2.1.0-beta5-build169" }, "commands": { "test": "xunit.runner.dnx" }, 

and I hope that when you create the project, the test will appear. I have a similar problem until I used the correct version of xUnit with the correct version of DNX.

Here is a link where you can learn more about the config. xUnit and ASP.NET 5 http://xunit.imtqy.com/docs/getting-started-dnx.html

Hope I helped.

0
source share

All Articles