如何使用MockK编写线程的单元测试

时间:2019-09-24 10:30:43

标签: android unit-testing mockk

我想使用mockK库为以下功能编写单元测试:

gpg> expire
...enter the new expiration date...
gpg> save

我尝试使用嘲笑中提供的线程:

void function_name() {
    new Thread(() -> {
        try {
            Thread.sleep(4000);
            //some code
        } catch (InterruptedException e) {
              e.printStackTrace();
        }
    }).start();
}

但是测试无法通过验证块提供。

如何测试包含延迟的上述功能。

0 个答案:

没有答案