Friday 24 February 2012

JUnit: How to test if an exception is thrown from a test method

public class FooTest {
 
  //this test is succeeded
  @Test(expected=NumberFormatException.class)
  public void testException() {
    throw new NumberFormatException();
   }
}

No comments:

Post a Comment