【发布时间】:2016-10-17 20:39:13
【问题描述】:
所以我正在尝试运行由 TeamCity 触发的 powershell 脚本,以根据每个 github 提交时更改的文件的名称运行特定的单元测试。
这是我从命令行运行它的方式:
C:\MyFolder\bin\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll" --test="MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest"
但我一直得到这个,它运行它只是从不运行任何测试:
NUnit Console Runner 3.4.1
Copyright (C) 2016 Charlie Poole
Runtime Environment
OS Version: Microsoft Windows NT 10.0.14393.0
CLR Version: 4.0.30319.42000
Test Files
MyFolder\Bin\UnitTesting.dll
Test Filters
Test: MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest
Run Settings
WorkDirectory: C:\Users\Me
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.0
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 2
Test Run Summary
Overall result: Passed
Test Count: 0, Passed: 0, Failed: 0, Inconclusive: 0, Skipped: 0
Start time: 2016-10-17 20:28:43Z
End time: 2016-10-17 20:28:43Z
Duration: 0.303 seconds
Results (nunit3) saved as TestResult.xml
现在,当我在没有 --test 命令的情况下运行它时:
C:\MyFolder\bin\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll"
它运行我们拥有的每一个单元测试,但我不想全部运行它们,我想运行特定的快速测试,并且只在我们进入暂存/生产服务器时运行大型测试,这样我们的开发人员就不用他们每次提交某事都不必等待 15 到 20 分钟。
一些附加信息: - 我为此使用的命名空间是
MyFolder.QuickTests.DaoTests.ProductDaoTests
我呼叫的班级是:
ProductBasicTest
文件夹目录等一些名称已更改,因为它们是文件目录的 %teamcity% 占位符。
我做错了什么无法运行特定测试?
由于某种原因,我的 nunit-console 无法识别 /run 命令或 /fixture 或 --test=。
编辑:
我升级到 3.5.0 仍然遇到同样的问题,我无法使用 --test。
C:\MyFolder\bin\NUnit.ConsoleRunner.3.5.0\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll" --test="MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest"
那是新位置,遇到同样的问题。
当我执行 --where for MyFolder 时,它会导致 Powershell 崩溃,但实际上并没有运行任何东西。
当我执行 --explore 时,它对 MyFolder 的作用与 --where 相同,而对 MyFolder.QuickTests 没有任何作用。
编辑编辑:
感谢 Rob,我找到了文档 here,并使用 --where "name=ProductBasicTest" 查看了 --where 函数,该函数将运行该测试套件中的所有文件!
【问题讨论】:
-
该表格适用于我,使用类(夹具)名称或仅使用 3.5 中的命名空间名称。我不记得 3.5 中为此修复了任何问题,但您可以尝试升级。您还可以尝试使用
--where命令行或--explore以确保您的测试没有不同的名称。 -
NUnit 3 也不使用 /run 或 /fixture 命令行选项。这是一个完全重写的命令行选项,不同于 2.6.x
-
@RobProuse 哦,太棒了,我很感激,我会尝试更新到 3.5,你知道 nunit-console 命令的文档在哪里吗?单元 3+?
标签: nunit nunit-console