[Android]使用android-junit-report.jar导出单元测试报告

时间 : 14-09-16 栏目 : Android, 移动开发, 集成测试 作者 : meiw@z3a105.com 评论 : 0 点击 : 2,004 次

Android在使用脚本编译和测试时,使用默认的testrunner不会输出文件类型的单元测试报告,每次只能分析logcat的无法直观的看到单元测试结果和报告,这给编写自动化脚本带来了不少麻烦,虽然可以自己动手编写支持junit测试报告输出的TestRunner,但是比较麻烦。除此之外,有一个android-junit-report.jar的开源包可以拿来使用,使用方法也很简单,输出的单元测试报告也可以为多种报告分析工具分析。具体使用方法如下:

这里假设Android APP的包名为com.xxx.xxx

方法1:使用Eclipse IDE方式

1.下载android-junit-report.jar并将其导入到Android测试项目的libs中

2.打开Android测试项目的AndroidManifest.xml文件,找到

<instrumentation 
      android:name="android.test.InstrumentationTestRunner"
      android:targetPackage="com.xxx.xxx" />

修改为

<instrumentation 
      android:name="com.zutubi.android.junitreport.JUnitReportTestRunner" 
      android:targetPackage="com.xxx.xxx" />

3.运行Junit测试 4.使用ADB方式获取单元测试报告

adb pull /data/data/com.xxx.xxx/files/junit-report.xml

方法2:使用ant方式

1.下载android-junit-report.jar并将其导入到Android测试项目的libs中

2.编辑ant.properties文件,增加以下内容

test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner

3.运行单元测试

ant clean debug install test

4.使用ADB方式获取单元测试报告

adb pull /data/data/com.xxx.xxx/files/junit-report.xml

方法3:使用Ant Build方式

1.下载android-junit-report.jar并将其导入到Android测试项目的libs中

2.编辑ant.properties文件,增加以下内容

test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner

3.在Build.xml中增加以下target内容

<target name="fetch-test-report">
  <xpath input="${tested.project.dir}/AndroidManifest.xml"
  expression="/manifest/@package" output="tested.package"/>
  <echo>Downloading XML test report...</echo>
  <mkdir dir="${reports.dir}"/>
  <exec executable="${adb}" failonerror="true">
  <arg line="${adb.device.arg}"/>
    <arg value="pull" />
    <arg value="/data/data/${tested.package}/files/junit-report.xml"/>
    <arg value="${reports.dir}/junit-report.xml"/>
  </exec>
</target>

4.运行单元测试

ant clean debug install test fetch-test-report

参考:

http://zutubi.com/source/projects/android-junit-report/documentation/

http://www.dotblogs.com.tw/yuanchien/archive/2010/11/24/add-emma-for-unit-testing.aspx

本文标签 , ,

除非注明,文章均为( meiw@z3a105.com )原创,转载请保留链接: http://blog.z3a105.com/?p=137

[Android]使用android-junit-report.jar导出单元测试报告:等您坐沙发呢!

发表评论





       ==QQ:122320466==

 微信    QQ群

推广

  • 104726drf320ff09r7i62f.jpg
  • 103217vn3333zbk3snwz2u.jpg

0

Aujourd’hui, une partie avec le développement du e-commerce, achats en ligne est devenu une partie de la vie pour beaucoup de gens. La mariage a commencé achats en ligne. Si vous choisissez achats les mariages en ligne, il peut être beaucoup moins cher que le salon de la Robe de mariée pas chermariée local, réduisant le budget de mariage. vous pouvez avoir beaucoup de choix si acheter de mariage en ligne. vous pouvez ramasser une robe de mariée bon marché sur Internet.
Piercing fascinerande figur, och nu tittar vi på 2016 senast brudklänning, kan du vara den vackraste bruden det!2016 senaste Bra brudklänning, söt temperament Bra design, romantiska spetsar blomma kjol, som du lägger till en elegant och charmig temperament.Kvinnan tillbaka mjuka linjer, människor brudklänningofta få en känsla av oändlig frestelse. Fall 2016 mässan, lämnar uppgifter om ditt bröllop charmig.
Yesterday afternoon, the Chinese team was training in the Guangzhou Gymnasium, when the reporter asked Zhao Yunlei the feeling of wearing the new cheap jersey , cheap jerseys online shopshe readily took a shirt from the bag crumpled ball to reporters, and she said with a smile: ” This shirt is light. ”Zhao Yunlei said: “Our material is very light like with the clothes of the tennis King Nadal, Federer, after the sweat, sweat does not drip down to the ground, when we do move, it is easy pace slipping if the sweat drip on the floor.”Tennis players Zhang Yawen, told reporters: “You might think the clothes attached to the body, fearing we swing will be affected, in fact, we do not feel anything, because the clothes are very light, very soft, put on quite comfortable. And it’s particularly good clothes to dry, washing and will dry in 15 minutes. ”
China’s sports enthusiasts NFL sweatshirt with mad love and the pursuit of, and therefore, NFL jerseys have a good market in China and development. China is a populous country, is the consumer, the economic momentum is so good, the sales prospects sportswear is immeasurable. With hot sales sweatshirt, but also to promote the importance of sports fans, on health, on the other hand is a matter of concern for the World Cup, fans wearing NFL jerseys and also can express themselves more fully love and obsession Therefore, NFL jerseys Wholesale jerseys online shopwholesale has good prospects and development in China.
ANTA-ANTA Sports Products Limited, referred to as ANTA Sports, Anta, is China’s leading sporting goods companies, mainly engaged in the design, development, manufacture and marketing of ANTA brand sporting goods, including sports footwear, apparel and accessories. Anta sweatshirt design advantages, warm stretch knit fabric, using Slim version of model, more personal fit, bid farewell to bloated, so wearing more stylish.GUIRENNIAO-This logo is a spiritual totem, smooth graphics implication unstoppable force; flexible deliver an elegant arc Wholesale jerseys china shop movement, strength and speed of the United States, a symbol of passion and rationality publicity “Heart” and “meaning”, “concept” unity; pass the fearless and enterprising mind, showing beyond the realm of self, to unstoppable force to create the future.XTEP-Xtep (China) Co., Ltd. is a comprehensive development wholesale jerseys china shop, production and marketing of Xtep brand (XTEP) sports shoes, clothing, bags, caps, balls, socks mainly large sporting goods industry enterprises.
There are a lot of fans in identifying the authenticity of the above cheap jerseys have great distress, so here to i will show you some methods to definitely affordable inexpensive cheap jerseys : Firstly, we should look at if it is working fine. China has been called the world’s factory, a lot cheap jerseys factories in China have foundries, but our cheap jerseys are all from here! Secondly, should to see whether it is the , we all know that it is difficult to get out of print once a genuine cheap cheap jerseys free shipping jersey was print. and we have all kind of stocka on the whole website, in other words, we have all you want ! Finally, look at the price, our price is not necessarily the lowest in the whole website but it must be most fair on the whole website, we certainly you will not regret later when you buy it. Of course, except that cheap jerseys, we also have the other products, such as socks, leggings and some other related products, everyone can enjoy the best services of here!