Adding an additional test suite to Gradle

前端 未结 3 1463
不知归路
不知归路 2020-12-16 16:53

I am attempting to add Gradle (1.4) to an existing project that has multiple test suites. The standard unit test located in src/test/java ran successfully, but

相关标签:
3条回答
  • 2020-12-16 17:06

    the "integration" sourceSet has not configured its compile and runtime classpath. That's why it can't find the classes from your main sourceset. you can configure the compile and runtime classpath in the following way:

    sourceSets {
        integTest {
            java.srcDir file('src/integration-test/java')
            resources.srcDir file('src/integration-test/resources')
            compileClasspath = sourceSets.main.output + configurations.integTest
            runtimeClasspath = output + compileClasspath
        }
    }
    
    0 讨论(0)
  • 2020-12-16 17:13

    Another way:

    test {
        exclude '**/*IntegrationTest*'
        ...
    }
    
    task testIntegration(type: Test) {
        include '**/*IntegrationTest*'
        ...
    }
    
    0 讨论(0)
  • 2020-12-16 17:23

    In most cases you want to use the same dependencies as your unit tests as well as some new ones. This will add the dependencies of your unit tests on top of the existing ones for integration tests (if any).

    sourceSets {
        integrationTest {
            compileClasspath += sourceSets.test.compileClasspath
            runtimeClasspath += sourceSets.test.runtimeClasspath
        }
    }
    
    0 讨论(0)
提交回复
热议问题