在运行时跳过TestNg测试 [英] Skip TestNg test in runtime
问题描述
我没有很多使用TestNG的经验,所以你知道如何跳过或忽略Java Runtime中的一些测试。我的想法是写@ Before-annotiation测试,如果失败,传入的测试将被忽略。
I don't have a lot of experiences with TestNG, so do you know hot to skip or ignore some tests in Java Runtime. My idea is to write @Before-annotiation test and if it fails the incoming test will be ignored.
我试图用假设方法使用JUnit,但我不知道更喜欢它,因为如果测试前失败,传入的测试会突出显示为已通过,并且它不是一个可靠的解决方案,因为它具有含糊不清的含义。
I tried to use JUnit with assume method, but I don't prefer it because if "before-test" fails the incoming test is highlighted as passed and it's not a reliable solution because it has ambiguous meaning.
所以,如果你有任何经验有了TestNG,请帮助我将不胜感激。
So if you have any experiences with TestNG, please help I would be grateful.
推荐答案
您需要一组测试。 @Test with next params注释
dependOnGroup
或
dependsOnMethods
You need group of tests. Annotation @Test with next params
dependOnGroup
or
dependsOnMethods
例如
@Test
public void verifyConfig() {
//verify some test config parameters
}
@Test(dependsOnMethods={"verifyConfig"})
public void dotest(){
//Actual test
}
这篇关于在运行时跳过TestNg测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!