Gradle:从依赖运行测试

时间:2015-12-11 19:45:52

标签: java gradle jbehave

我有两个项目:

  • 申请项目---项目A
  • 带验收测试的项目(on JBehave)---项目B

buid.gradle ---项目B(使用jbehave测试):

task sourceJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allJava
}

task testJar(type: Jar, dependsOn: testClasses) {
    classifier = 'tests'
    from sourceSets.test.output 
}

artifacts {
    archives sourceJar, testJar
}

uploadArchives {
    repositories.mavenDeployer {  
        if(project.ext.isReleaseVersion){
            repository (url: '[RepUrl]') {
                authentication (userName: 'user', password: 'pass')
            }  
            println "Upload to internal"
        }else{
            snapshotRepository (url: '[RepUrl]') {
                authentication (userName: 'user', password: 'pass')
            }  
            println "Upload to snapshots"
        }

        pom.version = '0.1'
        pom.artifactId = 'acceptance-tests'        
        pom.groupId = 'group' 
}

build.gradle ---项目A:

dependencies {
    testRuntime ('group:acceptance-tests:latest.release:tests')
}

当我运行gradlew test int时,项目A不会进行单一测试。

请告诉我,我的错误在哪里。

1 个答案:

答案 0 :(得分:0)

它无效。应该运行的测试类在SourceSets中配置。它来自java插件。读这个。 https://docs.gradle.org/current/userguide/java_plugin.html。我不认为您可以将其配置为使用某些依赖项。也许你可以改变测试任务的行为,你应该看一下测试任务的源代码。或者您可以编写自己的测试任务。您还可以添加一个新操作来测试任务并运行junit以使用ant.junit等其他工具执行测试。

相关问题