1.4 测试结果收集功能
每次运行一个用例结束的时候,会把当前用例的运行结果加入到xml的节点中,所有用例运行结束后,xml文件会保存在PC端的指定位置下。
收集到的测试结果样式如下:
<?xml version="1.0" encoding="UTF-8"?> <testsuites> <testsuite name="com.netease.mobile.autotest.testing.LoginTest"> <testcase classname="com.netease.mobile.autotest.testing.LoginTest" name="testUnLogin" time="59.499"/> </testsuite> <testsuite name="com.netease.mobile.autotest.testing.SubscribeTest"> <testcase classname="com.netease.mobile.autotest.testing.SubscribeTest" name="testAdd2" time="74.099"> <failure message="junit.framework.AssertionFailedError: Button with the text: 取消订阅 is not found!" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Button with the text: 取消订阅 is not found! at com.jayway.android.robotium.solo.Clicker.clickOn(Clicker.java:324) at com.jayway.android.robotium.solo.Solo.clickOnButton(Solo.java:684) at com.netease.mobile.autotest.common.PrisOperation.addSubscribe(PrisOperation.java:91) at com.netease.mobile.autotest.testing.SubscribeTest.testAdd2(SubscribeTest.java:126)</failure> </testcase> </testsuite> </testsuites> |
1.5 测试报告生成功能
首先会获取到收集的测试结果xml文件,然后解析xml同时加入一些css样式,生成html文件,邮件中发送的正文内容就是html文件内容。
这里就是一个解析xml以及样式处理的过程。