Gradle testCompile with mockito cannot find package

When i add

dependencies { testCompile 'org.mockito:mockito-all:1.9.5' } 

to my build.gradle , the JAR file is loading, but compilation fails with

 error: package org.mockito does not exist 

and a bunch of subsequent errors. When I replace testCompile with compile , it works. I'm still pretty new to Gradle, but testCompile sounds just right for me. Moreover,

 testCompile 'junit:junit:4.+' testCompile 'com.google.guava:guava-testlib:18.+' 

works just fine. Can someone explain what is going on here?

+5
source share
1 answer

With this configuration (and rightly so), the code that Mockito uses should be in src/test/java , not src/main/java . testCompile defines compilation dependencies for src/test/java .

+8
source

Source: https://habr.com/ru/post/1201445/


All Articles