Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simplest plugin to parse and display test results in Jenkins

I've started using Jenkins in order to compile and test my builds periodically. The job is fairly simple. It compiles the build and then executes the tests.

The test results are stored in a file. There's also a distinct line saying how many tests have passed. (Something like X tests passed out of Y).

I'd like to know what's the simplest way/plug-in to display these results at the end of the build.

I'd like a visual display, since I know Jenkins is very nice in displaying graphs over time/job.

I appreciate your help, and forgive me if this question already exists on Stackoverflow. I haven't found anything close enough for me.

like image 659
fashasha Avatar asked Feb 07 '13 14:02

fashasha


2 Answers

You can install the Groovy Postbuild Plugin and use it to parse your distinct line and display it right next to your build result :

def matcher = manager.getLogMatcher("(.*)  tests passed out of (.*)\$")
if(matcher != null && matcher.matches()) {
    passedTests = matcher.group(1)
    totalTests = matcher.group(2)
    manager.addShortText("${passedTests} / ${totalTests}")
}

You could also enhance it with a badge or a customized color depending of the success ratio.

Hope it helps

like image 41
Y__ Avatar answered Nov 15 '22 07:11

Y__


Wouldn't it be better if you can publish your test results in a format that is more understandable by Jenkins? If so, see this link on how to generate a simple test result. Once you have done that, the visual display that Jenkins offers comes to you at free of cost.

like image 188
Shiva Kumar Avatar answered Nov 15 '22 06:11

Shiva Kumar