Android 8.0 的系统CTS 测试报告动辄就是60-70M,浏览器打开太慢了,不利于工程师查看报告。所以简单写了一个python 脚本只提取所有错误的报告信息。主要使用ptyhon 的xpath 技术实现。

#!/usr/bin/python# -*- coding: UTF-8 -*-# owner zhouyong0701 2018/01/16from lxml import etreedef sperate():    tree = etree.parse("./test_result.xml")    # moudules= tree.xpath('/Result/Module')    # for moudule in moudules:    #     print moudule.xpath('./@*')[0]    result_file = open("./test_result.xml")    fail_file = open('test_result_fail_report.xml', 'w')    line = result_file.readline()    while line:        if " 0 :            print "parser moudule -> " + moudule.xpath('./@name')[0] + " fail -> " + str(len(fail_tests))            #print etree.tostring(moudule)            total += 1            fail += len(fail_tests)            testcases = moudule.xpath('./TestCase')            #foreach TestCase remove the all pass TestCase from moudule            for testcase in testcases:                fail_count = testcase.xpath('.//Test[@result="fail"]')                if len(fail_count) == 0 :                    moudule.remove(testcase)                pass_count = testcase.xpath('.//Test[@result="pass"]')                if len(pass_count) > 0 :                    tests = testcase.xpath('./Test')                    #foreach test remove the pass test in TestCase                    for test in tests :                        if test.xpath('./@result')[0] == 'pass' :                            print "remove test -> " + test.xpath('./@name')[0] + " = " + test.xpath('./@result')[0]                            testcase.remove(test)            fail_file.write(etree.tostring(moudule))    print "total moudules: " + str(total) + " fail : " + str(fail)    fail_file.write("\n");    fail_file.close()def main():    sperate();if __name__ == '__main__':    main();

更多相关文章

  1. [置顶] Android(安卓)L中的RecyclerView 、CardView 、Palette的
  2. 请教Android内置应用Browser编译成APK的问题
  3. 20145328 《Java程序设计》实验四实验报告
  4. react-native 键盘遮挡输入框
  5. [android]android自动化测试十一之代码覆盖率报告EMMA
  6. QQ android 登录模块简单分析
  7. eclipse 导入Android项目时报告 Invalid Project Description
  8. 基于Android的记事本的设计与开发(实验报告+源代码)
  9. Android应用程序提交Crash报告

随机推荐

  1. Android 如何屏蔽Home键
  2. 移植soundtouch到android 通过JNI来调用
  3. Android AsyncTask 异步任务操作
  4. Android Bundle类
  5. Android视频播放: VideoView播放视频(三)
  6. Android权限大全
  7. Android studio maven pom.xml
  8. android 获取mac地址
  9. Android单元测试时如何使用log查看输出结
  10. Android(安卓)开发(六)C2DM 云端推送