0

JUnit Jupiter 5.5.1我有一个不喜欢的印象JUnit Platform 1.3.1。如果两者都在 gradle 依赖项中指定,那么所有 JUnit 5 测试都将被忽略。请参阅我之前的 SO Q&A。例如,我认为以下组合行不通:

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')

相反,我必须使用以下组合。也就是说,JUnit Platform Launcher一定1.5.1不是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')

那是几个月前的事了。今天,我刚刚意识到,在我的项目中,那些 JUnit 5 测试再次被忽略了。然而,经过更深入的检查,我发现了以下依赖链:

+--- 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 (*)

有谁知道为什么这里Junit Jupiter 5.5.1将取决于JUnit Platform Commons 1.3.2

使用来自dependencyInsight 的更多信息进行更新

根据SODiscussion.gradle.org中的讨论,这->意味着存在依赖的“冲突解决”,我们可以使用该任务dependencyInsight来获得更多洞察力。我这样做了,但我仍然不太知道如何解释结果。

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

我的最终目标只是让我的 JUnit 5 测试运行。关于如何做到这一点的任何想法?

更新 2 - 添加了 gradle 文件

gradle 构建文件(和 gradle.properties)列在这个GitHub Gist 上。这是一个多项目构建,所以根目录有build.gradle,其中一个子项目profilerprofiler.gradle

4

0 回答 0