简体   繁体   English

使用 Cake 和 NUnit 重新运行失败的测试用例

[英]Rerun Failed Test Cases with Cake and NUnit

I am using a cake script to run test cases with NUnit.我正在使用蛋糕脚本通过 NUnit 运行测试用例。 The cases are written in C#.这些案例是用 C# 编写的。 How can I tell the script to rerun failed test cases?如何告诉脚本重新运行失败的测试用例? I am also using PowerShell to bootstrap the cake build.我还使用 PowerShell 来引导蛋糕构建。

NUnit currently doesn't have an out-of-the-box feature to re-run failed tests. NUnit 目前没有开箱即用的功能来重新运行失败的测试。 You'll have to:你必须:

  1. Compile a list of failed tests, either by extracting the failed tests from the Test Result XML file , or by writing the failed tests to a file by implementing a custom IResultWriter .编译失败测试列表,方法是从测试结果 XML 文件中提取失败的测试,或者通过实现自定义IResultWriter将失败的测试写入文件。

  2. Run NUnit giving it the list of tests to execute (the failed tests you got on step 1), using --test=FULLNAMES or -- testlist=FILE as described in the documentation .运行 NUnit 为其提供要执行的测试列表(您在第 1 步中获得的失败测试),使用--test=FULLNAMEStestlist=FILE文档中所述。

--test=FULLNAMES Comma-separated list of FULLNAMES of tests to run or explore. --test=FULLNAMES 以逗号分隔的要运行或探索的测试的 FULLNAMES 列表。 This option may be repeated.可以重复此选项。 Note that this option is retained for backward compatibility.请注意,保留此选项是为了向后兼容。 The --where option can now be used instead.现在可以改用 --where 选项。

--testlist=FILE The name (or path) of a FILE containing a list of tests to run or explore, one per line. --testlist=FILE 包含要运行或探索的测试列表的 FILE 的名称(或路径),每行一个。

If you're using the NUnit3Runner for Cake , you can configure the NUnit3Settings with the tests to be run ( Test or TestList ).如果您使用NUnit3Runner for Cake ,您可以使用要运行的测试( TestTestList )配置NUnit3Settings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM