title: Unable to test exception with junit
body: <p>I have a method which contains a try-catch block and I don't know how to make my test pass...</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class ClassToTest {
      public void loadFileContent() {
          try {
              InputStream fileStream = fileLoader.loadFileContent();
              fileContentReader = new BufferedReader(new InputStreamReader(fileStream));
          } catch(CustomException ce) {
              logger.log(Level.SEVERE, "Error message")
          }
      }
  }
  
  public class TestClassToTest {
      @Test
      (expected = CustomException.class)
      public void testCustomException() throws Exception {
          loadFileContent();
      }
  }
  </code></pre>
  
  <p>The only thing I want to do when the exception is thrown is to log it, and that all works great, however, how can I create a test that shows that it works?</p>
  
  <p>I tried to capture console output and </p>
  
  <pre><code>assertTrue(consoleOutput.contains("logMessgae") 
  </code></pre>
  
  <p>and that worked as long as I ran only that specific test case, but it did not work when I ran it in my test suite.</p>