Separating integration tests from unit tests in Android Studio

后端 未结 2 975
陌清茗
陌清茗 2021-02-13 23:16

I\'m trying to separate out integration tests in Android Studio 0.9.

I have added the following to the build file:

sourceSets {
    integrationTest {
            


        
2条回答
  •  一生所求
    2021-02-13 23:24

    I've done exactly this kind of separation in Gradle, but for a pure Java project, not Android. You are not specifying the classpath in source sets, which I think is the issue. Here's the relevant part of the build.gradle:

    sourceSets {
        integration {
            java {
                compileClasspath += main.output + test.output
                runtimeClasspath += main.output + test.output
                srcDir file('src/integration/java')
            }
            resources {
                srcDir 'src/integration/resources'
            }
        }
    }
    
    configurations {
        integrationCompile.extendsFrom testCompile
        integrationRuntime.extendsFrom testRuntime
    }
    
    task integrationTest(group: "verification", type: Test) {
        testClassesDir = sourceSets.integration.output.classesDir
        classpath = sourceSets.integration.runtimeClasspath
    }
    integrationTest.dependsOn testClasses
    

    IntelliJ idea picks up the folders under src/integration if they have the standard names (java, resources).

提交回复
热议问题