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.
Parallel executionBy using the --parallel switch, you can force Gradle to execute tasks in parallel as long as those tasks are in different projects. You could see big improvements in build times as soon as you enable parallel builds.
The subproject producer defines a task named buildInfo that generates a properties file containing build information e.g. the project version. You can then map the task provider to its output file and Gradle will automatically establish a task dependency. Example 2.
Run Gradle testsIn your Gradle project, in the editor, create or select a test to run. From the context menu, select Run <test name>. icon in the left gutter. If you selected the Choose per test option, IntelliJ IDEA displays both Gradle and JUnit test runners for each test in the editor.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With