【问题标题】:ReportNG Report with TestNG is not generated using WebDriver使用 WebDriver 不生成带有 TestNG 的 ReportNG 报告
【发布时间】:2012-10-18 07:05:52
【问题描述】:

我在 Eclipse 中使用 Selenium WebDriver + TestNG 和 java。我想使用 ReportNG 而不是普通的 TestNG 报告生成更好的报告。我已经使用reportng-1.1.2.jar 和velocity-dep-1.4.jar 配置了构建路径。我还从 Project > Properties > TestNG > "Disable Default Listeners" 禁用了默认的 TestNG 报告 目前我已经创建了一个 testNg.xml 文件,它将我的测试作为完整的测试套件运行。 xml文件内容如下:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" preserve-order="true" name="testingXML" junit="false" parallel="false" annotations="JDK">
<test verbose="2" name="com.src.com.pcrm.pageobjects.*" junit="false" annotations="JDK">
<testng classpathref="test-path"
            outputdir="${test-results.dir}"
            haltonfailure="true"
            useDefaultListeners="false"
           listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter">
      <xmlfileset dir="." includes="testng.xml"/>
      <sysproperty key="org.uncommons.reportng.title" value="My Test Report"/>
    </testng>
<classes>
<class name="com.pcrm.pageobjects.HomeTest"/>
    <methods>   
        <include name="testManadatoryFieldsOnHomePage"/>
        <include name="testIsLogoDisplayed"/>
        <include name="testUrlCheck"/>
    </methods>

但是当我执行这个 xml 文件时,它并没有生成任何 ReportNG 报告。怎么了?感谢您的帮助。

【问题讨论】:

  • “它不生成任何报告”——仅这一行语句并没有涵盖很多内容。显示的错误是什么?

标签: eclipse webdriver automated-tests testng reportng


【解决方案1】:

我最好的猜测是这是一个类路径问题。确保 ReportNG 和 Velocity JAR 位于类路径中。请参阅related question,了解使用带有 Selenium 的 ReportNG 的类似问题。

【讨论】:

    【解决方案2】:

    你可以试试这个TestNG-XSLT 报告,它看起来更大更容易阅读。

    【讨论】:

      【解决方案3】:

      第 1 步:下载所需的 Jar 文件

      从这里:https://github.com/google/guice你可以下载下面的jar文件

      guice-3.0.jar

      从这里:http://reportng.uncommons.org/你可以下载下面的jar文件

      reportng-1.1.4.jar
      velocity-dep-1.4.jar
      

      第 2 步:在项目的构建路径中添加 Jar 文件

      第 3 步:禁用 testng 的默认侦听器

      您需要禁用 testng 的默认侦听器。 禁用默认侦听器 右键单击eclipse中的项目文件夹。 转到属性。 - 它将打开属性对话框。 转到TestNG并检查禁用默认侦听器--->应用--->确定

      第 4 步:在 TestNG.xml 中添加这些监听器

      <listeners>
              <listener class-name="org.uncommons.reportng.HTMLReporter"/>
              <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
      </listeners>
      

      第 5 步:执行测试并查看 ReportNG 报告(在 html 文件夹内 html-->index.html(不在 index.html 之外))

      刷新您的项目文件夹。它将创建/更新测试输出文件夹。探索该文件夹,然后探索 html 文件夹。您将在其中找到 index.html 文件。打开 index.html 文件。

      【讨论】:

      • 我遵循了相同的步骤。 ReportNG 工作但不创建output 文件夹。
      猜你喜欢
      • 1970-01-01
      • 2013-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多