Pattern selector

Most relevant patterns first. Most helpful ones displayed. Click here to show all.

  1. NPE when use @SpringBootTest and @WebAppConfiguration
    Spring TestContext Framework

Your stack trace compared to the selected pattern

Jump to solutionsExpand frames
8 matching frames hidden
java.lang.IllegalStateException: Failed to load ApplicationContext
18 matching frames hidden
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(
8 frames hidden


JaviRpo2 months ago

You don't need @WebAppConfiguration with @SpringBootTest support.

So just delete @WebAppConfiguration, and then...

  • if you want a mocked WebApplicationContext -- for example, to use MockMvc -- use @SpringBootTest with the default webEnvironment (which is WebEnvironment.MOCK).
  • if you want your web application to actually be deployed in an embedded Servlet container -- for example, to test with TestRestTemplate -- use @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) or @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)

External results for this pattern (3)

  1. No message found for this stack trace.
    Show stack trace