Q:

Gradle test dependencies not loaded in Spring Boot test

I am trying to work with p6spy in Spring Boot tests. I have a test class annotated with
@RunWith(SpringRunner.class)
@SpringBootTest

My gradle.build looks like this
dependencies {
 compile('org.springframework.boot:spring-boot-starter-data-jpa')
 runtime('com.h2database:h2')

 testCompile 'p6spy:p6spy:3.0.0'
 testCompile('org.springframework.boot:spring-boot-starter-test')
}

As for the application itself (which runs fine), I added the new datasource to the test-application-context.
spring:
application:
    name: persistence
datasource:
    url: jdbc:p6spy:h2:mem:persistence;DB_CLOSE_ON_EXIT=FALSE
    username: sa
    password:
    driver-class-name: com.p6spy.engine.spy.P6SpyDriver
jpa:
database: H2

But when I run my test I get this error

java.lang.IllegalStateException: Cannot load driver class: com.p6spy.engine.spy.P6SpyDriver

To me this looks like my dependencies are not loaded. At first, I was using the @DataJpaTest annotation, but this one ignored even my new test-application-context.
Any help appreciated.
EDIT: I got it working bei adding the p6spy dependency manually to the test using IntelliJ. Now I'm sure that my classpath is wrong, but I don't know how to fix it to make it work in Gradle.

A:

The problem is located in my version of IntelliJ. I will file a bug report.
If anyone should have this problem, I added the missing dependencies manually in the project settings. Then it works also from the IDE.

