tom*_*med 6 msbuild unit-testing xunit.net .net-core visual-studio-2017
对于我的生活,我无法从基于msbuild的新xunit netcoreapp1.0项目模板在Visual Studio 2017中进行单元测试.
要求单元测试既可以在Visual Studio内部(对于开发人员)也可以dotnet test在CLI上进行自动构建过程,但是,我无法始终如一地工作.
这是我尝试过的:
在现有解决方案中,创建一个新项目并选择.NET Core > xUnit Test Project.
从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'
Run Code Online (Sandbox Code Playgroud)
或使用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
Run Code Online (Sandbox Code Playgroud)
如果我添加xunit.runner.console或xunit.runner.msbuildnuget包,它会停止在Visual Studio内部进行单元测试.
我如何让两者同时工作?
谢谢!
您遇到的错误出现在预览3中并在预览4中修复.它们在执行时没有逃脱命令行,并且由于C:\Program Files\dotnet默认情况下安装了dotnet.exe ,因此它总是失败.
如果要继续使用预览3,最简单的解决方法是编辑系统PATH环境变量,并替换C:\Program Files\dotnet为C:\Progra~1\dotnet.
我知道这不是一个很好的答案,但dotnet-test-xunit只支持project.json文件.VS 2017强制您切换到csproj文件.
我在xunit twitter feed上找到了这个:如果你正在尝试在VS2017 RC w/.NET Core中使用@xunit,请删除dotnet-test-xunit并使用xunit.runner.visualstudio2.2 beta 4.
| 归档时间: |
|
| 查看次数: |
5970 次 |
| 最近记录: |