TestNG异常测试

测试中,有时候我们期望某些代码抛出异常。

TestNG通过@Test(expectedExceptions)  来判断期待的异常,并且判断Error Message

package TankLearn2.Learn;

import org.testng.annotations.Test;

public class ExceptionTest {
    
    @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp="NullPoint")
    public void testException(){
        throw new IllegalArgumentException("NullPoint");
    }
}
View Code

 

posted on 2018-03-12 13:37  美含卡卡  阅读(128)  评论(0编辑  收藏  举报

导航