TestNG+Ant 测试报告美化
来源:互联网 发布:迷恋网络的危害 编辑:程序博客网 时间:2024/05/21 14:49
TestNG本身的测试报告很不美观,我们可以下载testng-xslt,加入其中的jar包去进行美化。该效果比reportNG还要美观。
1.下载testng-xslt(如testng-xslt-1.1.2版本)
其中lib下的saxon-8.7.jar 是用来美化report的jar。
2.新建JAVA项目,在项目下新建一个lib文件夹,用来加入jar文件;新建testoutput文件夹,在其中加入testng-results.xsl (路径:testng-xslt-1.1.2-master\src\main\resources)用来承再生成美化的测试报告。
3.lib里面加入需要的jar文件, 并引用。
4.TestNGSimpleTest.java
import org.testng.annotations.Test;import static org.testng.Assert.assertEquals;public class TestNGSimpleTest {@Testpublic void testAdd() {String str = "TestNG is working fine";assertEquals("TestNG is working fine", str);}}
5.src下建testng.xml
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" ><suite name="Suite1"> <test name="test1"> <classes> <class name="TestNGSimpleTest"/> </classes> </test></suite>
6.可以通过File-export-Ant的方式,将项目转化为Ant项目,会自动生成build.xml,然后修改代码为:
<project name="TestNGTest" default="testoutput" basedir="."><!-- Define <testng> task --><taskdef name="testng" classname="org.testng.TestNGAntTask"><classpath><pathelement location="lib/testng-6.8.jar" /></classpath></taskdef><property name="testoutputdir" location="testoutput" /><property name="srcdir" location="src" /><property name="libdir" location="lib" /><property name="full-compile" value="true" /><property name="basedir" value="D:/workspace/TestNGSimple/" /><path id="classpath.test"><fileset dir="${libdir}"><include name="**/*.jar" /></fileset><pathelement location="${testoutputdir}" /><pathelement location="${srcdir}" /></path><target name="clean"><delete dir="${basedir}/bin" /></target><target name="compile" depends="clean"><mkdir dir="${basedir}/bin" /><javac srcdir="${srcdir}" encoding="UTF-8" destdir="${basedir}/bin" verbose="${full-compile}" classpathref="classpath.test" includeantruntime="off" debug="on" debuglevel="lines,vars,source" /></target><path id="classes"><fileset dir="${libdir}" includes="*jar"/><fileset dir="${libdir}" includes="*zip"/><pathelement location="${basedir}/bin/"/></path><target name="runtest" depends="compile"><testng outputdir="${testoutputdir}" classpathref="classes" delegateCommandSystemProperties="true"><xmlfileset dir="${srcdir}" includes="testng.xml" /></testng></target><target name="testoutput" depends="runtest"><xslt in="${testoutputdir}/testng-results.xml" style="${testoutputdir}/testng-results.xsl" out="${testoutputdir}/index.html "><param name="testNgXslt.outputDir" expression="D:/workspace/TestNGSimple/testoutput/" /><classpath refid="classpath.test" /></xslt></target></project>
7. 右键 build.xml 文件,Run as -- Ant build
8. testoutput中 生成测试美化后的报告
注意:
1.
<project name="TestNGTest" default="testoutput" basedir=".">default=“testoutput”,如果不需要美化的报告,则改为runtest
2.注意classes 的配置,然后引入到runtest的配置中,否则报找不到class的异常。
<path id="classes"><fileset dir="${libdir}" includes="*jar"/><fileset dir="${libdir}" includes="*zip"/><pathelement location="${basedir}/bin/"/></path>
<target name="runtest" depends="compile"> <testng outputdir="${testoutputdir}" classpathref="classes" delegateCommandSystemProperties="true"> <xmlfileset dir="${srcdir}" includes="testng.xml" /> </testng> </target>
3.testng-results.xml在路径(testng-xslt-1.1.2-master\test\single)下
<target name="testoutput" depends="runtest"><xslt in="${testoutputdir}/testng-results.xml" style="${testoutputdir}/testng-results.xsl" out="${testoutputdir}/index.html "><param name="testNgXslt.outputDir" expression="D:/workspace/TestNGSimple/testoutput/" /><classpath refid="classpath.test" /></xslt></target>
1 0
- TestNG+Ant 测试报告美化
- TestNG+Ant 测试报告美化
- 使用TestNG-xslt+ant来美化selenium测试报告
- TestNg测试报告美化
- TestNG测试报告美化
- testNG测试报告美化
- TestNG测试报告美化
- 使用TestNG-xslt美化测试报告
- 使用TestNG-xslt美化测试报告
- TestNG入门笔记[6]:TestNG-xslt 美化测试报告
- ant+TestNG-xslt生成selenium测试报告
- ant构建testNG测试输出测试报告
- ant+testng-xslt生成selenium测试报告
- 使用ant运行testng使用testng-results.xsl美化结果
- 使用ant运行testng的testng.xml并且使用testng-results.xsl美化结果
- 使用ant运行testng的testng.xml并且使用testng-results.xsl美化结果
- 测试报告生成 TestNG-xslt
- testNG之测试报告
- 批处理文件更新当前SVN目录下的所有文件
- ArcGIS教程:Workflow Manager的基本词汇
- 免费网站建设真的免费吗
- HDU 4339 (线段树字符标记)
- Xcode5 关联 git 使用bitbucket托管 搭建多人协作开发
- TestNG+Ant 测试报告美化
- 截:截图、截屏 20140904 ⑨图像处理
- httpclient将android数据post到数据库
- 在Linux虚拟机下安装Mysql,并远程访问
- const_iterator的使用,STL算法----copy(),输出迭代器---ostream_iterator()
- 对ADC(DAC)的线性度(INL和DNL)的一点理解
- 苹果公司推出的ios 6测试版的iPhone和iPad
- 测试一下
- XPath 详解,总结---写的不错