Behave test runner has no colored output on Jenkins

2.2k views Asked by At

I have setup jenkins on Ubuntu server 14.04 on an EC2 instance. I have some selenium tests that I execute using behave as test runner.

On Jenkins I have also installed the plugin AnsiColor hoping that I can get color output on the jenkins console, however I get color for everything else except for the Gherking syntax. Selenium errors, python debug, everything has color...except for the output of behave.

Now the thing is if I run the tests on a Mac or on Ubuntu but not with the Jenkins user, everything works fine and the colors are there.

I really don't have any code to post, but I can say what I have tried to no avail:

  • running behave with behave --color
  • mapping the color map of AnsiColorPlugin to the escape sequences of behave found in formatter/ansi_escapes.py
  • adding #!/bin/bashto jenkins build script to make sure it does not get executed with shinstead of bash

If this is of any relevance I am using python 3.4 on virtualenv

Besides the actual answer, any suggestions on how to debug this are also welcome! thanks

1

There are 1 answers

0
LetMeSOThat4U On

Reading original source code of PrettyFormatter, there's no way to force it to use colors as it uses isatty to determine if it's writing to actual terminal.

However, necessary modifications to enable color output are trivial:

https://github.com/mrkafk/behave/commit/5fa2dd3fd1dc7149857df4da156d8fd00f5058a5

I've created pull request and tested it to work in Jenkins (after enabling parsing ANSI codes in project configuration of course):

enter image description here