Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About Jenkins JUnit XML Format

Tags:

junit

xml

jenkins

I'm working on a script that generates test results in JUnit XML format that Jenkins accepts.

I read through some answers in StackOverFlow about this topic: JUnit XML format specification that Hudson supports and Spec. for JUnit XML Output but none of these talks about the detail of the "testsuites" attributes or options.

I want to show the total number of "testcase", total number of failed "testcase" and total number of skipped "testcase" from all the "testsuite" under the "testsuites".

ie <testsuites *something to add here to include the info demanded*>...</testsuites>

Is there a way to achieve that?

Any help will be greatly appreciated!

like image 447
GJ. Avatar asked Jul 17 '12 21:07

GJ.


People also ask

What is JUnit XML format?

JUnit xml is a framework that was used in many applications in the test frameworks. By default, the test will generate xml files which are simple reports used for the execution of the test. These files are used to generate the report which was custom, we can also generate the reports as per the requirement of testing.

What does JUnit do in Jenkins?

The JUnit plugin provides a publisher that consumes XML test reports generated during the builds and provides some graphical visualization of the historical test results (see JUnit graph for a sample) as well as a web UI for viewing test reports, tracking failures, and so on.

How do I run a JUnit test from XML?

Create JUnit Test Case Class Create a java class, which is a JUnit test class, TestJunit. java in /work/testng/src. To execute the JUnit test cases, define the property junit="true" as in the xml above. The JUnit test case class TestJunit is defined in class name.


1 Answers

I think that information will be automatically computed by Jenkins. If not - don't bother adding it, it won't be displayed anyway.

Here's a useful tip on how to debug this sort of thing: create a job (let's name it jUnitReport) that "touches" a file (let's call it jUnit.xml) in a shell/batch build step; add 'Publish JUnit test resul report' and specify jUnit.xml in 'Test report XMLs' edit box. Run the job once - that will create its workspace. Now place valid jUnit.xml that you want to test in the workspace. Run the job again and examine how test results look.

It is important not to remove the 'touch' step - otherwise Jenkins will think of the test results as stale and fail the build.

You can now play with jUnit.xml without running actual tests and examine how it affects results Jenkins displays.

like image 167
malenkiy_scot Avatar answered Sep 29 '22 16:09

malenkiy_scot