"RobolectricTestRunner.class";在Android Studio中无法识别 [英] "RobolectricTestRunner.class" not recognized in Android Studio
本文介绍了"RobolectricTestRunner.class";在Android Studio中无法识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Robolectric运行单元测试,但是Android Studio无法识别以下类:
I'm trying to use Robolectric to run unit tests but the Android Studio is not recognizing the class on:
@RunWith(RobolectricTestRunner.class)
详细信息:
classpath 'com.android.tools.build:gradle:3.0.0'
我正在导入依赖项:
testImplementation "org.robolectric:robolectric:3.5.1"
并且:
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
它根本不会出现导入类的选项.我应该添加更多我忘记的依赖吗?
It simply does not appear option to import the class. Should I add any more dependencies I'm forgetting?
错误:
error: package org.robolectric does not exist
error: package org.robolectric does not exist
error: package org.robolectric.shadows does not exist
error: cannot find symbol class RobolectricTestRunner
error: cannot find symbol variable Robolectric
error: cannot find symbol variable ShadowApplication
推荐答案
我解决了此问题,只需将测试类放在 src \ test
文件夹中,而不是将其放在 src中\ androidTest
文件夹
I solved the issue just by putting the test class inside the src \ test
folder instead of putting it in thesrc \ androidTest
folder
这篇关于"RobolectricTestRunner.class";在Android Studio中无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文