Android Test Orchestrator 和自定义应用程序类

Ser*_*kov 5 testing android

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

  1. 在 Android Studio 3 preview Beta 6 中使用向导创建简单的项目
  2. 创建自定义跑步者,如:
    class CustomTestRunner : AndroidJUnitRunner() {
      override fun newApplication(cl: ClassLoader?, className: String?,   context: Context?): Application {
       return super.newApplication(cl, TestApplicationClass::class.simpleName, context)
      }
    }
Run Code Online (Sandbox Code Playgroud)
  1. 更换新的仪器转轮
  2. 运行仪器测试后未找到测试

有任何想法吗?看起来 Orchestrator 依赖于清单中的应用程序类名。

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

Tom*_*tel 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).

这就是我在定制跑步机中发生的事情。

祝你好运!