ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android-maven-plugin,instrumentation testing和testSize

2019-06-30 04:14:19  阅读:293  来源: 互联网

标签:android maven integration-testing instrumentation android-maven-plugin


我正在使用maven来构建,运行和检测我的Android应用程序. Android测试框架有三个不同的测试范围@SmallTest,@MediumTest@LargeTest,android-maven-plugin有能力通过testTestSizetest/testSize参数选择测试范围.该参数可以是小型中的一个,可以从相关范围运行您的测试.

但是,如果我想同时进行中小型测试,不仅是小型还是非中型测试,我该怎么办?有这个问题的解决方案吗?

解决方法:

根据InstrumentationTestRunner API doc,这就是Android SDK的设计和应该如何工作的方式:

Running all small tests: adb shell am instrument -w -e size small com.android.foo/android.test.InstrumentationTestRunner

Running all medium tests: adb shell am instrument -w -e size medium com.android.foo/android.test.InstrumentationTestRunner

Running all large tests: adb shell am instrument -w -e size large com.android.foo/android.test.InstrumentationTestRunner

即使您使用plain adb命令来运行测试,也必须使用两个进程分别运行中小型测试,一个接一个. Android Maven插件只是adb命令的另一个包装器,所以没有办法通过android-maven-plugin配置AFAIK来改变默认行为.

如果你仔细阅读InstrumentationTestRunner API doc,你会注意到有一个有趣的命令用法:

Filter test run to tests with given annotation: adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

If used with other options, the resulting test run will contain the union of the two options. e.g. “-e size large -e annotation com.android.foo.MyAnnotation” will run only tests with both the LargeTest and “com.android.foo.MyAnnotation” annotations.

注释配置作为实验API添加(标记为@hide,有关详细信息,请参阅this version history),并且未在am instrument options list中记录.理论上,您可以创建自己的注释类(请参阅SmallTest.java作为示例),标记所有@MediumTest与@CustomizedTest一起使用-e size和-e annotation来实现你想要的:同时从两个注释中运行union测试,所有这些都在一个命令中.

不幸的是,android-maven-plugin不支持注释配置,请参阅plugin documentationlatest source code.可能的解决方法是使用exec-maven-plugin运行plain adb shell am instrument命令.

希望这是有道理的.

标签:android,maven,integration-testing,instrumentation,android-maven-plugin
来源: https://codeday.me/bug/20190630/1332836.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有