1、依赖测试
通过 @Test(dependsOnMethods = {"test1"}) 在执行test2用例时同时执行test1
package com.lsc;
import org.testng.annotations.Test;
public class fourdep {
@Test
public void test1(){
System.out.println("test1的测试结果");
// throw new RuntimeException();
}
@Test(dependsOnMethods = {"test1"})
public void test2(){
System.out.println("test2的测试结果");
}
}
运行test2结果:
2、超时测试
在System.out.println("11111111111");和System.out.println("22222222222");睡眠10s
package com.lsc;
import org.testng.annotations.Test;
public class fourTime {
@Test
public void TestSuccess() throws InterruptedException {
System.out.println("11111111111");
Thread.sleep(10000);
System.out.println("22222222222");
}
}
执行结果: