Dotnet CLI构建和测试–只需运行测试 [英] Dotnet CLI build and test – just run the tests

查看:106
本文介绍了Dotnet CLI构建和测试–只需运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

**\*test*.dll

我想在dotnet cli上使用此架构,但是什么都找不到dotnet测试文档.我的项目文件结构就是这样.

I want use this schema on dotnet cli but I can't found dotnet test documentation nothing.my project file structure is this way this.

目前正在测试它查看.sln文件下的所有.dll文件.但我只想查看tests.dll文件

At the moment tests It looking at all the .dll files under the .sln file. but I want just looking tests.dll files

dotnet test --no-build "**\*test*.dll" //?? All files in my project 

推荐答案

对于dotnet测试,没有一种可以过滤的模式,我们只能通过 DisplayName FullyQualifiedName过滤测试对于xUnit,请参考以下链接以了解详情: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md

There isn't such a pattern to filter that for dotnet test, we can only filter tests by DisplayName or FullyQualifiedName for xUnit, refer to this link for dertails : https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md

但是它只能过滤测试,不能排除其他非测试项目.dll.

But it can only filter the tests, it cannot exclude other non-test project .dlls.

例如

dotnet test --filter "FullyQualifiedName=YourNamespace.TestClass1.Test1"

但是,您可以尝试编写PowerShell脚本来筛选测试项目并在循环中运行命令.参考: Dotnet CLI –运行测试来自多个程序集

Howerever you can try writing PowerShell script to filter the test projects and run the command in the loop. Reference: Dotnet CLI – running tests from multiple assemblies

例如

Get-ChildItem | ? { $_.Name.Contains("Test") } | ForEach-Object { Push-Location; Set-Location $_.Name; dotnet test --no-build; Pop-Location}

此线程供您参考: https://github.com/Microsoft/vstest/Issues/705

另一种解决方法是编写 cmd/bat 脚本以仅运行测试项目:

Another workaround is writing a cmd/bat script to run the test projects only:

例如

cd C:\TestProjectPath\A.Tests

dotnet test --no-build

cd C:\TestProjectPath\B.Tests

dotnet test --no-build

cd C:\TestProjectPath\C.Tests

dotnet test --no-build

这篇关于Dotnet CLI构建和测试–只需运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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