C# Visual studio无法发现测试(xunit)
我在发现测试时遇到visual studio 2015 for Web问题。 我编写了简单的.Net核心应用程序,添加了带有测试的project,my project.json如下所示:C# Visual studio无法发现测试(xunit),c#,visual-studio,unit-testing,testing,xunit,C#,Visual Studio,Unit Testing,Testing,Xunit,我在发现测试时遇到visual studio 2015 for Web问题。 我编写了简单的.Net核心应用程序,添加了带有测试的project,my project.json如下所示: { "version": "1.0.0-*", "dependencies": { "xunit": "2.3.1", "xunit.runner.visualstudio": "2.3.1", "dotnet-test-xunit": "2.2.0-preview2-buil
{
"version": "1.0.0-*",
"dependencies": {
"xunit": "2.3.1",
"xunit.runner.visualstudio": "2.3.1",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"testRunner": "xunit",
"frameworks": {
"net461": {
}
}
}
然后在我的测试项目中,我编写了第一个测试:
using Xunit;
namespace Tests
{
public class Class1
{
public Class1()
{
}
[Fact]
public void HelloWorld()
{
Assert.True(true);
}
}
}
当我构建解决方案时,我的测试未被发现,我在测试输出窗口中收到以下消息:
------ Discover test started ------
========== Discover test finished: 0 found (0:00:00,0475339) ==========
------ Discover test started ------
An exception occurred while test discoverer 'DotNetTestDiscoverer' was loading tests. Exception: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
========== Discover test finished: 0 found (0:00:00,0145118) ==========
有趣的是,6.0.0.0版甚至没有Newtonsoft.Json
我尝试了以下方法:
我正在使用.netcore sdk版本1.0.0-preview2-003131。问题已解决-xunit不支持visual studio 2015 express edition。错误表示找不到特定版本的
Newtonsoft.Json
。您是否在项目中使用Newtonsoft.Json
?不,我没有。我粘贴了我的整个project.json.json,但是您有一个来自其他依赖项的临时依赖项。你需要解决这个问题。你试过安装Newtonsoft.Json吗?是的,我试过了,安装了Newtonsoft.Json 9.0.1(xunit依赖于它,但没有成功)。没有Newtonsoft.Json版本6.0.0.0,但错误表明了这一点。此外,这个项目(来自存储库)在不同的计算机上工作。