How to run XUnit tests in the project.json and dotnet tfm world
Asked Answered
C

1

8

Background: Recently I switched from the "old" world to the new project.json world, because new is always better ;) Currently 2 out of 3 projects can use the "dotnet" target framework moniker, the other one needs the full .NET framework (net46).

I also switched my test projects to the new project.json world, but it I can´t run any tests. The build is green, but no tests are found.

I read this documentation and included the xunit.runner.dnx, but the problem is that is is not a "dnx" project - it has a dependency on "dotnet" or "net46" and the current runner doesn´t seem to find the tests.

The project is available on GitHub.

The error from the xunit.runner.dnx package:

Error The dependency xunit.runner.dnx 2.1.0-beta5-build169 in project Sloader.Config.Tests does not support framework .NETPlatform,Version=v5.0. Sloader.Config.Tests C:\Users\Robert\Documents\GitHub\Sloader\tests\Sloader.Config.Tests\project.json 20 IntelliSense

Is this currently not supported or do I miss something? Thanks!

Castleman answered 16/9, 2015 at 22:36 Comment(0)
M
9

It can't be done right now. The issue is that the build system for project.json doesn't copy referenced DLLs from NuGet packages, unlike the old packages.config system. Until Microsoft fixes this behavior, you will not be able to do this. Your only recourse is to go back to packages.config.

Mysticism answered 17/9, 2015 at 1:1 Comment(4)
Is this behavior by design or is this acknowledged as a bug within Microsoft?Castleman
Yes, we exchanged e-mail with a couple of the team members over this issue, and they acknowledged that it's a bug that they intend to fix.Mysticism
There's some misinformation here but we should clarify guidance for this. It's coming. xproj and csproj will be able to reference each other. On top of that, unit testing still requires you to have a runner for each technology you want to test on.Swab
The original poster didn't mention csproj => xproj references. He was asking how to run a non-DNX project.json unit test project with xUnit.net. And my information -- absolutely correct -- is that this is broken right now because of the failure to copy NuGet references to the bin folder.Mysticism

© 2022 - 2024 — McMap. All rights reserved.