Note- This example shows how to test a runtime exception. 
If the methowithException() 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;
    }
}

 

Source: http://selenium-makeiteasy.blogspot.com