我现在使用黄瓜已经有一段时间了,现在我想将测试套件的使用情况从maven迁移到gradle.
我设法准备了项目,包括基本用法,运行测试,结果等.
我遗漏的最后一篇文章只能运行在特定标签上过滤的测试.
运行验收测试是通过产品风格完成的:
productFlavors {
uats {
testInstrumentationRunner "com.paddy.cuespton.cuespton.test.Instrumentation"
}
full {
applicationId "com.paddy.app.cuespton"
versionName "1.0"
}
}
这使我能够使用任务运行测试:
./gradlew connectedAndroidTestUatsDebug
是否可以将param with tag添加到此任务以仅运行特定测试?
我试着用
理论上应该解决这个问题的https://github.com/samueltbrown/gradle-cucumber-plugin/插件,但由于语言不兼容,我无法使用Android运行它.
这是我工作的回购,
https://github.com/paddyzab/espresso-cucumber-sandbox.
感谢帮助!
解决方法:
没有尝试这个黄瓜插件,但假设我们有类似的设置,你可以做到以下(sample repo):
1)为uats风格定义相应的buildConfigField:
Uats {
testInstrumentationRunner "com.quandoo.gradletestpoc.test.Instrumentation"
// passing instrumentation parameters
buildConfigField "String", "TAGS", "\"${getTagsproperty()}\""
}
2)定义getTagsproperty()方法:
def getTagsproperty() {
return project.hasProperty("tags") ? project.getProperties().get("tags") : ""
}
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();
}
4)跑
./gradlew connectedAndroidTestUatsDebug -Ptags="@bar"
请享用!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。