Gradle测试未与javafx项目一起运行
build.gradle:Gradle测试未与javafx项目一起运行,java,gradle,Java,Gradle,build.gradle: plugins { id 'java' id 'application' id 'org.openjfx.javafxplugin' version '0.0.8' } mainClassName = 'mvc.Main' repositories { mavenCentral() } dependencies { testImplementation('org.junit.ju
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
mainClassName = 'mvc.Main'
repositories {
mavenCentral()
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter-api:5.6.0-M1')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.6.0-M1')
testCompile('org.mockito:mockito-core:3.1.0')
testCompile('com.athaydes.automaton:Automaton:1.3.2')
testCompile("org.testfx:testfx-core:4.0.16-alpha")
testCompile("org.testfx:testfx-junit:4.0.15-alpha")
testImplementation('org.hamcrest:hamcrest:2.2')
implementation 'com.github.cliftonlabs:json-simple:3.1.0'
}
applicationDefaultJvmArgs = [ "-Djdk.gtk.version=2"]
sourceCompatibility = 11
targetCompatibility = 11
test {
useJUnitPlatform()
dependsOn 'cleanTest'
testLogging {
events "passed", "skipped", "failed"
}
}
javafx {
modules = ['javafx.controls', 'javafx.fxml']
version = '11.0.2'
}
我的项目结构通常是:
src/main/java/mvc/main.java
src/test/java/mvc/MainTest.java
当我运行gradle测试或./gradlew测试时,它不会执行任何测试,不确定出了什么问题。您能尝试更改
testRuntime
→ testRuntimeOnly
和testCompile
→ testCompileOnly
看看这是否解决了什么问题?你说的“它不执行任何测试”是什么意思?你得到了什么输出?您是否有任何错误?是否可以尝试更改testRuntime
→ testRuntimeOnly
和testCompile
→ testCompileOnly
看看这是否解决了什么问题?你说的“它不执行任何测试”是什么意思?你得到了什么输出?你有错误吗?