title: What is the best way to test that a spring application context fails to start?
body: <p>I use the spring-boot-starter-web and spring-boot-starter-test.</p>
  
  <p>Let's say I have a class for binding configuration properties:</p>
  
  <pre><code>@ConfigurationProperties(prefix = "dummy")
  public class DummyProperties {
  
      @URL
      private String url;
  
      // getter, setter ...
  
  }
  </code></pre>
  
  <p>Now I want to test that my bean validation is correct. The context should fail to start (with a specfic error message) if the property <code>dummy.value</code> is not set or if it contains an invalid URL. The context should start if the property contains a valid URL. (The test would show that <code>@NotNull</code> is missing.)</p>
  
  <p>A test class would look like this:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = MyApplication.class)
  @IntegrationTest({ "dummy.url=123:456" })
  public class InvalidUrlTest {
      // my test code
  }
  </code></pre>
  
  <p>This test would fail because the provided property is invalid. What would be the best way to tell Spring/JUnit: "yep, this error is expected". In plain JUnit tests I would use the ExpectedException.</p>