如何从gradle的测试罐中运行测试?

时间:2019-04-14 09:44:01

标签: java gradle junit

我在gradle中构建了一个多项目。在项目gradle-playground-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-playground-b中运行测试jar的测试。因此,我有:

plugins {
    id 'java'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testRuntimeOnly project (path: ":gradle-playground-a", configuration: 'testArtifacts')
}

repositories {
    mavenCentral()
}

但是未运行来自test-jar的测试。当我查看gradles调试输出时,我发现test-jar包含在gradle-playground-b的测试执行的类路径中。

我要做的是具有与mavens surefire depednenciesToScan等效的功能。

在测试gradle-playground-b时如何从测试罐执行测试?

1 个答案:

答案 0 :(得分:-1)

我只是在第一个项目的netbeans中使用一个“按钮”来激活第二个项目。那是我真正知道怎么做的唯一方法,因为我已经完成了一些有限的项目,我很确定您可以使用Visual STudio在VB中进行此操作,但是由于您在Java中使用的是netbeans,而且它是免费的。

相关问题