Spring-Boot-WebMVC-Test-Error

Terence February 18, 2018

Hey All,

I have created a Spring-Web-MVC-Test using the below Annotations

 

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc

 When I run the test locally it compiles and build the .war file with no issues.

I tried running the similar test inside the docker image using the .yml file so to automate regression testing of our unit-tests. But I see a failed to load "Application Context" error.

java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) ~[spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189) ~[spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131) ~[spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) ~[spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) [spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) [spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) [spring-test-4.3.8.RELEASE.jar:4.3.8.RELEASE]

 

Any help will be appreciated.

 

1 answer

0 votes
Einar Pehrson
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2018

Hi @Terence, could you please provide some more details about what you are trying to do and how this relates to Atlassian?

tprosser March 20, 2018

I do have the same error, but with the new @WebMvcTest annotation. Posted this on SO: https://stackoverflow.com/questions/49391580/spring-boot-test-with-webmvctest-fails-on-atlassian-bitupcket-pipeline

Switching to your annotation version (which should work as well as per the docs), does not change anything. Seeing that my tests run fine locally, I think it may have something to do with the fact that pipelines run in a Docker container. If so, how does one configure that correctly?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events