title: Junit 4.12 Issue testing exception
body: <p>I have a simple method trying to fetch some file. I would like to test when the file is none existent and this is where my problem begins. The test keeps failing.</p>
  
  <p>The method is something like :</p>
  
  <pre><code>public Configuration populateConfigs(Configuration config) throws UnRetriableException {
  
      try {
                   ....
  
      } catch (IOException | ConfigurationException e) {
          log.error(" getConfiguration : ", e);
          throw new UnRetriableException(e);
      }
  
      throw new UnRetriableException("problem getting config files.");
  }
  </code></pre>
  
  <p>In my tests I have tried two separate solutions without success.</p>
  
  <ol>
  <li><p>Using the new style as suggested in the <a href="https://stackoverflow.com/questions/4489801/junit-test-analysing-expected-exceptions#answer-5693603">SO solution</a></p>
  
  <pre><code>@Rule
  public ExpectedException exception = ExpectedException.none();
  @Test
  public void testPopulateConfigurationMissing() throws Exception {
  
      exception.expect(UnRetriableException.class);
      DefaultConfigHandler configurationFactory = new DefaultConfigHandler(testDirectory, testFileThatIsNonExistant);
      Configuration configuration = configurationFactory.populateConfiguration(systemConfig);
  
  }
  </code></pre></li>
  <li><p>For method two which is just how I used to know exceptions are tested.</p>
  
  <pre><code>@Test(expected = UnRetriableException.class)
  public void testPopulateConfigurationMissing() throws Exception {
  
      DefaultConfigHandler configurationFactory = new  DefaultConfigHandler(testDirectory, testFileThatIsNonExistant);
      Configuration configuration = configurationFactory.populateConfiguration(systemConfig);
  
  }
  </code></pre></li>
  </ol>
  
  <p>The exception is actually thrown as shown below :</p>
  
  <pre><code>com.caricah.iotracah.exceptions.UnRetriableException: java.nio.file.NoSuchFileException: world/over
  at com.caricah.iotracah.system.handler.impl.DefaultConfigHandler.populateConfiguration(DefaultConfigHandler.java:137)
  at com.caricah.iotracah.system.handler.impl.DefaultConfigHandlerTest.testPopulateConfigurationMissingDirectory(DefaultConfigHandlerTest.java:137)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
  at org.junit.runners.Suite.runChild(Suite.java:128)
  at org.junit.runners.Suite.runChild(Suite.java:27)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  </code></pre>
  
  <p>Hence my question, what else do I need to do to make the test pass?</p>
  
  <p>Ofcourse without using the junit3 way of catching the exception.</p>