如何导入实现注释的类@RunTestInLooperThread

时间:2017-10-23 08:50:52

标签: asynchronous testing junit realm looper

我是Realm和Android编程的新手。我在实现异步登录(SyncUser.loginAsync)的JUnit测试时遇到问题。 当我运行测试时,我收到错误:

“只能从looper线程进行异步登录。不能在没有looper的线程上自动更新Realm。”

为了解决这个问题,我发现我应该导入这些类(添加注释@RunTestInLooperThread以便在Looper中运行测试):

import io.realm.rule.RunInLooperThread;
import io.realm.rule.RunTestInLooperThread;
import io.realm.rule.TestRealmConfigurationFactory;

但是找不到包io.realm.rule.*

我应该怎么做才能导入这些类?

我正在使用gradle插件io.realm:realm-gradle-plugin:4.1.0

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

我们的内部仪器测试正在使用这些类。它们不是以公共方式分发的。

但是,如果您需要,可以直接从我们的Github仓库中复制它们: https://github.com/realm/realm-java/tree/master/realm/realm-library/src/testUtils/java/io/realm/rule