https://xunit.github.io/docs/getting-started-dotnet-core.html页面描述了如何使用dotnet test命令行运行测试。
它声明它需要一个特定的project.json,在这里我们添加xunit依赖项和测试运行程序:
"testRunner": "xunit",
"dependencies": {
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-build10015"
}如果我尝试从父目录调用它:
C:\git\Project\test [master ≡]> dotnet test
dotnet-test Error: 0 : System.InvalidOperationException: C:\git\Project\test\project.json does not exist.
at Microsoft.DotNet.Tools.Test.TestCommand.GetProjectPath(String projectPath)
at Microsoft.DotNet.Tools.Test.TestCommand.DoRun(String[] args)
C:\git\Project\test [master ≡]>问:是否有一种方法可以使用单个project.json运行所有测试(多个dotnet test )
发布于 2016-06-03 15:45:04
因为已经过了将近一个月了,没有人回答,所以我至少要分享一下我一直在做的事情。(一旦Visual "15“RTM启动,这将不相关,因为project.json死了)
只需在所有for上使用一个project.json循环:
在本地,在测试目录中,我只运行:
for /f %a in ('dir /b /s project.json ^| find /v "TestUtilities"') do dotnet test %a在所有project.json上运行它,除非路径有: TestUtilities
请注意,在TeamCity上,您需要转义%(在脚本中,您需要双倍:%%),这样就可以了:
for /f %%%a in ('dir /b /s project.json ^| find /v "TestUtilities"') do dotnet test %%%a注意%%。由于在TeamCity中%用于变量,所以第三%转义它。
发布于 2016-10-05 13:58:24
如果有人在寻找Windows的答案,下面是PowerShell中完成此工作的oneliner:
dir test | % { dotnet test $_.FullName }
发布于 2016-12-12 12:11:05
来自塞里罗格的人员有一个在他们的CI管道中构建多个测试项目的例子。查看这个powershell脚本https://github.com/serilog/serilog/blob/dev/Build.ps1#L44
https://stackoverflow.com/questions/37323364
复制相似问题