Android Test Orchestrator和自定义Application类

时间:2017-09-21 13:13:10

标签: android testing

我尝试了 Android Test Orchestrator ,如果 Application 类被更改,它就看不到任何测试。很容易重现。

  1. 在Android Studio 3预览测试版中,使用向导创建简单项目
  2. 创建自定义转轮,例如:
  3.     class CustomTestRunner : AndroidJUnitRunner() {
          override fun newApplication(cl: ClassLoader?, className: String?,   context: Context?): Application {
           return super.newApplication(cl, TestApplicationClass::class.simpleName, context)
          }
        }
    
    1. 用新的替换仪表运行器
    2. 运行检测测试后未找到测试
    3. 有什么想法吗?看起来Orchestrator依赖于清单中的应用程序类名称。

      我使用此配置为测试使用特殊的Dagger依赖项。

1 个答案:

答案 0 :(得分:0)

我有类似的问题,有一个自定义测试运行器。确保TestApplicationClass在运行时不会崩溃。如果自定义运行器崩溃,那么orchestrator将无法获取有关测试的信息,并将返回消息:

No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).

这就是我的自定义选手中发生的事情。

祝你好运!