xUnit with Jenkins: how to display colors in the B

2019-07-09 02:59发布

问题:

I successfully setup CasperJS test suite exporting to an xUnit XML file that way:

$ casperjs test googletesting.js --xunit=log.xml

I managed to automate these tests through Jenkins thanks to the xUnit Plugin.

I even managed to setup emails notifications when a build fails thanks to [Mail Watcher Plugin][3] which is great !

The only problem is the format of the output, it's a bit messy. In the build console output and in my email notifications I see the following:

[37;46;1mTest file: tests.js[0m
[33m# TEST XXX[0m
[32;1mPASS[0m #aaa found
[32;1mPASS[0m #bbb found
[32;1mPASS[0m ccc found
[32;1mPASS[0m ddd found

In the xUnit Plugin page, it says:

For each xUnit tool, an embedded style sheet is used. However, the plugin also enables you to use a custom style sheet for your own tool such as WebUI

Is there a way to display the build output so that it's styled properly with beautiful colors ?

回答1:

Hurray !

Actually, describing my problem made me investigate and find a solution !

I just needed to install the AnsiColor Plugin and check the Color ANSI Console Output box from the Build Environment !

More info here: http://code.dblock.org/the-jenkins-ansicolor-plugin-youve-all-been-waiting-for

It now displays beautiful colors in my Console Output.

Still shitty in my email notifications but who cares ?...

Hope it can help !