title: how to handle exceptions in junit
body: <p>I wrote some test cases to test some method. But some methods throw an exception. Am I doing it correctly?</p>
  
  <pre><code>private void testNumber(String word, int number) {
      try {
          assertEquals(word,  service.convert(number));
      } catch (OutOfRangeNumberException e) {
          Assert.fail("Test failed : " + e.getMessage());
      }
  }
  
  @Test
  public final void testZero() {
      testNumber("zero", 0);
  }
  </code></pre>
  
  <p>If I pass <code>-45</code>, it will fail with <code>OutOfRangeException</code> but I am not able to test specific exception like <code>@Test(Expected...)</code></p>