Anyone who can run tests from the "test" dependency tanks in gradle build? I have a gradle build script that includes several test jars, as well as a testRuntime dependency. I would like to run tests in these dependencies using the "gradle test".
I see that gradle does not have a ready-made solution for running tests from a jar, as mentioned in this link . I am trying to follow the "unpack" options suggested in this post. Not sure how to connect the unpacking task with the test task for iterating over all the dependencies of the test jar and running the tests? PS: I know that we do not need to run dependency tests in consuming projects. But for my reasons I have to do this.
Any gradle experts on how to achieve this?
[EDIT]
I used the code below to run tests from a jar. But what I want is a general task, such as "runTestsFromDependencyJars", which goes through all the test configuration dependencies and runs the test. Not sure how can I make it work 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
}
}