I am starting out in Java using DrJava. I am following TDD for learning. I created a method which is suppose to validate some data and on invalid data, the method is suppose to throw exception.
It is throwing exception as expected. But I am not sure, how to write a unit test to expect for exception.
In .net we have ExpectedException(typeof(exception))
. Can someone point me to what is the equivalent in DrJava?
Thanks
If you are using JUnit, you can do
@Test(expected = ExpectedException.class)
public void testMethod() {
...
}
Have a look at the API for more details.