如何以编程方式按名称禁用 DUnit 测试?
对于集成测试,我创建了一个 DUnit 测试套件,该套件为第三方组件(消息代理)的每个版本运行一次。不幸的是,由于被测试组件的某些版本中存在已知错误,某些测试总是失败。
这意味着测试套件永远不会 100% 完成。然而,对于自动化测试,需要 100% 的成功分数。 DUnit 不提供现成的方法来按名称禁用测试套件中的测试。
For integration tests, I created a DUnit test suite which runs once for every version of a third party component (a message broker). Unfortunately, some tests always fail because of known bugs in some versions of the tested component.
This means the test suites will never complete with 100%. For automated tests however, a 100% success score is required. DUnit does not offer a ready-made method to disable tests in a test suite by name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我编写了一个过程,它采用一个测试套件和一个测试名称列表,禁用具有匹配名称的所有测试,并且还执行嵌套测试套件的递归。
用法示例(TStringlist“排除”是在设置方法中创建的):
I wrote a procedure which takes a test suite and a list of test names, disables all tests with a matching name, and also performs a recursion into nested test suites.
Example usage (the TStringlist ‘Excludes’ is created in the Setup method):
对于已知会失败的测试,您可以实现
ITestListener
接口并覆盖ShouldRunTest
。此解决方案的优点(与 @WarrenP 的
DisableTests
相比)是,它不会影响确定要运行哪些测试的复选框。我为我的测试套件使用通用基类
TMvTestSuite
,它添加了一个可以在构造函数中调用的函数AddKnownInvalidTest
(例如在AddTest
之后) :For tests, that are known to fail, you can implement
ITestListener
interface and overrideShouldRunTest
.The advantage of this solution (compared to
DisableTests
by @WarrenP) is, that it does not affect the check boxes, that determine which tests to run.I use a common base class
TMvTestSuite
for my test suites, that adds a functionAddKnownInvalidTest
that can be called in the constructor (e.g. afterAddTest
):