【问题标题】:Jenkins Publish TestNG Results not workingJenkins 发布 TestNG 结果不起作用
【发布时间】:2014-09-30 09:09:14
【问题描述】:

我正在运行 Jenkins 1.571。我正在使用pom.xml 构建我的项目。我有两次执行 maven-surefire-plugin 以分叉模式执行两个 testng 套件。

但 Jenkins build#/testReport 页面仅显示第一个套件的测试结果。构建日志显示两个套件的测试用例均已成功执行。

我想将两个套件的结果都包含在报告中,所以我添加了Publish TestNG Results 插件,但这根本没有显示任何结果。知道我可能缺少什么吗?

在我的 Jenkins 配置中,我指定了 'TestNG XML report pattern' = '**/target/surefire-reports/testng-results.xml'

构建日志显示:

TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/target/surefire-reports/testng-results.xml
Did not find any matching files.
Finished: SUCCESS

我的相关pom.xml:

<!-- run unit test cases -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12.4</version>
    <configuration>
        <environmentVariables>
            <outputDirectory>${project.build.directory}</outputDirectory>
        </environmentVariables>
    </configuration>
    <executions>
        <execution>
            <id>default-test</id>
            <configuration>
                <forkMode>once</forkMode>
                <suiteXmlFiles>
                    <suiteXmlFile>${basedir}/src/test/testngSuite1.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </execution>
        <execution>
            <id>special-test</id>
            <phase>test</phase>
            <goals>
                <goal>test</goal>
            </goals>
            <configuration>
                <forkMode>always</forkMode>
                <suiteXmlFiles>
                    <suiteXmlFile>${basedir}/src/test/testngSuite2.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </execution>
    </executions>
</plugin>

【问题讨论】:

    标签: jenkins testng maven-surefire-plugin


    【解决方案1】:

    最终我发现我需要为 TestNG 插件使用正斜杠来定位文件(我的 Jenkins 在 Windows 上运行)。

    TestNG Reports Processing: START
    Looking for TestNG results report in workspace using pattern: C:/workspace/project/target/surefire-reports/Suite1/UnitTests.xml;C:/workspace/project/target/surefire-reports/Suite2/UnitTests.xml
    Saving reports...
    Processing 'C:\programs\Jenkins\jobs\project\builds\2014-10-02_21-57-48\testng\testng-results-1.xml'
    Processing 'C:\programs\Jenkins\jobs\project\builds\2014-10-02_21-57-48\testng\testng-results.xml'
    TestNG Reports Processing: FINISH
    Finished: SUCCESS
    

    此参考也有帮助: http://www.seleniumtests.com/p/testing-forum.html#nabble-td5001883

    【讨论】:

    • 您真的使用正斜杠解决了这个问题吗?我的 jenkins 在 centos 上运行,现在我遇到了同样的问题。
    【解决方案2】:

    1.在构建后操作中选择“可编辑电子邮件通知”。

    2.在默认内容部分:删除 $DEFAULT_CONTENT。放置以下代码以将您的 html 报告注入默认内容:-

    ${FILE,path=”html文件的相对路径”}

    例如:${FILE,path=”MyWorkspace/MyProj/test-output/emailable-report.html”}

    下面我的技术博客中给出了更详细的步骤:-

    https://itisatechiesworld.wordpress.com/2015/01/06/including-testng-reports-within-the-jenkins-email-notifications/

    如果您在使用 Jenkins 时还有其他与报告相关的问题,请告诉我。 会尽力帮忙的。 :)

    问候, 主播

    【讨论】:

    • 如果这是你的博客,你需要声明你的隶属关系,否则它被认为是垃圾邮件
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多