gpt4 book ai didi

android - 使用 Gradle Spoon 插件在特定位置启动测试

转载 作者:行者123 更新时间:2023-11-29 00:06:42 24 4
gpt4 key购买 nike

我在查找文档时遇到问题,我该如何解决这个问题。

我能够启动小型/中型/大型测试:

./gradlew spoonSmall
./gradlew spoonMedium
./gradlew spoonLarge

或使用此设置启动特定测试:

spoon {
(...)

if (project.hasProperty('spoonClassName')) {
className = project.spoonClassName

if (project.hasProperty('spoonMethodName')) {
methodName = project.spoonMethodName
}
}
}

我可以启动特定文件:

./gradlew spoon -PspoonClassName=com.package.tests.MyTest;

我感兴趣的是启动位于以下位置的所有测试的可能性:

./gradlew spoon -PspoonClassName=com.package.tests

包。两种方法都可以。 bash 控制台的一些参数,或者创建我自己的注释并通过类似 ./gradlew spoonMyTests 启动的方法。

感谢您的建议/帮助。

最佳答案

来自官方文档:

There are numerous ways to run a specific test, or set of tests. You can use the Spoon --size, --class-name or --method-name options, or you can use the --e option to pass arguments to the instrumentation runner, e.g.

--e package=com.mypackage.unit_tests

当直接从命令行(而不是从 gradle 任务)执行 Spoon 时,以下命令应该有效

java -jar spoon-runner-1.1.9-jar-with-dependencies.jar \
--apk ExampleApp-debug.apk \
--test-apk ExampleApp-debug-androidTest-unaligned.apk \
--e package=com.package.tests

您需要找到一种方法将这个额外的参数传递给 Spoon gradle 插件。

更新

来自official doc Spoon Gradle 插件:

Custom instrumentation arguments

Use the instrumentationArgs property on spoon extension to pass custom parameters to your tests:

spoon { instrumentationArgs = ["foo=bar", "name=value"] }

在您的情况下,这应该如下所示:

spoon {   
instrumentationArgs = ["package=com.package.tests"]
}

关于android - 使用 Gradle Spoon 插件在特定位置启动测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33283238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com