我正在 Jenkins/Mono 上运行 NUnit 测试,这就是我的命令:
mono /opt/NUnit-3.8.0/nunit3-console.exe $WORKSPACE/ProjectName/bin/$CONFIG/ProjectName.dll --where="test~=$TEST_NAME" --config=$CONFIG
这个想法是能够使用正则表达式选择测试。现在,我想使用正则表达式选择测试但忽略大小写。我尝试过这样的事情:
TEST_NAME = ^.*(?i)something(?-i).*$
也尝试过:
TEST_NAME = ^.*something.*$/i
但是我收到了“意外标记 '('” 和 “意外标记 '/'” 错误。有没有办法使用不区分大小写的修饰符?
最佳答案
NUnit console runner --where=EXPRESSION
使用特定的 test selection language (TSL) 其中
an expression indicating which tests to run. It may specify test names, classes, methods, categories or properties comparing them to actual values with the operators ==, !=, =~ and !~.
For matching regular expressions, NUnit users .NET's Regex.IsMatch method... as described here.
像这样尝试并查看上面链接的 TSL 文档中的示例。
--where "test =~ /(?i).*mytest/"
但是,如果您使用的是 NUnit V2,您可能就不那么幸运了:
The driver for NUnit V2 supports a subset of TSL. Because the V2 NUnit framework only allowed filtering on test names and categories, you may only use the cat and test keywords in comparisons. In addition, the regular expression operators =~ and !~ are not supported.
关于regex - NUnit 控制台命令行正则表达式不区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51014185/