Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual studio无法发现测试(xunit)_C#_Visual Studio_Unit Testing_Testing_Xunit - Fatal编程技术网

C# Visual studio无法发现测试(xunit)

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

我在发现测试时遇到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-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

我尝试了以下方法:

  • 将测试体系结构更改为x64
  • 以管理员身份启动visual studio
  • 重新打开VS
  • 删除%TEMP%/VisualStudioTestExplorerex文件夹
  • 创建新项目
  • 将测试和项目架构更改为x86
  • 注: 当我运行dotnettest时,它工作正常,但我希望在测试窗口中进行测试,因为我无法从控制台调试测试

    编辑: 我已经创建了导致问题的存储库,请随意查找:

    编辑2:
    我正在使用.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,但错误表明了这一点。此外,这个项目(来自存储库)在不同的计算机上工作。