Cucumber Eclipse Plugin Pretty格式化功能异常问题咨询
解决方案
- 校验TestRunner类的
@CucumberOptions注解配置
确保plugin参数配置正确,示例正确配置如下:
@CucumberOptions( features = "src/test/resources/features", glue = "stepdefinitions", plugin = {"pretty", "html:target/cucumber-reports.html"}, monochrome = false )
确认没有拼写错误,也没有同时配置多个冲突的控制台输出插件。
- 调整Eclipse编码配置
- 打开
Window → Preferences → General → Workspace,将Text file encoding设置为UTF-8 - 进入
Run/Debug → Console,将Console encoding也修改为UTF-8,避免编码异常导致格式符解析失败
统一Cucumber插件与依赖版本
你使用的Java 1.8最高可兼容Cucumber 7.11.0稳定版,建议将项目引入的cucumber-java、cucumber-junit依赖版本升级到7.11.0,同时保证Cucumber Eclipse插件版本和依赖版本匹配,版本不匹配是pretty格式异常的高频原因。关闭控制台自动折行
点击控制台视图右上角的下拉菜单,取消勾选Wrap Text选项,pretty模式的缩进、换行依赖固定行宽,自动折行会打乱原有排版。强制指定pretty模式输出参数
在TestRunner对应的运行配置Run Configurations → Arguments → VM arguments中添加参数:-Dcucumber.pretty.monochrome=false
强制启用格式化输出,若控制台出现ANSI颜色码乱码,可将参数值改为true关闭彩色输出。
内容的提问来源于stack exchange,提问作者user1909223
相关产品推荐
相关产品推荐

