简体   繁体   English

如何从Ruby黄瓜方案大纲中生成可通过黄瓜报告正确使用的结果?

[英]How to generate results from a Ruby Cucumber Scenario Outline that can be properly consumed by cucumber-reporting?

We have an app using Cucumber with many gherkins that use Scenario Outlines. 我们有一个使用Cucumber的应用程序以及许多使用场景大纲的小黄瓜。 We are using ruby to run the tests. 我们正在使用ruby运行测试。

I'd like to display the results of these tests with cucumber-reporting . 我想用黄瓜报告显示这些测试的结果。 However, there is currently an issue with how cucumber reports JSON (et al) results for Scenario Outlines, which means that the output does not contain proper results and the report cannot display those results. 但是,当前黄瓜如何报告“方案大纲”的JSON(等)结果存在问题,这意味着输出不包含正确的结果,并且报告无法显示这些结果。 See this issue and this issue . 请参阅本期本期

Can I put in a hack to Cucumber to make JSON report properly when dealing with Scenario Outlines? 处理场景大纲时,我可以对Cucumber进行黑客攻击以正确地生成JSON报告吗? Alternately, is there an automated way to process the Scenario Outlines into normal Scenarios so that Cucumber will generate proper reports? 或者,是否存在一种自动方式将“方案大纲”处理为正常方案,以便Cucumber将生成适当的报告?

Below I have a brute-force answer, but I would appreciate something less kludgy. 下面我有一个蛮力的答案,但我希望您能避免一些杂乱无章的事情。

Note: I really don't like this answer. 注意:我真的不喜欢这个答案。

Scenario Outlines can be preprocessed using cucumber -f pretty -x -d , which expands scenario outlines in a dry-run, where the steps are not actually executed. 可以使用cucumber -f pretty -x -d预处理方案大纲,这可以在未实际执行步骤的空运行中扩展方案大纲。 The output can be piped to a file and that file can be chopped up using some script to extract the generated scenarios. 可以将输出通过管道传输到文件,并可以使用一些脚本将文件切碎以提取生成的方案。

Those scenarios can then be included in the input to the actual cucumber execution, which will execute the Scenario Outlines as if they are normal Scenarios. 然后,可以将这些方案包含在实际执行黄瓜的输入中,该输入将执行方案大纲,就好像它们是正常方案一样。

This is really kludgy and would require writing a script to chop up the results of the -f pretty -x output (including removing the auto-comments on each line and the preamble to the actual generated Examples: for each outline). 这确实很麻烦,需要编写脚本来将-f pretty -x输出的结果切碎(包括删除每行的自动注释和实际生成的Examples:的前言Examples:针对每个轮廓)。

Update: 更新:

Someone has written a formatter that essentially does this, but they warn that it's a hack: https://gist.github.com/blt04/9866357 有人编写了一个格式化程序,基本上可以做到这一点,但是他们警告说这是黑客: https : //gist.github.com/blt04/9866357

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM