行为测试运行程序在詹金斯上没有彩色输出 [英] Behave test runner has no colored output on Jenkins

查看:239
本文介绍了行为测试运行程序在詹金斯上没有彩色输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在EC2实例的Ubuntu服务器14.04上安装了jenkins.我有一些硒测试是使用 behave 作为测试运行程序来执行的.

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.

在Jenkins上,我还安装了插件 AnsiColor ,希望我可以在上面获得颜色输出jenkins控制台,但是除了Gherking语法之外,其他所有颜色我都得到了体现. Selenium错误,python调试,所有内容都有颜色...行为的输出除外.

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.

现在的问题是,如果我在Mac或Ubuntu上运行测试,但不与Jenkins用户一起运行,则一切正常,并且颜色在那里.

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:

  • 运行行为与behave --color
  • 将AnsiColorPlugin的颜色映射映射到formatter/ansi_escapes.py中发现的行为的转义序列
  • #!/bin/bash添加到jenkins构建脚本中,以确保不会使用sh而不是bash来执行该脚本.
  • 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

如果这有任何意义,我正在virtualenv

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

推荐答案

阅读PrettyFormatter的原始源代码,没有办法强迫它使用颜色,因为它使用isatty来确定它是否正在写入实际的终端.

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/5fa2dd3fd1dc71498df4>

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

我已经创建了拉取请求,并测试了它是否可以在Jenkins中工作(当然,在项目配置中启用了解析ANSI代码之后):

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

这篇关于行为测试运行程序在詹金斯上没有彩色输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆