首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android工具:使用内插通过测试选项

Android工具:使用内插通过测试选项
EN

Stack Overflow用户
提问于 2022-03-18 04:50:02
回答 1查看 21关注 0票数 0

我试图将一些测试选项传递给我的Android工具测试,如下所示:

代码语言:javascript
复制
export value1="abcd"
export value2="pqrs"
export value3="xyz"

adb shell 'CLASSPATH=$(pm path androidx.test.services) app_process / \
  androidx.test.services.shellexecutor.ShellMain am instrument -r -w -e \
  targetInstrumentation com.example.test/com.example.runner.CustomAndroidRunner \
  -e class com.example.TestingDemo#testWithoutApiInvocation \
  -e clearPackageData true -e debug false \
  -e myKey1 "$value1" \
  -e myKey2 "$value2" \
  -e myKey3 "$value3" \
  androidx.test.orchestrator/androidx.test.orchestrator.AndroidTestOrchestrator'

在我的测试代码中,我得到了myKey(1)(2)(3)的空值。

根据我的理解,bash变量不会在单引号中展开。因此,当我在双引号中包含上面的命令时,它没有运行。

是否有可能像我上面所做的那样将变量值传递给测试?

EN

回答 1

Stack Overflow用户

发布于 2022-03-18 04:56:50

回答我自己的问题。在调试了更多之后,我能够让它按下面的方式工作。

代码语言:javascript
复制
adb shell 'CLASSPATH=$(pm path androidx.test.services) app_process / \
  androidx.test.services.shellexecutor.ShellMain am instrument -r -w -e \
  targetInstrumentation com.example.test/com.example.runner.CustomAndroidRunner \
  -e class com.example.TestingDemo#testWithoutApiInvocation \
  -e clearPackageData true -e debug false \
  -e myKey1' "$value1" '\
  -e myKey2' "$value2" '\
  -e myKey3' "$value3" '\
  androidx.test.orchestrator/androidx.test.orchestrator.AndroidTestOrchestrator'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71522591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档