Issue
I upgraded my IntelliJ version from 2017.3 to 2018.1 and now I can't run integration tests from the IDE anymore.
The project is a Spring Boot application and build with gradle. The integration tests look basically like this:
@RunWith(SpringRunner.class)
@SpringBootTest(
classes = TestApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE
)
@Transactional
public class MyServiceIT {
@Autowired
private MyService service;
@Test
public void test() {
// ...
}
}
It's still possible to run the test with gradle, but I can't run the isolated test from the IDE.
I get this error, because the instances cannot be autowired anymore:
[INFO] org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [MyServiceIT]: no resource found for suffixes {-context.xml, Context.groovy}.
[INFO] org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
[INFO] org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@309e345f, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@56a6d5a6, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@18ce0030, org.springframework.test.context.support.DirtiesContextTestExecutionListener@4445629, org.springframework.test.context.transaction.TransactionalTestExecutionListener@45b9a632, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@25d250c6, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener@4df50bcc, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@6b26e945, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@63a65a25, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@54c562f7, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@318ba8c8, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@6dbb137d, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@3c9d0b9d]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ...
I worked perfectly with version 2017.1. I think I have to change something in the IDEs configuration but I don't know what.
I'm using Windows 10, IntelliJ 2018.1, Java 1.8 and Spring Boot 1.5.10.RELEASE
Solution
Finally, I made it running again. In the Run/Debug Configurations
the Working directory
was set to $MODULE_DIR$
. In my project that did not resolve correctly. After setting the Working directory
explicitly to the project root, running specific integration tests worked.
Answered By - Axel Meier
Answer Checked By - Mildred Charles (JavaFixing Admin)