gradle测试执行人失败,而非零退出值1(Intellij Idea默认Gradle [7.4.1]/javafx [17.0.1]构建)
使用Javafx和Gradle构建工具创建应用程序:
- Javafx:17.0.1
- Gradle:7.3.1
- Java:Amazon Coretto 17.0.3
- Junit:5.8.2
我在Junit运行单元测试时遇到了以下错误,
> Task :test FAILED
Error occurred during initialization of boot layer
java.lang.RuntimeException: Unable to parse --add-opens <module>/<package>: com.example.testingtesting/
Execution failed for task ':test'.
> Process 'Gradle Test Executor 2' finished with non-zero exit value 1
我尝试过<<< a href =“ https://discuss.gradle.org/t/gradle-test-executor-executor-executor-executor-x-fin--------零 - 零 - exit-value-143/28857” rel =“ nofollow noreferrer”尺寸和将项目克隆到另一个位置 。我还经历了 gradle docs ://github.com/gradle/gradle/issues/16820“ rel =“ nofollow noreferrer”> gradle github ,并且无法找到任何特殊用途。
此外,我还通过 intellij noreferrer“> Intellij setup and Configuration and Configuration and Configuration tutorials a href =“ https://openjfx.io/openjfx-docs/#next-steps” rel =“ nofollow noreferrer”> javafx教程,但我似乎找不到结构或依赖关系或其他与之相关的任何内容进行单位测试。我在下面包括其他代码信息。 (不包括完整的示例,因为我发现问题)
目录结构如下:
├───.gradle
└───src
├───main
│ └───java
│ └───com
│ └───example
│ └───testingtesting
└───test
└───java
└───!!JUnitTestingFile!!
gradle build脚本
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.1'
}
group 'com.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.8.2'
}
sourceCompatibility = '17'
targetCompatibility = '17'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'com.example.testingtesting'
mainClass = 'com.example.testingtesting.HelloApplication'
}
javafx {
version = '17.0.1'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
Working on creating an application with JavaFX and the Gradle build tool:
- JavaFX: 17.0.1
- Gradle: 7.3.1
- Java: Amazon Coretto 17.0.3
- JUnit: 5.8.2
I encountered the following error while running unit tests in Junit
> Task :test FAILED
Error occurred during initialization of boot layer
java.lang.RuntimeException: Unable to parse --add-opens <module>/<package>: com.example.testingtesting/
Execution failed for task ':test'.
> Process 'Gradle Test Executor 2' finished with non-zero exit value 1
I have tried increasing my heap size and cloning the project to another location. I have also gone through the gradle docs and the gradle github and have not been able to find anything of particular use.
In addition I have also gone through the IntelliJ setup and configuration tutorials and the JavaFX tutorials but I cannot seem to find anything on the structure or dependencies or anything else relating to the unit tests. I have included additional code information below. (not including the full example because I found the problem)
Directory structure is as follows:
├───.gradle
└───src
├───main
│ └───java
│ └───com
│ └───example
│ └───testingtesting
└───test
└───java
└───!!JUnitTestingFile!!
Gradle Build Script
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.1'
}
group 'com.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.8.2'
}
sourceCompatibility = '17'
targetCompatibility = '17'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'com.example.testingtesting'
mainClass = 'com.example.testingtesting.HelloApplication'
}
javafx {
version = '17.0.1'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,当我发现此出色的教程及其 。
对我的问题是目录结构,应该是以下内容:(
请注意,添加 tests.java.com.junit5 文件夹,而不仅仅是 tests.java 文件夹)
我不会完全理解为什么目录结构会导致错误,因此,如果有人对为什么会发生这种情况有更多的了解,请分享。
我还检查了给定的gradle构建文件,尽管与示例项目确实如此。
Turns out that I missed something in the Directory structure as I found out with this wonderful tutorial and its corresponding git repo.
The problem for me was in the directory structure, which should have been the following:
(note the addition of the tests.java.com.junit5 folder instead of just the tests.java folder)
I will not claim to fully understand why the directory structure caused an error, so if anyone has any more knowledge as to why this happens please share.
I also checked that the given gradle build file continues to work with the new build structure despite having a slightly different dependency from the example project and it does.