Note- This example shows how to test a runtime exception.
If the metho
If the metho
d withException() throws any runtime Exception then it will be passed. ex-
1)
import org.testng.annotations.Test;
public class RunTimeExceptions {
@Test(expectedExceptions = Exception.class)
public void withException(){
int a = 5/0;
}
}
2) This test case will fail-
import org.testng.annotations.Test;
public class RunTimeExceptions {
@Test()
public void withException(){
int a = 5/0;
}
}
import org.testng.annotations.Test;
public class RunTimeExceptions {
@Test()
public void withException(){
int a = 5/0;
}
}