如何在黄瓜JS报告的步骤中打印参数

时间:2018-09-15 15:18:42

标签: javascript cucumber cucumberjs

我有一个与此相似的功能文件。我想将示例打印到生成的报告中。找不到任何有效的解决方案。

我正在使用命令cucumber-js test/test.feature --require test/step.js --format json:test/report.json

生成json报告

功能文件:-

Feature: Simple maths

  Scenario Outline: much more complex stuff
    Given a variable set to <var>
    When I increment the variable by <increment>
    Then the variable should contain <result>

    Examples:
      | var | increment | result |
      | 100 |         5 |    105 |
      |  99 |      1234 |   1333 |
      |  12 |         5 |     18 |

生成的报告:-

[
  {
    "keyword": "Feature",
    "name": "Simple maths",
    "line": 1,
    "id": "simple-maths",
    "tags": [],
    "uri": "test/test.feature",
    "elements": [
      {
        "id": "simple-maths;much-more-complex-stuff",
        "keyword": "Scenario",
        "line": 10,
        "name": "much more complex stuff",
        "tags": [],
        "type": "scenario",
        "steps": [
          {
            "arguments": [],
            "keyword": "Given ",
            "line": 4,
            "name": "a variable set to 100",
            "match": {
              "location": "test/teststep.js:28"
            },
            "result": {
              "status": "passed",
              "duration": 1000000
            }
          },
          {
            "arguments": [],
            "keyword": "When ",
            "line": 5,
            "name": "I increment the variable by 5",
            "match": {
              "location": "test/teststep.js:33"
            },
            "result": {
              "status": "passed"
            }
          },
          {
            "arguments": [],
            "keyword": "Then ",
            "line": 6,
            "name": "the variable should contain 105",
            "match": {
              "location": "test/teststep.js:38"
            },
            "result": {
              "status": "passed",
              "duration": 1235000000
            }
          }
        ]
      }
    ]
  }
]

我期望这样的报告中包含参数或示例属性

{
  "steps": [
    {
      "arguments": [],
      "keyword": "Given ",
      "line": 4,
      "name": "a variable set to 100",
      "match": {
        "location": "test/teststep.js:28"
      },
      parameters: {
       "var": "100"
      },
      "result": {
        "status": "passed",
        "duration": 1000000
      }
    }
  ]
}

有什么办法可以做到这一点?

0 个答案:

没有答案