Jenkins Publish TestNG Results not working

会有一股神秘感。 提交于 2019-12-11 09:35:36

问题


I am running Jenkins 1.571. I am building my project with a pom.xml. I have two executions of maven-surefire-plugin to execute two testng suites in a forked mode.

But Jenkins build#/testReport page shows test results for only first suite. Build logs show test cases from both suites are successfully executed.

I want to include results from both suites into report, so I added Publish TestNG Results plug-in, but that doesn't show any results at all. Any idea on what I might be missing?

In my Jenkins configuration, I specified 'TestNG XML report pattern' = '**/target/surefire-reports/testng-results.xml'

Build log shows:

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

My relevant 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>

回答1:


Eventually I found out that I need to use forward slash for TestNG plugin to locate the file (My Jenkins runs on 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

Also this reference helped: http://www.seleniumtests.com/p/testing-forum.html#nabble-td5001883




回答2:


1.Select "Editable Email Notification" on Post-Build actions.

2.In the Default Content section : remove $DEFAULT_CONTENT.Place the following code to inject your html report into the default content :-

${FILE,path=”relative path to html file”}

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

More detailed steps given below in my tech blog:-

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

Also let me know if you have any other reporting related questions using Jenkins. Will try to help out. :)

Regards, VJ



来源:https://stackoverflow.com/questions/26116894/jenkins-publish-testng-results-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!