testng---异常测试/依赖测试
------异常测试-----------
package com.suite;
import org.testng.annotations.Test;
public class ExpectedTest {
@Test(expectedExceptions = RuntimeException.class)
public void runTimeExceptionsFailed(){
System.out.println("这是一个失败的异常测试");
}
@Test(expectedExceptions = RuntimeException.class)
public void runTimeExceptionsSuccess(){
System.out.println("这是一个正常的异常测试");
throw new RuntimeException();
}
}
------------依赖测试-------------
package com.suite;
import org.testng.annotations.Test;
//被依赖的方法失败了则 执行的方法会被忽略
//eg:必须登录后才能进行查询产品的操作
public class dependTest {
@Test
public void test01(){
System.out.println("test01 run");
throw new RuntimeException();
}
@Test(dependsOnMethods = {"test01"})
public void test02(){
System.out.println("test02 run");
}
}
test01 run
test02 run
===============================================
Default Suite
Total tests run: 2, Failures: 0, Skips: 0
===============================================