Java 如何在gradle中从测试jar运行测试?
我在gradle有一个多项目构建。在projectJava 如何在gradle中从测试jar运行测试?,java,gradle,junit,Java,Gradle,Junit,我在gradle有一个多项目构建。在projectgradle-playway-a中,我正在使用一些junit测试创建一个测试jar: plugins { id 'java' } dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' } repositories { mavenCentral() } test.enabled = false configurations
gradle-playway-a
中,我正在使用一些junit测试创建一个测试jar:
plugins {
id 'java'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
repositories {
mavenCentral()
}
test.enabled = false
configurations {
testArtifacts.extendsFrom testRuntime
}
task testJar(type: Jar) {
classifier "test"
from sourceSets.test.output
}
artifacts {
testArtifacts testJar
}
现在,我想在另一个项目gradle-playerly-b
中运行测试jar的测试。因此,我有:
plugins {
id 'java'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testRuntimeOnly project (path: ":gradle-playground-a", configuration: 'testArtifacts')
}
repositories {
mavenCentral()
}
但是,不会运行来自测试jar的测试。当我查看gradles调试输出时,我看到测试jar包含在类路径中,用于执行gradle-playway-b
我想做的是有一个功能的等价物
在测试
gradle-playway-b
时,如何从测试jar执行测试?我只需在第一个项目上的netbeans中使用一个“按钮”来激活第二个项目。这是我真正知道如何做到这一点的唯一方法,因为我已经完成了很多有限的项目,我很确定您可以在VB中使用Visual STudio来实现这一点,但因为您的Java中使用了netbeans,而且它是免费的。对不起,我使用的是命令行中的纯渐变。这似乎对我没有帮助。