android-junit-report-mail-python


下面使用android-junit-report工具实现android下junit框架测试自动生成报告,并发送邮件的功能

一、工具

 1.android-junit-report------android下用该工具生成测试报告
 2.(可选)android-junit-report-master----工具的源码和使用例子

二、使用
注:需要单独建一个测试工程,如果测试工程和项目工程是一个,ant debug install test 会报
       \build.xml:617: subant task calling a target that depends on its parent target '-build-setup'.错误
 1. * Edit AndroidManifest.xml to set android:name in the
    instrumentation tag to:
      com.zutubi.android.junitreport.JUnitReportTestRunner.
 2. cmd: android update test-project -p [测试工程路径] -m [项目工程路径]
     e.g.    android update project -p e:\workspace\dd -m E:\workspace\dd\TestCalTest
     生成android自动化的build.xml, ant.properties, local.properties    
 3.* Edit ant.properties to add the line:
      test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner
 4.编写 custom_rules.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="Test">
<property name="reports.dir" value="bin/reprots"/>
<target name="makedir">
<mkdir dir="${reports.dir}"/>
<echo>=====maked reports dir</echo>
</target>
<!-- 拿到项目工程的package名-->
<target name="init-props">
        <xpath input="${tested.project.dir}/AndroidManifest.xml"
               expression="/manifest/@package" output="tested.project.app.package"/>
    </target>
    
    <!-- 将测试报告从android目录下拿到pc上 -->
<target name="fetch-test-report" depends="init-props,makedir">
<echo>Downloading XML test report...</echo>
        <exec executable="${adb}" failonerror="true">
            <arg line="${adb.device.arg}"/>
            <arg value="pull"/>
            <arg value="/data/data/${tested.project.app.package}/files/junit-report.xml"/>
            <arg value="${reports.dir}/junit-report.xml" />
        </exec>
     </target>
     
     <target name="test-and-fetch" depends="debug,install,test,fetch-test-report,send-mail"/>
     
     <target name="send-mail">
    <mail mailhost="mail.foxitsoftware.com" mailport="25" subject="Test build">
    <from address="myself@xxx.com"/>
    <to address="someone@xxx.com"/>
    <message>test completed,see the file attachment </message>
    <attachments>
    <fileset dir="${reports.dir}">
    <include name="*.xml"/>
    </fileset>
    </attachments>
    </mail>
    </target>
    
    <!-- use execute python -->
    <target name="test">
    <exec executable="python" failonerror="true">
    <arg value="hello.py"/>
    </exec>
    </target>
</project>

最后只要到测试工程下运行 ant test-and-fetch

转载:http://blog.163.com/yujie_chen2011/blog/static/200379167201365104446774/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值