Behave test runner has no colored output on Jenkins

为君一笑 提交于 2019-12-08 19:14:39

问题


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:


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):



来源:https://stackoverflow.com/questions/30718995/behave-test-runner-has-no-colored-output-on-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!