簡體   English   中英

如何從gradle的測試罐中運行測試?

[英]How to run tests from a test-jar in gradle?

我在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()
}

但是,不會運行來自測試罐的測試。 當我查看gradles調試輸出時,我看到test-jar包含在classpath中,用於gradle-playground-b的測試執行。

我正在嘗試做的是擁有等效的depednenciesToScan功能。

測試gradle-playground-b時,如何從test-jar執行測試?

我只是在第一個項目的netbeans中使用“按鈕”來激活第二個項目。 這是我真正知道該怎么做的唯一方法,因為我已經完成了一些有限的項目,我很確定您可以使用Visual STudio在VB中執行此操作,但是由於您在Java中使用netbeans並且它是免費的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM