我正在使用Android Test Orchestrator来运行我的 UI 测试,并且需要在所有测试完成后生成结果报告。我需要在编排器开始运行测试以及完成运行所有测试时进行回调,以便我可以生成并保存报告。
鉴于为每个测试创建了一个新实例AndroidJUnitRunner,我无法利用onStart()并finish()做到这一点。
我正在寻找一种方法来提供自定义编排器,以便我可以使用内部方法。
android android-testing android-espresso android-junit androidjunitrunner
我正在尝试从需要与 Android Test Orchestrator 一起运行的测试套件中获取覆盖率报告。
按照他们的建议,我添加了
testInstrumentationRunnerArguments coverageFilePath: '/data/local/tmp/codeCoverage'
Run Code Online (Sandbox Code Playgroud)
但我仍然得到
java.io.IOException: No coverage data to process in directories [[buildDr]/outputs/code_coverage/stageTestDebugAndroidTest/connected]
Run Code Online (Sandbox Code Playgroud)
我认为它可能与测试发行说明存档页面中的这一行有关
如果“coverage”和“coverageFilePath”参数都被传递,则仅启用协调器覆盖处理。
我试过添加
testInstrumentationRunnerArguments coverage: 'true'
Run Code Online (Sandbox Code Playgroud)
它没有什么区别,我找不到任何关于实际应该传递什么的信息。
你知道我缺少什么吗?
一个工作示例的链接也非常好。
android android-testing android-espresso androidjunitrunner android-test-orchestrator
我androidx.test在我的项目中使用库(我最近迁移到的)并使用自定义AndroidJUnitRunner. 迁移之前一切正常,但现在我收到此错误 -
Started running tests
Test running failed: Instrumentation run failed due to 'Process crashed.'
Empty test suite.
我使用的自定义跑步者类扩展自androidx.test.runner.AndroidJUnitRunner
在我的应用程序build.gradle文件中,我有以下设置 -
testInstrumentationRunner "com.example.CustomTestRunner"
具有依赖关系 -
androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation "androidx.test:rules:1.1.1"
我所有的测试课都有@RunWith(androidx.test.ext.junit.runners.AndroidJUnit4.class)
我被困在这个问题上。任何帮助,将不胜感激。谢谢。
我kotlin collections library (listOf, first, toList, etc,..在我们的AndroidTest包中使用) 方法来运行 UI 测试,AndroidJunit4 runner并且在我提到 kotlin 集合库的任何地方都会遇到这些类型的错误。
java.lang.NoSuchMethodError: No static method listOf(Ljava/lang/Object;)Ljava/util/List; in class Lk/v/i; or its super classes (declaration of 'k.v.i' appears
Run Code Online (Sandbox Code Playgroud)
奇怪的是我在编译时没有看到任何问题,也没有在类级别独立运行测试时看到任何问题。仅当我使用 Gradle 运行整个测试套件时才会出现此问题
这是我用来使用 Gradle 运行 UI 测试套件的命令
./gradlew connectedCheck --info --full-stacktrace --no-build-cache --debug
Run Code Online (Sandbox Code Playgroud)
我怀疑在运行时加载的类似乎与编译时不同
这是build.gradle依赖项
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.71"
// Instrumented Tests
testImplementation "androidx.test:core:1.2.0"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Run Code Online (Sandbox Code Playgroud) android kotlin android-uiautomator android-junit androidjunitrunner
从 CI 运行测试时发现崩溃。阅读这篇关于使用 Android Test Orchestrator 的文章 ( https://developer.android.com/training/testing/junit-runner#ato-gradle )。我正在使用 adb 从 CI 运行我的测试。想知道如何安装orchestrator。apk 在命令行中?