android - Android测试用例等待10分钟后才能在debug模式下调试
问题描述
它以前工作过。但现在已经不行了。IDE 只显示“实例化测试...”。但是当我等了 10 分钟时,它突然就起作用了?该机器是 2015 年中的 Macbook Pro。问题仅出现在androidTest
,test
目录工作正常。
@LargeTest
@RunWith(AndroidJUnit4::class)
class SomeTestClass {
@get:Rule
var activityTestRule = ActivityTestRule(
NavigationActivity::class.java, false, false)
@Before
fun before() {
Timber.d("When debugging, this triggers only after about 10 minutes.")
}
@Test
fun testContents() {
Assert.assertEquals(0, 0)
}
}
日志不断输出:
D/EZIO_NLOG: watchdog_routine executed!
D/EZIO_NLOG: check1
check1
check2
check2
尝试了以下事情:
- 文件,使缓存无效/重新启动
- 试过这个答案。但它似乎已经过时了。
- 编辑配置...,选择“All in Package”、“Class”和“Method”。它们都不起作用。
- 当我等了很长时间,比如 10 分钟,然后突然之间它就会触发并起作用。
解决方案
Android 测试很慢,并且在该调试器之上增加了更多负载。我遇到了同样的问题,我同意使用带有 Android 测试的调试器是一件痛苦的事情。
下面是我在这里找到的东西
Espresso detects when the main thread is idle, so it is able to run your test commands at the appropriate time, improving the reliability of your tests.
最重要的是,当添加调试器时,它会变得更慢。
您可以尝试在真实设备上运行测试,它应该更快(我假设)
推荐阅读
- nix - nix nixlang:通过 nix-build -A hello 在 default.nix 中未定义的变量 pkgs,但在 nix repl 中有效
- makefile - makefile 中的“变量”目标名称
- c++ - Arduino-C++ Bool 不会从 False 变为 True
- r - 传单:: 映射错误的国家名称
- node.js - 如何强制node.js pm2基于ipv4运行
- c++ - 使用 Visual Studio 2019 正确设置 tinycc,未找到库 libtcc1-32.a
- rust - 泛型函数中的 Rust 生命周期问题
- javascript - 在选择下拉列表中更改值时更新引导日期选择器的 DaysOfWeekDisabled
- flutter - Flutter:为什么 Provider 比只有静态单例的 AppGlobal 类更好?
- java - 从数组创建 toString