
使用gradle java插件,我可以做类似的事情
task testFast(type: Test) { useJUnit { includeCategorIEs 'foo.Fast' excludeCategorIEs 'foo.Slow' }}task testSlow(type: Test) { useJUnit { includeCategorIEs 'foo.Slow' excludeCategorIEs 'foo.Fast' }} 但是,如果使用androID插件,我必须将testoptions添加到androID闭包中以包含/排除,
androID {... testoptions { unitTests.all { useJUnit { excludeCategorIEs foo.Slow' } } }...} 但当然这适用于所有构建变体的所有测试任务.
有没有办法创建使用相同构建变体的任务,但是对不同类别执行测试?
解决方法 我想出的最好的方法是从命令行使用gradle属性:testoptions { unitTests.all { useJUnit { if (project.hasProperty('testcategory') && testcategory == "Slow") { includeCategorIEs 'foo.Slow' } else { excludeCategorIEs 'foo.Slow' } } }} 并使用
gradlew -Ptestcategory=Slow test总结
以上是内存溢出为你收集整理的Android单元类别测试全部内容,希望文章能够帮你解决Android单元类别测试所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)