Visualization of JUnit Test Results

2,412 views
Skip to first unread message

Christian Kolb

unread,
Nov 1, 2017, 2:18:09 PM11/1/17
to go-cd
Hello dear community!

is there any way (probably through a Plugin) to visualize results of Java Unit tests and showing the code coverage in GoCD?
For Jenkins for example there are some plugins which show you the results in nice graphs for each run/build and the overall results from the past runs.
This one for example: https://wiki.jenkins.io/display/JENKINS/JUnit+Plugin

Does anything comparable exist for GoCD? If not, any third-party tool that can help me out?

Thanks in advance! :-)

Jeff

unread,
Nov 1, 2017, 3:25:04 PM11/1/17
to GoCD User Mailing List
Not sure if this is what you are looking for, but I use TestNG (similar to JUnit) with Java.  It generates an HTML representation of the test report that I publish as a Test artifact.  I then publish it as a tab in the job.  Here is a partial screen grab:

Inline image 1

There may be a better way, but this is what I'm doing.

-Jeff 


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Kolb

unread,
Nov 1, 2017, 4:23:48 PM11/1/17
to go-cd
Wow! That looks pretty great!
What do I have to do in order to get such a TestNG Test Report?
I think creating a test artifact is also needed for that?

Which version of GoCD is needed for that? I use version 16.12.0 currently.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.

Jeff

unread,
Nov 1, 2017, 5:46:57 PM11/1/17
to GoCD User Mailing List
I'm using 17.11.0, but I believe the test artifact publishing and custom tabs features have been around long before v16.x.x.  I believe we used it at a previous job in v10.x.x.

Creating the test artifact is simply telling GoCD which file or directory structure is the location of that test artifact(s).  It could be just a single XML file or an entire directory structure.  My test artifact is the entire Maven surefire-reports folder:

Inline image 1

When I define my custom tab, I simply point it to the resulting index.html file from the test artifact destination:

Inline image 3

Assuming you are already using JUnit today, I'd first look at ways to either have JUnit produce HTML directly or see if there is a utility that will convert the JUnit XML output to an HTML format. Or you can publish the XML directly (it won't look as nice).   How that happens will be determined if you use Ant, Maven, Gradle or some other project structure.  I believe ANT and Maven surefire have built-in mechanisms to generate HTML from the JUnit results, including TestNG.

Regardless, TestNG is just like JUnit in that you included the TestNG dependency and annotate your test classes and methods accordingly with @Test, etc.  

Hopefully that was clear.

-Jeff

To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscribe@googlegroups.com.

Christian Kolb

unread,
Nov 1, 2017, 7:58:22 PM11/1/17
to go-cd
Thank you very much for your explanation - however I need your help once more.

With your help, I finally was able to list the test artifacts but nothing shows up in my custom tab.
What is odd though is that when I want to show the index.html of the unit test report in a separate tab,
it does not show up there although I have used the same path ( + the file name of course).
I then tried to link the tab to an XML which is also created during the build, I got the same result.
Then I tried to link tabs to the directories of both files only without explicitly listing the .html or .xml file but the same message appeared:

Can you help me out?
You might be interested in the config of my pieline, you find it attached to this reply along with some screenshots.

GoCD says:
Artifact '**/build/reports/tests/index.html' is unavailable as it may have been purged by Go or deleted externally.
01_Test_Artifacts.PNG
02_Custom_tabs.PNG
03_Resource_unavailable.PNG
TestResult_Pipeline_Config.xml

Björn Andersson

unread,
Nov 1, 2017, 8:49:24 PM11/1/17
to go...@googlegroups.com
I think it'll work if you try the custom tab path without the stars, e.g. build/reports/tests/index.html. 
The stars are for using wildcards to find the directories, but I believe you need the absolute path when showing the result in a tab.

Cheers,
Björn

Christian Kolb

unread,
Nov 1, 2017, 9:40:10 PM11/1/17
to go-cd
Oh my holy cow, thank you very much! Removing the wildcards brought the desired result!
Reply all
Reply to author
Forward
0 new messages