Anyone able to run tests from "test" dependency jars in gradle build? I have a gradle build script which includes few test-jars as well under testRuntime dependency. I would like to run the tests in these dependencies using "gradle test".
I see that gradle does not have out-of-box solution to run tests from a jar as mentioned in this link. I am trying to follow the "unpack" option suggested in this post. Am not sure how do I tie the unpack task with test task to iterate over all the test-jar dependencies and run the tests? PS: I know that we do not have to run tests of dependencies in consuming projects. But for my reasons, I have to do this.
Any gradle experts on how to achieve this?
[EDIT]
I used the below to code to run tests from a jar. But what I want is a generic task such as "runTestsFromDependencyJars" which goes through all the test configuration dependencies and run the test. Not sure how do I get it to run for all such dependencies?
task unzip(type: Copy ) {
from zipTree(file('jar file with absolute path'))
into file("$temporaryDir/")
}
task testFromJar(type: Test , dependsOn: unzip) {
doFirst {
testClassesDir=file("$temporaryDir/../unzip/")
classpath=files(testClassesDir)+sourceSets.main.compileClasspath+sourceSets.test.compileClasspath
}
}