Visual Studio 2015 RC1 Update 1中的XUnit找不到测试 [英] XUnit in Visual Studio 2015 RC1 Update 1 doesn't find tests

查看:59
本文介绍了Visual Studio 2015 RC1 Update 1中的XUnit找不到测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用预览模板在Visual Studio 2015中创建了一个ASP.NET 5项目.我通过NuGet安装了XUnit,并在解决方案中添加了"xUnit测试项目(DNX)".

I created an ASP.NET 5 project in Visual Studio 2015, using the Preview Templates. I installed XUnit via NuGet, and I added an "xUnit Test Project (DNX)" to my solution.

但是,即使我在Class1.cs中有一个公共的事实"测试方法,我的测试资源管理器也什么也没显示.当我运行所有测试"时,测试"输出窗口为空白.我的构建"输出窗口显示2个项目构建成功. (我的ASP.NET 5项目和我的xUnit项目.)

But my Test Explorer shows nothing, even though I have a public "Fact" test method in Class1.cs. When I "Run All Tests", the "Tests" output window is blank. My "Build" output window shows that 2 project build succeeds. (My ASP.NET 5 project, and my xUnit project.)

但是,当我构建或清理解决方案时,我在测试"输出窗口中收到以下消息:

When I either build or clean my solution, however, I get the following message in the "Tests" output window:

------ Discover test started ------
------ Test started: Project: MyProjectTest ------
Starting  Microsoft.Dnx.TestHost [C:\Users\xxxxxx\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe --appbase "C:\Users\xxxxxx\Documents\GitForWindows\Repositories\MySolution\MyProjectTest" Microsoft.Dnx.ApplicationHost --port 8424 Microsoft.Dnx.TestHost --port 8458 --parentProcessId 17312]

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Dnx.TestHost.Program.<>c__DisplayClass2_0.<<Main>b__0>d.MoveNext()
Unable to start Microsoft.Dnx.TestHost
========== Discover test finished: 0 found (0:00:01.057196) ==========

根据两个项目的属性窗口,我的解决方案DNX SDK版本为1.0.0-rc1-update1.我还将其设置为通过dnvm的活动"运行时,而上述行为没有任何变化.但是,我不了解有关从命令行运行DNX的说明,所以也许这是一个起点?

My solution DNX SDK version, according to both projects' properties window, is 1.0.0-rc1-update1. I also set that as the "active" runtime via dnvm, with no change in the above behavior. I don't understand the instructions about running DNX from the command line, though, so perhaps that's a starting point?

当我尝试将DNX SDK切换到1.0.0-beta5并清理解决方案时,我得到:

When I try switching DNX SDK to 1.0.0-beta5, instead, and clean solution, I get:

------ Discover test started ------
------ Test started: Project: MyProjectTest ------
Starting  Microsoft.Framework.TestHost [C:\Users\xxxxx\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta5\bin\dnx.exe --appbase "C:\Users\xxxxxx\Documents\GitForWindows\Repositories\MySolution\MyProjectTest" Microsoft.Framework.ApplicationHost --port 9737 Microsoft.Framework.TestHost --port 9770 --parentProcessId 16732]

System.InvalidOperationException: Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1':
   xunit 2.1.0
   xunit.runner.dnx 2.1.0-beta6-build191

Searched Locations:
  C:\Users\xxxxx\Documents\GitForWindows\Repositories\MySolution\{name}\project.json
  C:\Users\xxxxx\Documents\GitForWindows\Repositories\MySolution\src\{name}\project.json
  C:\Users\xxxxx\Documents\GitForWindows\Repositories\MySolution\test\{name}\project.json
  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\{name}.dll
  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\{name}.dll
  C:\Windows\Microsoft.NET\assembly\GAC_32\{name}\{version}\{name}.dll
  C:\Windows\Microsoft.NET\assembly\GAC_64\{name}\{version}\{name}.dll
  C:\Windows\Microsoft.NET\assembly\GAC_MSIL\{name}\{version}\{name}.dll

Try running 'dnu restore'.

   at Microsoft.Framework.Runtime.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env)
   at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args)
   at dnx.host.RuntimeBootstrapper.Execute(String[] args)
Unable to start Microsoft.Framework.TestHost
========== Discover test finished: 0 found (0:00:01.4699978) ==========

运行DNU还原无法解决任何问题.

Running DNU restore doesn't resolve anything.

这是所要求的project.json:

Here's the project.json as requested:

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

  "dependencies": {
    "xunit": "2.1.0",
    "xunit.runner.dnx": "2.1.0-beta6-build191"
  },
  "commands": {
    "test": "xunit.runner.dnx"
  },

  "frameworks" : {
    "dnx451": { },
    "dnxcore50" : {
      "dependencies": {
        "System.Collections": "4.0.11-beta-23225",
        "System.Linq": "4.0.1-beta-23225",
        "System.Threading": "4.0.11-beta-23225",
        "Microsoft.CSharp": "4.0.1-beta-23225"
      }
    }
  }
}

推荐答案

您需要使用与dnx匹配的xUnitRunner版本.对于dxn RC1,您需要使用xunit.runner.dnx的版本2.1.0-rc1-build204

You need to use a version of xUnit runner that matches dnx. For dxn RC1 you need to use the version 2.1.0-rc1-build204 of xunit.runner.dnx

这篇关于Visual Studio 2015 RC1 Update 1中的XUnit找不到测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆