Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying custom test results in Jenkins Maven job

I just added some Python unit tests to an existing Maven POM but I can't seem to get Jenkins to report the results of the tests when it runs the build.

I'm running nose tests from Maven with the exec-maven-plugin during the "test" phase. The tests run successfully from the Jenkins job and generate an xUnit compatible test report to target/surefire-reports/TEST-nosetests.xml, but Jenkins doesn't pick up on the results.

Interestingly, Maven also reports no tests run before executing the test suite:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- exec-maven-plugin:1.1.1:exec (nosetests) @ server ---
[INFO] ................
[INFO] ----------------------------------------------------------------------
[INFO] Ran 16 tests in 194.799s
[INFO] 
[INFO] OK
[INFO] Registering compile source root /Volumes/Data/workspace/myProject/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

So is this a problem with Jenkins not seeing the results, or with Maven not treating my test suite as actual tests?

like image 650
bpanulla Avatar asked Nov 19 '12 18:11

bpanulla


People also ask

How do I view test reports in Jenkins?

You get to the Test Result page by clicking a build link on the Status or History page of your Jenkins project, or by clicking Test Result in the menu on the left. Click the image to enlarge it. At the top of the page, Jenkins displays summary information about the executed tests and their total execution time.

How do you publish results in Jenkins?

Alternative Method To Generate TestNG Reports in Jenkins Login into Jenkins. Manage Jenkins and Install TestNG Result Plugin. Please make sure that you restart Jenkins after the plugin installation. Next, go to Jenkins Home Page → Create New Jenkins Job and in Post-Build Action select → Publish TestNg Result.

Does Jenkins provide test report?

Jenkins understands the JUnit test report XML format (which is also used by TestNG). When this option is configured, Jenkins can provide useful information about test results, such as trends. The plugin also provides a generic API for other unit-test publisher plugins in Jenkins.


2 Answers

To build upon the answer by bpanulla, if you have tests in more than one sub-directory of your project, you can use a wildcard in the "Test report XMLs" field, such as: **/target/surefire-reports/*.xml

like image 176
Jim Somerville Avatar answered Sep 29 '22 17:09

Jim Somerville


Try after adding the maven compiler plugin

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <executions>
                <execution>
                    <id>default-testCompile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <encoding>ISO-8859-1</encoding>
                <source>1.8</source>
                <target>1.8</target>
                <useIncrementalCompilation>false</useIncrementalCompilation>
                <testSource>1.8</testSource>
                <testTarget>1.8</testTarget>
            </configuration>
        </plugin>
like image 29
rajeev Avatar answered Sep 29 '22 18:09

rajeev