【问题标题】:Android Test Orchestrator and custom Application classAndroid Test Orchestrator 和自定义应用程序类
【发布时间】:2017-09-21 13:13:09
【问题描述】:

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

  1. 在 Android Studio 3 预览版 Beta 6 中使用向导创建简单项目
  2. 创建自定义运行器,例如:
    class CustomTestRunner : AndroidJUnitRunner() {
      override fun newApplication(cl: ClassLoader?, className: String?,   context: Context?): Application {
       return super.newApplication(cl, TestApplicationClass::class.simpleName, context)
      }
    }
  1. 用新的更换仪表滑轨
  2. 运行插桩测试后未找到测试

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

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

【问题讨论】:

  • 尝试覆盖 AJUR 的 onOrchestratorConnected() 方法,并放 Logs 查看是否为每个测试连接了 orchestrator

标签: android testing


【解决方案1】:

我有类似的问题,使用自定义测试运行器。确保您的 TestApplicationClass 在运行时不会崩溃。如果自定义运行程序崩溃,则编排器将无法获取有关测试的信息并返回消息:

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).

这就是我在自定义跑步者身上发生的事情。

祝你好运!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多