Jenkins发布TestNG结果不起作用

时间:2014-09-30 09:09:15

标签: jenkins testng maven-surefire-plugin

我正在运行 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>

2 个答案:

答案 0 :(得分:2)

最终我发现我需要使用TestNG插件的正斜杠来定位文件(My 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

答案 1 :(得分:0)

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

2.在默认内容部分:删除$ DEFAULT_CONTENT.Place以下代码将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有任何其他报告相关问题,也请告诉我。 会尽力帮忙。 :)

此致 VJ