import org.testng.annotations.Test;
public class ExceptionTest {
@Test(expectedExceptions = ArithmeticException.class)
public void testDivisionByZero() {
int a = 5;
int b = 0;
}
@Test(expectedExceptions = NullPointerException.class)
public void testNullPointer() {
String str = null;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="ExceptionTestSuite">
<test name="ExceptionTests">
<classes>
<class name="com.example.ExceptionTest"/>
</classes>
</test>
</suite>