【发布时间】:2015-08-06 06:49:09
【问题描述】:
我想设置我的项目以进行单元测试。
我尝试按照Android's page上的说明进行操作:
// Unit testing dependencies
testCompile 'junit:junit:4.12'
// Set this dependency if you want to use Mockito
testCompile 'org.mockito:mockito-core:1.10.19'
// Set this dependency if you want to use Hamcrest matching
androidTestCompile 'org.hamcrest:hamcrest-library:1.1'
但是,在这样做并创建测试时,我得到:
“无法解析符号‘junit’”
“无法解析符号'mockito'”
在Vogel's tutorial 中,需要更多的依赖项,而我想要最低限度。
另外,使用 Vogel 的教程,我得到:
警告:与依赖项“com.android.support:support-annotations”冲突。应用 (22.2.1) 和测试应用 (22.2.0) 的已解决版本不同。
所以我的问题是:如何让 Android 页面的依赖项正常工作?
【问题讨论】:
-
您是否尝试过明确添加
testCompile 'com.android.support:support-annotations:22.2.1'? -
是的。没有帮助:/
-
我试图回答您的一些问题,但对于“无法解析符号 'junit'”错误,尚不清楚您何时以及如何得到它。只是通过尝试输入代码? gradle 是否真的有效并将依赖项放入项目中? gradle 构建失败了吗?
-
我也遇到了同样的问题,你找到解决办法了吗?
标签: android unit-testing junit mockito