Runtime Dependencies in Software Model Tests

(Ramon Wirsch) #1

the Unit Test for my project uses Mockito.
In an old-model test, in which i declared the Mockito dependency as follows, everything works

dependencies {
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'

But when using the software model like this:

test(JUnitTestSuiteSpec) {
    jUnitVersion '4.12'
    testing $.components.main
    dependencies {
        module 'org.mockito:mockito-core:1.10.19'

the test crashes with

java.lang.ClassNotFoundException: org.objenesis.ObjenesisStd

declaring the objenisis library explicitly as

module 'org.objenesis:objenesis:2.1'

makes it work.

Examining the classpath actually used to Execute the test, shows that the library in question is not on it.

Since Objenisis is a runtime dependency of mockito, this leads me to believe, that runtime dependencies (at least on maven artifacts) do not work correctly with the new software model tests.

I verified the described behavior on gradle 2.12 and 2.13-rc1.