jenkins HTML Report中文乱码(读取csv文件)

1.CSV文件设置为UTF-8;

2.重写build.xml文件。

<?xml version="1.0" encoding="UTF-8"?>
<!-- <?xml version="1.0" encoding="GBK"?> -->


<project basedir="." default="testoutput" name="automation test"> <!--默认使用testoutput任务-->
    <property name="base.dir" value="D:\workspace\MySeleniumScript"/><!--项目根目录-->


<property name="testng.output.dir" value="${base.dir}/result"/><!--配置结果输出地址-->


<property name="lib.dir" value="${base.dir}/lib"/><!--设置其他jar包目录-->


<property name="testng.file" value="${base.dir}/testng.xml"/> <!--调用的testng用例执行xml文件,这里是文件名-->
 <property name="testdir" location="test" /> <!--设置编译的2进制文件目录-->


 <taskdef resource="testngtasks" classpath="${lib.dir}/testng.jar"/><!--导入testng的jar包-->


<target name="clean"> <!--清除之前的2进制文件-->


<delete dir="${testdir}"/>
<delete file="D:/Myjenkins/workspace/Interface/test-output/TestReport.zip"/>  


</target>


<target name="compile" depends="clean">


<mkdir dir="${testdir}"/><!--新建2进制文件存放目录-->
<mkdir dir="result"/> <!--新建结果导出目录-->


<javac srcdir="${base.dir}/src" encoding="UTF-8" destdir="${testdir}" classpathref="classes"


includeantruntime="off" debug="on" debuglevel="lines,vars,source"/> </target> <!--编译java程序-->


<path id="classes"> <!--设置jar包相关-->
<fileset dir="${lib.dir}" includes="*.jar"/>
<pathelement location="${testdir}"/>
<pathelement location="${base.dir}/src" />
</path>




<target name="runtest" depends="compile">
<!--运行testng文件-->
<!-- 在target里面新建一个testng标签,里面需要设置的属性有:outputdir – 测试结果输出目录;classpathref – 那些自动化测试代码的目标路径,通常就是编译完成以后的那个目标路径,例如xxx/bin;delegateCommandSystemProperties – 接受传递命令行参数作为系统变量,这个设置为true可以在调用Ant的时候通过 -Dfoo=value 把参数传递给TestNG;里面还有一个xmlfileset节点,这个节点就是指定testng.xml文件的目录以及具体文件。 -->
<testng outputdir="${base.dir}/test-output" 
    classpathref="classes"
     delegateCommandSystemProperties="true">
<sysproperty key="file.encoding" value="UTF-8" /><!--解决控制台中文乱码问题,关系到和用例输出结果进行对比-->
<xmlfileset dir="${base.dir}" includes="testng.xml"/> <!--在指定路径下,找文件名由testng.file--> 
</testng> <!--定义的testng.xml文件-->


</target>
    <tstamp>   
        <format property="CURTIME" pattern="yyyyMMdd_HHmmss" locale="us"/>   <!--设置当前时间-->
    </tstamp>   
<path id= "test.classpath" >
<fileset dir= "${lib.dir}" includes= "*.jar" />
</path>


<target name= "testoutput" depends="runtest" >


     <xslt in= "D:/workspace/MySeleniumScript/test-output/testng-results.xml" style= "D:/workspace/MySeleniumScript/test-output/testng-results.xsl"
         out= "D:/workspace/MySeleniumScript/test-output/TestReport/index.html" >
        <!-- you need to specify the directory here again -->
         <param name= "testNgXslt.outputDir" expression= "D:/Myjenkins/workspace/Interface/test-output/TestReport" />
         <classpath refid= "test.classpath" />
     </xslt>
   <zip destfile="D:/workspace/MySeleniumScript/test-output/html.zip" basedir="D:/workspace/MySeleniumScript/test-output/html"/>


</target>


</project>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值