在这里,我编写了一个测试来确定API是否正在使用预期的内容响应错误的请求……
Scenario: Unkown user response body properties contain expected content
Given I have a valid client auth token
And I request a user with an unknown "valid" uuid
And I get the response json
Then the expected fields should contain expected content
| field | content |
| statusCode | 404 |
| error | Not Found |
| message | User record not found |
下面是相应的步骤:
@then(u'the expected fields should contain expected content')
def step_impl(context):
for row in context.table:
received_content = str(context.request_json.get(row['field']))
expected_content = row['content']
assert_equal(received_content, expected_content)
Behave似乎将表行内容转换为字符串。
我的问题是:是否可以在Behave表中指定单元格的数据类型?
在实际的响应中,statusCode
是一个整数,但正如您在我的步骤函数中看到的那样,为了验证它,我被迫将请求内容转换为字符串。如果我可以指定我在content列中传递的404
是一个整数,我就不需要这么做了。
https://stackoverflow.com/questions/50627578
复制相似问题