title: How to test exception in Java Junit
body: <p>I created the following method that I use to validate Roman numbers converter.
  In JUnit the test passes but the program doesn't throw any exception.
  Where did I wrong?</p>
  
  <pre><code>public void validateState(String number){
      if(!number.matches("^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$"))
          throw new IllegalArgumentException("Invalid number");
  
      System.out.println("Invalid number");
  }
  </code></pre>
  
  <p>Test:</p>
  
  <pre><code>@Test(expected = IllegalArgumentException.class)
  public void test15() throws Exception {
      new RomanNumber("").validateState("MMMMM");
  }
  </code></pre>
  
  <p>Thank you for the help.</p>