Search code examples
androidandroid-studiogradleandroid-testing

Share code between Local Tests and Instrumented Test?


Is there a way to share code between those two without creating another module/external library ?


Solution

  • It's been 5 years so hopefully you figured it out, but in case someone stumbles on this.

     // This allows us to share classes between androidTest & test directories.
    android.sourceSets {
        test {
            java.srcDirs += "$projectDir/src/testShared"
        }
        androidTest {
            java.srcDirs += "$projectDir/src/testShared"
        }
    }