title: Should jUnit test cases handle default exceptions in a throws declaration or in a try catch block
body: <p>If I write test cases for a function that throws a bunch of exceptions should I add a throws declaration for these exceptions in my test method or should I catch each individual exception. What is the correct way of going about it? I believe try-catch is a better way but in the catch block should I print the stacktrace? </p>
  
  <p>For example, I have a method <code>getGroups(String name)</code> that throws <code>AuthenticationException</code>. If I write a test case to check if an <code>IllegalArgumentException</code> is being thrown when the <code>name</code> parameter is null, how do I handle the <code>AuthenticationException</code>? Do I add it to throws part of my method or should I enclose the exception in a <code>try-catch</code> block. </p>
  
  <pre><code>@Test
  public void testGetGroupsWithNull() throws AuthenticationException {
   thrown.expect(IllegalArgumentException.class);
   getGroups(null);
  }
  </code></pre>
  
  <p>In the above test case I just added a <code>throws AuthenticationException</code>, but I would like to know if it is better to enclose the exception in a try-catch block and what shoudld I do after catching the exception. I could print the stack trace. </p>
  
  <p>I am handling the unexpected exception <code>AuthenticationException</code>by not placing it in the 'throws' clause but in a try/catch block. </p>
  
  <pre><code>@Test
  public void testGetGroupsWithNull() {
  thrown.expect(IllegalArgumentException.class);
  try {
    getGroups(null);
  } catch(AuthenticationExcption e) {
    Assert.fail("Authentication Exception");
  }
  }
  </code></pre>