问题描述
我使用的仪器测试
@RunWith(AndroidJUnit4.class)
来自
import androidx.test.runner.AndroidJUnit4;
以建立我的测试用例.现在,此行被标记为已弃用,并带有使用AndroidJUnit4
from
in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4
from
import androidx.test.ext.junit.runners.AndroidJUnit4
但是,如果我尝试从命名包中导入AndroidJUnit4
,则会出现错误,提示ext
无法解决.
However if I try to import AndroidJUnit4
from the named package I get the error, that ext
can not be resolved.
您有什么主意,应在gradle中包括哪些软件包来解决此问题?
Do you have an idea, what package should be included in gradle to resolve this issue?
推荐答案
根据 AndroidJUnit4的文档,
-
gradle文件应包含以下行:
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
将测试类从AndroidJUnit4
如果仍然无法使用,请确保清理和/或重建项目.您也可以直接在 Google的maven存储库
If it still doesn't work, make sure that you clean and/or rebuild your project. Also you can check the current version directly in Google's maven repository
这篇关于不推荐使用AndroidJUnit4.class:如何使用androidx.test.ext.junit.runners.AndroidJUnit4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!