使用 behat on POST 检查所需的属性

Check for required properties with behat on POST

我正在测试我的 REST API 所以我正在做这样的事情:

Scenario: Create a Task List
  Given I send a POST to tasklist with json:
  """
  {
    "creator_id" : 1,
    "title" : "Behat Test List",
    "display_order" : 7,
    "color" : 123456,
    "type": 1
  }
  """
  Then The response code should be 201

这 5 个属性都是创建任务列表所必需的。我现在需要再写五个这样的参数并省略一个参数,并确保响应代码是 400。这感觉像是大量的重复。正确的做法是什么?

尝试这样的场景大纲:

Scenario Outline: Create a Task List
Given I send a POST to tasklist with json:
"""<sample>"""
Then The response code should be 201

Examples:
  | sample                                                                                              |
  | { "creator_id" : 1, "title" : "Behat Test List", "display_order" : 7, "color" : 123456, "type": 1 } |