我试图将一些测试选项传递给我的Android工具测试,如下所示:
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变量不会在单引号中展开。因此,当我在双引号中包含上面的命令时,它没有运行。
是否有可能像我上面所做的那样将变量值传递给测试?
发布于 2022-03-18 04:56:50
回答我自己的问题。在调试了更多之后,我能够让它按下面的方式工作。
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'https://stackoverflow.com/questions/71522591
复制相似问题