Android Jetpack compose:不应使用WaitForActivitisToComplete()方法
我现在所在的州,我想为应用程序编写androidTests 在阅读的文档中,我创建了一个文件,并编写了一个简单的测试来检查进度:Android Jetpack compose:不应使用WaitForActivitisToComplete()方法,android,android-testing,android-instrumentation,android-jetpack-compose,Android,Android Testing,Android Instrumentation,Android Jetpack Compose,我现在所在的州,我想为应用程序编写androidTests 在阅读的文档中,我创建了一个文件,并编写了一个简单的测试来检查进度: test.kt: 类考官测试{ @获取:规则 val composeTestRule=CreateComposetrule() @试验 乐趣atLaunchDefaultTextExists(){ composeTestRule.setContent{ Text(Text=“Text”) } composeTestRule.onNodeWithText(“文本”).
test.kt:
类考官测试{
@获取:规则
val composeTestRule=CreateComposetrule()
@试验
乐趣atLaunchDefaultTextExists(){
composeTestRule.setContent{
Text(Text=“Text”)
}
composeTestRule.onNodeWithText(“文本”).AssertsDisplayed()
}
}
我还在app/src/debug/
中添加了debugAndroidManifest
,以启用文档中建议的ComposeActivity
但是,通过运行测试,不会发生任何事情,测试也不会开始执行
以下是测试获得库存的状态(应用程序已生成并部署,但未开始运行测试。应用程序的正常执行正常工作):
我是否缺少安装中的一个部件?测试没有运行的原因是什么
撰写:1.0.0-alpha05 AS:4.2-金丝雀14 更新 调试测试并检查其日志后,我看到以下错误:
No method shouldWaitForActivitiesToComplete() in
androidx/test/runner/AndroidJUnitRunner
确保test:monitor
和test:core
是最新的
在Android test github上查看这个问题时,我意识到问题可能是因为test:monitor
比需要的时间长。所以我做了以下步骤:
app:dependencies
以查看test:monitor
库的版本
1.2.0
,而不是最新的1.3.0
),请查找降级它的库
在我的例子中,片段测试
将其降级为1.2
,所以我删除了它
test:monitor
和test:core
是最新的之后,我终于可以运行测试了