【问题标题】:Generate testng reports without overwriting the previous test output result?生成 testng 报告而不覆盖之前的测试输出结果?
【发布时间】:2016-06-23 09:02:39
【问题描述】:

我正在使用 java 的 selenium-webdriver。我正在使用 testNG,执行后我得到默认报告。但是一旦我重新运行该套件,以前的结果就会被覆盖。

我们可以在不覆盖之前的测试输出结果的情况下生成测试报告吗?

我们需要任何构建工具吗?如果是的话如何用maven做?

【问题讨论】:

    标签: maven report testng


    【解决方案1】:

    是的,您可以在不覆盖以前的情况下生成报告。

    要实现它,您需要参数化报告输出目录。

    我不知道,如何用纯 TestNG 来做,但是用 maven-surefire-plugin 很简单:

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>testng-suite.xml</suiteXmlFile>
                </suiteXmlFiles>
                <reportsDirectory>report_${maven.build.timestamp}</reportsDirectory>
            </configuration>
        </plugin>
    </plugins>
    

    这将为每次运行创建单独的目录,使用当前时间戳作为唯一后缀。

    【讨论】:

      【解决方案2】:

      如果您有存储报告的目录的路径,并且想要保留过去的报告以供将来参考,您可以为报告的名称加上时间戳

         Calendar cal = Calendar.getInstance();   
         Date time=cal.getTime();
         String timestamp=time.toString();
         String systime=timestamp.replace(":", "-");
         int year = cal.get(Calendar.YEAR);
         int month = (cal.get(Calendar.MONTH)+1);
         int day = cal.get(Calendar.DAY_OF_MONTH);
      
      
      
         public void generateReport  (List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
          extent = new ExtentReports("C:\\XAMPP\\htdocs\\TestReports\\TestReport" + " " + systime + "_" + Constants.U360_VERSION +".html");
      

      【讨论】:

        猜你喜欢
        • 2019-01-27
        • 2018-05-19
        • 1970-01-01
        • 2019-02-11
        • 1970-01-01
        • 2019-08-07
        • 1970-01-01
        • 1970-01-01
        • 2017-09-03
        相关资源
        最近更新 更多