Appium入门自动化测试(十四)
从你的全世界路过
我希望有一个如你一般的人,如山间清爽的风,如古城温暖的阳光,只要最后是你就好。今天,你路过了谁,谁又丢失了你呢? ----《从你的全世界路过》。
各位小伙伴们,好久不见,不知道你是否看过这场电影,遇到了谁,又路过了谁?
闲话少说,今天继续我们的教程。今天主要了解一下怎么生成漂亮的测试报告。
testng默认测试报告
在eclipse里面配置testng.xml 作为test suite
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<!-- parallel="classes" thread-count="5" -->
<suite name="Suite" parallel="classes" thread-count="5">
<test verbose="2" preserve-order="true" name="TestDebug" >
<parameter name="driverName" value="chrome" />
<classes>
<class name="main.java.com.dbyl.appiumCore.tests.iOSTest" />
<class name="main.java.com.dbyl.appiumCore.tests.iOSBrowser" />
<class name="main.java.com.dbyl.appiumCore.tests.AppDemo" />
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
testng.xml测试报告如下:
使用reprotng
ReportNG is a simple HTML reporting plug-in for the TestNG unit-testing framework. It is intended as a replacement for the default TestNG HTML report. The default report is comprehensive but is not so easy to understand at-a-glance. ReportNG provides a simple, colour-coded view of the test results.
reportng 是一个简单的testng 的生成html格式报告插件,是为了取代testng 默认的 html report.tesng默认的report不容易理解,也不太美观。reportng提高简单的,多彩的测试结果的视图.
使用reportng 之后生成html格式的测试报告,不但能显示出test suite 的cases状态,还能够获取到更详细的测试结果。
如何使用Reportng
-
引入相关的jar包
-
禁用testng default listeners
-
在define listener中添加:org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter
总结
使用reportng的时候,很多人会遇到中文乱码,我也遇到过。所以就从github clone一份源码,按照网上的方法修改了,能够处理中文字符。
下载地址:https://github.com/tobecrazy/appiumDemo/blob/master/libs/reportng-1.1.5.jar
并且可以修改reportng 自定义测试报告。
如果使用ant ,需要这样配置:
<testng classpathref="runpath" outputDir="test-output"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter,org.testng.reporters.FailedReporter" >
<xmlfileset dir="${basedir}" includes="Parametertestng.xml"/>
<jvmarg value="-Dfile.encoding=UTF-8" />
<sysproperty key="org.uncommons.reportng.title" value="AutoMation TestReport" />
</testng>
最后感谢每一个认真阅读我文章的人,看着粉丝一路的上涨和关注,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走
这些资料,对于做【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴我走过了最艰难的路程,希望也能帮助到你!凡事要趁早,特别是技术行业,一定要提升技术功底。希望对大家有所帮助…….
如果你不想再体验一次自学时找不到资料,没人解答问题,坚持几天便放弃的感受的话,可以加入下方我的qq群大家一起讨论交流,里面也有各种软件测试资料和技术交流。