【发布时间】:2015-10-14 07:31:56
【问题描述】:
我有一组测试(用于我的 Android 应用程序),可以在 Android Studio 中以 Junit 方法运行(右键单击 testClass 文件并运行它)。它确实取决于使用 Robolectric 的 Android 模块。在 Android Studio 1.3.1 之前它运行良好。
但是,当我迁移到 Android Studio 1.4 时,当我同步我的 Gradle 文件时,会出现此警告
Warning:Ignoring dependency of module 'app' on module 'unit-tests'. Java modules cannot depend on Android modules
这样,我的测试也不能再被触发,因为我所有的 Android 类,例如AppCompat 不再可检测。
我的部分 gradle 代码如下,其中 :app 是我的 android 模块。
def androidModule = project(':app')
dependencies {
testCompile androidModule
//... some other dependency
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'org.mockito:mockito-all:1.9.5'
//... some other dependency
}
如果这是新的 Android Studio 1.4 行为、我的 gradle 文件中有问题,或者只是一个新的 Android Studio 1.4 错误,有人可以对此有所了解吗?
【问题讨论】:
-
有趣的是,'org.robolectric:robolectric:2.4' 也会发生这种情况。我有 robolectric v3.0,它也失败了。
-
我也更新到Android Studio v1.5 Preview,还是不行。
-
这有点糟透了...... wth
-
是的,@worked,这是一个很大的退步。因此,我仍然坚持使用我的 1.3.1...也许您可以考虑对上面的问题/问题进行投票以引起更多关注。
-
在 2.0 预览版中似乎仍然存在同样的问题
标签: android-studio gradle junit junit4 robolectric