【问题标题】:Android Test cases can only be debugged in debug mode after 10 minutes of waitingAndroid测试用例等待10分钟后才能在debug模式下调试
【发布时间】:2020-08-13 13:30:29
【问题描述】:

它以前工作过。但现在已经不行了。 IDE 只显示“实例化测试...”。但是当我等了 10 分钟时,它突然就起作用了?机器是Macbook Pro,2015年中。问题只出现在androidTesttest目录工作正常。

@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 

尝试了以下方法:

  1. 文件,使缓存无效/重新启动
  2. 试过this answer。但它似乎已经过时了。
  3. 编辑配置...,选择“All in Package”、“Class”和“Method”。它们都不起作用。
  4. 当我等待很长时间(例如 10 分钟)时,它会突然触发并起作用。

【问题讨论】:

  • 您使用的是模拟器还是设备?

标签: android kotlin testing


【解决方案1】:

Android 测试很慢,并且在调试器之上增加了更多负载。我也遇到过同样的问题,我同意在 Android 测试中使用调试器很痛苦。

下面是我找到的here 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.

除此之外,当添加调试器时,它会变得更慢。

您可以尝试在真实设备上运行测试,它应该会快一点(我假设)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-25
    • 2023-04-02
    • 2023-01-28
    • 2019-10-13
    • 2013-05-11
    • 2019-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多