I'm using Gradle in Android Studio 3.x and it's multi-module and includes Java libraries.
I want to implement the test of the Java library in Spock.
There are various ways to install Spock, but I will add it to the module build.gradle. However, the important point of this article is the destinationDir on the last line.
apply plugin: 'groovy'
dependencies {
testCompileOnly 'org.codehaus.groovy:groovy:2.5.3'
testCompileOnly('org.spockframework:spock-core:1.2-groovy-2.5') {
exclude module: 'groovy-all'
}
}
compileTestGroovy.destinationDir = compileTestJava.destinationDir
When executed from the triangle that appears to the left of the test class in hoge.groovy, gradle's tax runs compile (compileTestGroovy) as groovy and .class is generated, but it is hoge / build / classes / groovy / test Generated in /
.
But Test in Android Studio? Seems to be JUnit, so it seems that it refers to .class of hoge / build / classes / java / test /
.
As a result, the test cannot be executed with an error of Class not found:" hogehoge "Empty test suite.
.
Therefore, set compileTestGroovy.destinationDir
to the same .class output destination as Java.
Recommended Posts