• 使用reportNG替换testNG的默认报告


    关于reportng的官网介绍:http://reportng.uncommons.org/

    1.下载reportNG的jar包:http://pan.baidu.com/s/1hq5znLU

    2.reprotNG的源码:https://github.com/dwdyer/reportng

    3.在项目中导入reportNG的jar包

    4.更改eclipse设置

    5.设置完成后,运行项目,在项目test-output/html/index.html即可查看report

    6.设置reportng的编码

    更改源文件的AbstractReporter.java,并替换相应jar包的class

        protected void generateFile(File file,
                                    String templateName,
                                    VelocityContext context) throws Exception
        {
            //Writer writer = new BufferedWriter(new FileWriter(file));
            //encoding to utf-8
            OutputStream out=new FileOutputStream(file);
            Writer writer=new BufferedWriter(new OutputStreamWriter(out,"utf-8"));
            try
            {
                Velocity.mergeTemplate(classpathPrefix + templateName,
                                       ENCODING,
                                       context,
                                       writer);
                writer.flush();
            }
            finally
            {
                writer.close();
            }
        }

    7.更改报告的方法排列顺序,按照方法的执行先后顺序来进行排序的

    更改TestResultComparator.java,并替换相应jar包的class

         public int compare(ITestResult result1, ITestResult result2)
         {
             //return result1.getName().compareTo(result2.getName());
             int longresult2 = 0;
             if(result1.getStartMillis()<result2.getStartMillis()) {
                 longresult2 = -1;
             }else {
                 longresult2 = 1;
             }
             return longresult2;
         }

     8.teng的xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <suite name="测试用例集" parallel="false">
    <listeners>
    <listener class-name="org.uncommons.reportng.HTMLReporter" />
    <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
    </listeners>
      <test verbose="8" name="TestNgrepotng">
        <classes>
          <class name="com.reprot.TestNgrepotng"/>
        </classes>
      </test> <!-- Test -->
        <test verbose="8" name="Test22">
        <classes>
          <class name="com.reprot.Test22"/>
        </classes>
      </test>
    </suite> <!-- Suite -->

     9.更改报告输出样式

    在reportng-1.1.4.jar的reportng.properties文件中增加

    oneclass.description=Description
    oneclass.duration=Duration
    oneclass.testdata=Data being used
    oneclass.testresult=Test result
    oneclass.screenshot=Screen shot
    oneclass.additionalinfo=Additional Info

    在reportng-1.1.4.jar的results.html.vm文件中更改

    <tr>
    <td colspan="1" class="group">$testClass.name</td>
    <td colspan="1" class="group">$messages.getString("oneclass.duration")</td>
    <td colspan="1" class="group">$messages.getString("oneclass.testresult")</td>
    </tr>

    10.效果图

  • 相关阅读:
    首次搭建微信小程序记录各种细节
    vue3.x 首次搭建
    通过nodejs 下载阿里云省、市、区的json文件,使用在echart上
    vscode
    使用 ts + and design + react-redux + react-router-dom + ahook 开发 管理后台
    Python 字典(dict) 操作基础
    高斯混合模型视频背景建模的EM算法与Matlab 实现
    Tensorflow 10分钟快速上手
    Ubuntu16.04LTS 搜狗输入法无法输入中文
    Machine Learning Class 1:Introduction,supervised & unsupervised learning
  • 原文地址:https://www.cnblogs.com/qiaoyeye/p/4729737.html
Copyright © 2020-2023  润新知