Android Studio测试显示测试结果0/0,如何开始测试?

hk8txs48  于 2023-01-13  发布在  Android
关注(0)|答案(2)|浏览(288)

我正在Android Studio中学习Kotlin初学者课程,在测试阶段,测试结果总是0/0。我如何完成这些测试?
代码是由谷歌Android开发人员,它应该工作完美。(我用了相同的)。应用程序编译没有错误。代码在这里:https://github.com/google-developer-training/android-basics-kotlin-words-app
我尝试了各种解决方法:

这可能与Android Studio版本- Bumblebee或模拟器中的一些设置有关,以阻止测试。我怀疑这一点,因为当创建以前的应用时,在测试阶段发生了同样的事情(测试结果0/0)
测试结果显示:
2004年5月21日06时18分:正在Pixel 3 API 29上启动“navigate_to_words_...()”。应用程序重启成功,无需重新安装。正在运行测试
$ adb shell am instrument -w -m -e调试错误-e类'com.example.wordsapp.navigationTests#导航到单词导航组件' com.example.wordsapp.test/android.support.test.runner.androidJUnitRunner已连接到设备“Pixel_3_API_29 [模拟器-5556]”上的进程10870。〉
你对此有何看法?谢谢你抽出时间!

odopli94

odopli941#

请查看原始的build.gradle-您使用了错误的测试运行程序:

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vsnjm48y

vsnjm48y2#

在我的情况下,测试工作,但今天还没有开始。我尝试:

  • 使高速缓存无效并重新启动,
  • 编辑配置,
  • 更改设置(Java版本等),
  • 将项目与Gradle文件同步,
  • checkout 旧的提交并尝试从那里构建,
  • 恢复默认IDE设置,
  • 擦拭仿真器,
  • 构建应用程序。

然后我启动了应用程序,发现它没有启动(启动时崩溃)。在Logcat中,我看到一个错误,并试图解决它。在我的例子中,它是Didn't find class "androidx.core.app.CoreComponentFactory",但解决方案是https://stackoverflow.com/a/74836005/2914140

android.useAndroidX=true
android.enableJetifier=true

gradle.properties中。
在那之后我发现一个问题是一个糟糕的依赖注入。我修复了它并恢复回gradle.properties

相关问题