1. // I Junit 3:
  2. public void testMethod() {
  3.     Exception e = null;
  4.     try {
  5.         doStuff();
  6.     } catch (Exception e_) {
  7.         e = e_;
  8.     }
  9.     assertNotNull(e);
  10. }
  11.  
  12. // I JUnit 4:
  13. @Test(expected = SomeException.class)
  14. void testMethod() throws Exception {
  15.     doStuff();
  16. }