0

I have an impression that JUnit Jupiter 5.5.1 does not like JUnit Platform 1.3.1. If both are specified in gradle dependency, then all JUnit 5 tests would just be ignored. See my previous SO Q&A on this. For example, I think the following combination would NOT work:

testImplementation('org.junit.platform:junit-platform-launcher:1.3.1')
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.5.1')
testImplementation('org.junit.jupiter:junit-jupiter-api:5.5.1')

Instead, I must use the following combination. That is, JUnit Platform Launcher must be 1.5.1 not 1.3.1:

testImplementation('org.junit.platform:junit-platform-launcher:1.5.1')
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.5.1')
testImplementation('org.junit.jupiter:junit-jupiter-api:5.5.1')

That was a few months ago. Today, I just realized that in my project, those JUnit 5 tests are being ignored again. Upon deeper inspection, however, I found the following dependency chain:

+--- org.junit.jupiter:junit-jupiter:5.5.1
|    +--- org.junit.jupiter:junit-jupiter-api:5.5.1 -> 5.3.2
|    |    +--- org.apiguardian:apiguardian-api:1.0.0
|    |    +--- org.opentest4j:opentest4j:1.1.1
|    |    \--- org.junit.platform:junit-platform-commons:1.3.2
|    |         \--- org.apiguardian:apiguardian-api:1.0.0
|    \--- org.junit.jupiter:junit-jupiter-params:5.5.1 -> 5.3.2
|         +--- org.apiguardian:apiguardian-api:1.0.0
|         \--- org.junit.jupiter:junit-jupiter-api:5.3.2 (*)

Does anyone know why here Junit Jupiter 5.5.1 would depend on JUnit Platform Commons 1.3.2

Update with more info from dependencyInsight

Based on the discussion here in SO and in discuss.gradle.org, the -> means there has been a "conflict resolution" of dependency and we could use the task dependencyInsight to gain more insight. I did that but still I could not quite know how to interpret the result.

clee@WS00509 MINGW64 ~/pg/dhpv2a (pg/gradle-6)
$ ./gradlew :profiler:dependencyInsight --configuration testCompileClasspath --dependency org.junit.jupiter:junit-jupiter

> Task :profiler:dependencyInsight
org.junit.jupiter:junit-jupiter:5.5.1 (selected by rule)
   variant "compile" [
      org.gradle.status              = release (not requested)
      org.gradle.usage               = java-api
      org.gradle.libraryelements     = jar (compatible with: classes)
      org.gradle.category            = library (not requested)

      Requested attributes not found in the selected variant:
         org.gradle.dependency.bundling = external
         org.gradle.jvm.version         = 8
   ]

org.junit.jupiter:junit-jupiter:5.5.1
\--- testCompileClasspath

org.junit.jupiter:junit-jupiter-api:5.3.2 (selected by rule)
   variant "compile" [
      org.gradle.status              = release (not requested)
      org.gradle.usage               = java-api
      org.gradle.libraryelements     = jar (compatible with: classes)
      org.gradle.category            = library (not requested)

      Requested attributes not found in the selected variant:
         org.gradle.dependency.bundling = external
         org.gradle.jvm.version         = 8
   ]

org.junit.jupiter:junit-jupiter-api:5.3.2
\--- org.junit.jupiter:junit-jupiter-params:5.3.2
     \--- org.junit.jupiter:junit-jupiter:5.5.1 (requested org.junit.jupiter:junit-jupiter-params:5.5.1)
          \--- testCompileClasspath

org.junit.jupiter:junit-jupiter-api:5.5.1 -> 5.3.2
\--- org.junit.jupiter:junit-jupiter:5.5.1
     \--- testCompileClasspath

org.junit.jupiter:junit-jupiter-params:5.3.2 (selected by rule)
   variant "compile" [
      org.gradle.status              = release (not requested)
      org.gradle.usage               = java-api
      org.gradle.libraryelements     = jar (compatible with: classes)
      org.gradle.category            = library (not requested)

      Requested attributes not found in the selected variant:
         org.gradle.dependency.bundling = external
         org.gradle.jvm.version         = 8
   ]

org.junit.jupiter:junit-jupiter-params:5.5.1 -> 5.3.2
\--- org.junit.jupiter:junit-jupiter:5.5.1
     \--- testCompileClasspath

A web-based, searchable dependency report is available by adding the --scan option.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 6s
1 actionable task: 1 executed

My ultimate goal is just to get my JUnit 5 tests running. Any ideas on how to do that?

Update 2 -- added gradle files

The gradle build files (and gradle.properties) are listed on this GitHub Gist. This is a multi-project build, so the root directory has build.gradle and one of the sub-project profiler has profiler.gradle

leeyuiwah
  • 6,562
  • 8
  • 41
  • 71
  • Please provide your complete Gradle file. The version downgrade must happen due to some other dependencies or plugins. – johanneslink Dec 16 '19 at 16:30
  • @johanneslink -- Thanks! I added three gradle files to the opening question. – leeyuiwah Dec 16 '19 at 16:42
  • 1
    You're using Spring Boot 2.1.4, which has a dependency on JUnit jupiter 5.3.2 in its BOM. See https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.1.4.RELEASE/spring-boot-dependencies-2.1.4.RELEASE.pom. Upgrade to the latest Spring Boot, or configure the dependency management plugin to use the version of junit jupiter that you want. – JB Nizet Dec 16 '19 at 17:23
  • @JBNizet -- Wow! Thanks! I should have caught that myself. Many thanks! – leeyuiwah Dec 16 '19 at 17:26
  • 1
    Does this answer your question? [Gradle 5 JUnit BOM and Spring Boot Incorrect Versions](https://stackoverflow.com/questions/54598484/gradle-5-junit-bom-and-spring-boot-incorrect-versions) – Sam Brannen Dec 17 '19 at 13:56

0 Answers0