Reputation: 115
Starting a test from IntelliJ works fine. The same test in gradle returns:
13:15:20.148 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'Inlined Test Properties' with highest search precedence
╷
└─ JUnit Jupiter ✔
├─ HelloIntegrationTest ✔
│ └─ testHello() ✘ Failed to load ApplicationContext
That last debug log line is the same in IntelliJ. The difference is that in IntelliJ the test starts and succeeds but in gradle it stops with that. In IntelliJ the test fails if I intentionally make it fail. So I'm sure it's run until the end.
--debug --info --stacktrace don't help as the log stops before the test. I'm a beginner on Gradle. Any clue how to debug this is welcome...
Using Gradle 4.6, spring boot 2 release, JUnit 5.0.1. The whole class and repo to reproduce are there: https://github.com/ununhexium/springdwarf/blob/4480792f9d257dfc726fcf956ca5e452675b18e9/src/test/java/net/lab0/shell/HelloIntegrationTest.java
Upvotes: 5
Views: 4239
Reputation: 1908
According to the stacktrace (see build/test-reports
) this is caused by having different logging frameworks on the classpath.
A quick fix would be to remove the following two dependencies along with the logManager
configuration of the JUnitPlatformExtension
:
// To use Log4J's LogManager
testRuntimeOnly("org.apache.logging.log4j:log4j-core:$log4jVersion")
testRuntimeOnly("org.apache.logging.log4j:log4j-jul:$log4jVersion")
Switching to Gradle's native support for running tests on the JUnit Platform also resolves this problem: https://github.com/ununhexium/springdwarf/pull/1
Upvotes: 4
Reputation: 115
This line in build.gradle.kts was messing up something.
logManager = "org.apache.logging.log4j.jul.LogManager"
Upvotes: 0