gradle - Include tests from other module -
my project looks this:
├───module1-test-cases │ └───src │ └───test │ └───groovy │ └───specs │ └───module1test └───module2-test-cases └───src └───test └───groovy └───specs └───module2test
there lot different modules, each module has own build.gradle file, can run tests separate modules
example of build.gradle
dependencies{ compile("org.codehaus.groovy:groovy-all:2.3.3") compile project(":core") compile("commons-codec:commons-codec:1.10") testcompile("junit:junit:4.11") testcompile project(":module2-test-cases") } test{ exclude '**/smth/**' }
i want include tests other module when run gradle test task runs tests current module , module want.
if multi-project, running test
on root run tests in of modules.
if want run module1
tests when runing module2
tests can depend on test task.
in module1 build.gradle
test.dependson(':module2:test')
this going run module2 test
task before running module1 test
task , if run root test
task not going run them twice.
also, can put dependson
inside task.
test{ dependson ':othermodule:test' exclude '**/smth/**' }
gradle take care running test classes, dont need classes want run. test discovery (depending on project structure , sourcesets) you.
Comments
Post a Comment