10

ProjectA contains an abstract unit test, TestA.

ProjectB has a test called TestB, which needs to extends from TestA, to fulfil the test requirements for this specific implementation.

I've added to the build.gradle configuration file on ProjectB, ProjectA as a dependency compilation test:

testCompile project(':ProjectA')

Also, as a dependency compilation:

compile project(':ProjectA')

Although I'm able to extend from TestA, when I try to run TestB I get the next error:

error: cannot find symbol class TestA

So, is there any way to share test code between modules?

Thanks.

Víctor Albertos
  • 8,093
  • 5
  • 43
  • 71

1 Answers1

4

As mentioned in this question you should add dependency on test sources like this:

compileTestJava.dependsOn tasks.getByPath(':projectA:testClasses')
testCompile files(project(':projectA').sourceSets.test.output.classesDir)
Community
  • 1
  • 1
tkachuko
  • 1,956
  • 1
  • 13
  • 20