在我的一生中,我无法从新的基于 msbuild 的 Visual Studio 2017 中进行单元测试netcoreapp1.0
xunit 项目模板。
要求单元测试既可以在 Visual Studio 内部(对于开发人员)也可以在 Visual Studio 中工作dotnet test
然而,在用于自动构建过程的 CLI 上,我无法使两者一致地工作。
这是我尝试过的:
在现有解决方案中,创建一个新项目并选择.NET核心 > xUnit测试项目.
从 Visual Studio 构建项目,默认测试出现并成功运行,现在运行dotnet test
从 powershell 提示符中,获取:
> dotnet test
Test run for D:\...\bin\Debug\netcoreapp1.0\MyProj.dll(.NETCoreApp,Version=v1.0)
dotnet exec needs a managed .dll or .exe extension. The application specified was 'C:\Program'
或者使用 csproj 文件进行 dotnet 测试:
> dotnet test MyProject.csproj
(same error as above)
> dotnet test ..\MySolution.sln
Couldn't find a project to run test from. Ensure a project exists in D:\...
Or pass the path to the project
如果我添加xunit.runner.console
or xunit.runner.msbuild
nuget 包,它会停止 Visual Studio 内部的单元测试工作。
我如何让两者同时工作?
Thanks!
您遇到的错误存在于预览版 3 中,并在预览版 4 中修复。它们在执行时没有转义命令行,并且由于 dotnet.exe 安装在C:\Program Files\dotnet
默认情况下,它总是失败。
如果您想继续使用预览版 3,最简单的解决方法是编辑您的系统PATH
环境变量,并替换C:\Program Files\dotnet
with C:\Progra~1\dotnet
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)