title: JUnit Exception Testing
body: <p>Edit: Not JUnit 4 available at this time. </p>
  
  <p>Hi there,</p>
  
  <p>I have a question about "smart" exception testing with JUnit. At this time, I do it like this:</p>
  
  <pre><code>public void testGet() {
  
      SoundFileManager sfm = new SoundFileManager();
  
          // Test adding a sound file and then getting it by id and name.
          try {
              SoundFile addedFile = sfm.addSoundfile("E:\\Eclipse_Prj\\pSound\\data\\Adrenaline01.wav");
              SoundFile sf = sfm.getSoundfile(addedFile.getID());
              assertTrue(sf!=null);
              System.out.println(sf.toString());
  
              sf = sfm.getSoundfileByName("E:\\Eclipse_Prj\\pSound\\data\\Adrenaline01.wav");
              assertTrue(sf!=null);
              System.out.println(sf.toString());
          } catch (RapsManagerException e) {
              System.out.println(e.getMessage());
          }
  
          // Test get with invalid id. 
          try {
              sfm.getSoundfile(-100);
              fail("Should have raised a RapsManagerException");
          } catch (RapsManagerException e) {
              System.out.println(e.getMessage());
          }
  
          // Test get by name with invalid name
          try {
              sfm.getSoundfileByName(new String());
              fail("Should have raised a RapsManagerException");
          } catch (RapsManagerException e) {
              System.out.println(e.getMessage());
          }
  
      }
  </code></pre>
  
  <p>As you can see, I need one try/catch block for each function that is supposed to throw an exception. It seems not to be a good way to do this - or is there no possibility to reduce the use of try/catch?</p>