如何在 TestNG 中跳过或忽略测试的执行 [英] How to skip or ignore execution of tests in TestNG

查看:65
本文介绍了如何在 TestNG 中跳过或忽略测试的执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TestNG 在 Java 中编写测试.

I am writing test in java using TestNG.

我想跳过或忽略类文件中使用条件的所有类方法.

I want to skip or ignore a all class methods using conditional inside the class file.

在 ruby​​ 中,我遵循了这个 如何使用 Test 跳过某些测试::单位

In ruby, I have followed this How to skip certain tests with Test::Unit

我可以在java中做什么?

How can I do in java?

推荐答案

你可以抛出 <如果假设不成立,则代码>SkipException 在您的测试中,并且该机制足够灵活,甚至可以将测试标记为跳过或失败.这篇文章 展示了如何以声明方式将这种方法集成到您的测试套件.基本上你用 @Assumes 注释方法并有一个自定义的 IInvokedMethodListener.

You can throw SkipException's in your tests if assumptions does not hold, and that mechanism is flexible enough to even mark the test as skipped or failed. This article shows how to integrate this approach in a declarative manner in your test suite. Basically you annotate methods with @Assumes and have a custom IInvokedMethodListener.

或者(我不鼓励这样做,但这是一个选项),如果您可以确定静态跳过哪些内容,您可以动态生成一个 XML 规范并运行它.

Or (I don't encourage this but it's an option), if you can determine what to skip statically, you may generate an XML spec on the fly and run it.

这篇关于如何在 TestNG 中跳过或忽略测试的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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