当我添加
dependencies { testCompile 'org.mockito:mockito-all:1.9.5' }
到我的 build.gradle ,JAR文件被下载,但编译失败
build.gradle
error: package org.mockito does not exist
以及一系列后续错误。当我更换 testCompile 通过 compile ,它起作用。关于Gradle,我还是个初学者,但是 测试编译 听起来很对。而且,
testCompile
compile
测试编译
testCompile 'junit:junit:4.+' testCompile 'com.google.guava:guava-testlib:18.+'
工作正常。有人能解释一下这里发生了什么吗?
有了这种配置(而且是正确的),使用Mockito的代码需要在 src/test/java 而不是 src/main/java . testCompile 定义编译依赖项 src/test/java .
src/test/java
src/main/java