You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询Android Gradle命令行Espresso测试的可选参数及文档位置

Android Gradle Espresso测试命令行参数查询及可用参数说明

一、-Pandroid.testInstrumentationRunnerArguments.* 可用参数

这类参数是传递给Android测试运行器(默认是AndroidJUnitRunner)的配置项,常见可用参数包括:

  • class:指定要运行的单个测试类或测试套件,示例:com.aaa.bbb.Suites.CITestSuite
  • package:指定测试包范围,仅运行该包下的测试用例
  • notClass:排除指定的测试类
  • notPackage:排除指定的测试包
  • size:按测试规模过滤,可选值:small、medium、large
  • annotation:仅运行带有指定注解的测试,比如androidx.test.filters.LargeTest
  • notAnnotation:排除带有指定注解的测试
  • debug:启用测试调试模式,取值true或false
  • log:控制测试日志输出级别,比如log=debug

二、-Pandroid.experimental.androidTest.* 可用实验性参数

这类是Android Gradle插件提供的实验性测试配置参数,除了你用到的numManagedDeviceShards(设置托管设备的测试分片数量),还有:

  • shardIndex:指定当前测试分片的索引,需配合numManagedDeviceShards使用,分片数为2时索引可取0或1
  • useOrchestrator:启用Android Test Orchestrator测试编排器,取值true或false
  • clearPackageData:在每个测试类执行前清除应用数据,需配合测试编排器使用,取值true或false
  • enableTestStorage:启用测试存储功能,用于留存测试结果和日志,取值true或false

三、参数文档查询方法

  1. 本地任务帮助:在项目根目录执行命令 ./gradlew help --task pixel4api31DebugAndroidTest,会输出该测试任务支持的所有参数说明
  2. Android Gradle插件文档:在Android Studio中查看当前项目使用的AGP版本,对应版本的插件测试配置章节会列出所有支持的命令行参数
  3. 测试运行器注释:通过Android Studio的代码跳转功能查看AndroidJUnitRunner类的注释,里面会详细说明可通过testInstrumentationRunnerArguments传递的参数

内容的提问来源于stack exchange,提问作者reutsey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 02:31:16