title: How to write a test to check invalid configuration causes Spring application context to fail?
body: <p>Our team writes tests for Spring using Spring's <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/testing.html#testcontext-framework" rel="nofollow">TestContext framework</a>.</p>
  
  <p>It is really easy to use, but I cannot find a way to test invalid context configuration.</p>
  
  <p>I tried putting <code>@Test(expected = Exception.class)</code> on the test with the invalid config, and the test failed anyways with <code>java.lang.IllegalStateException: Failed to load ApplicationContext</code>.</p>