Pat*_*ick 4 java android gradle cucumber-jvm
我现在使用黄瓜已经有一段时间了,现在我想将测试套件的使用情况从maven迁移到gradle.
我设法准备项目,包括基本用法,运行测试,结果等.我遗漏的最后一块是只能运行在特定标签上过滤的测试.运行验收测试是通过产品风格完成的:
productFlavors {
uats {
testInstrumentationRunner "com.paddy.cuespton.cuespton.test.Instrumentation"
}
full {
applicationId "com.paddy.app.cuespton"
versionName "1.0"
}
}
Run Code Online (Sandbox Code Playgroud)
这使我能够使用任务运行测试:
./gradlew connectedAndroidTestUatsDebug
Run Code Online (Sandbox Code Playgroud)
是否可以将param with tag添加到此任务以仅运行特定测试?
我尝试使用 https://github.com/samueltbrown/gradle-cucumber-plugin/插件,理论上应解决此问题,但由于语言不兼容,我无法使用Android运行.
这是我工作的回购, https://github.com/paddyzab/espresso-cucumber-sandbox.
感谢帮助!
没有尝试这个黄瓜插件,但假设我们有类似的设置,你可以做以下(样本回购):
1)为uats风格定义相应的buildConfigField:
Uats {
testInstrumentationRunner "com.quandoo.gradletestpoc.test.Instrumentation"
// passing instrumentation parameters
buildConfigField "String", "TAGS", "\"${getTagsProperty()}\""
}
Run Code Online (Sandbox Code Playgroud)
2)定义getTagsProperty()方法:
def getTagsProperty() {
return project.hasProperty("tags") ? project.getProperties().get("tags") : ""
}
Run Code Online (Sandbox Code Playgroud)
3)处理自定义检测类的onCreate()方法中的传递标记:
private static final String TAGS_KEY = "tags";
......
@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
// Reading runner params
String tags = BuildConfig.TAGS;
if (!tags.isEmpty()) {
bundle.putString(TAGS_KEY, tags);
}
instrumentationCore.create(bundle);
start();
}
Run Code Online (Sandbox Code Playgroud)
4)跑
./gradlew connectedAndroidTestUatsDebug -Ptags="@bar"
Run Code Online (Sandbox Code Playgroud)
请享用!
| 归档时间: |
|
| 查看次数: |
3235 次 |
| 最近记录: |