假设如下所示:
Scenario Outline: various bits
When a thing named "bog standard" is created with "<name>", "<path>", and "<type>"
Then the system should respond with <response>
Examples:
| name | path | type | response |
| | | | 400 |python @When(u'a thing name...“)注释方法不会为这个输入调用。显然,参数必须至少有一个非空格字符。对于任何包含缺失值的测试,我都会得到一个NotImplementedException。
我怎么才能让它工作呢?我想测试一下缺少的值。我希望将None或"“传递给step方法。
另外,如果我想在参数中使用前导空格,我该怎么做呢?
发布于 2017-10-26 21:03:23
Gherkin在解析示例表时非常“固执己见”。
获得所需内容的最简单方法是使用占位符的值,例如"none“或"n/a",并在步骤定义中检查占位符。您可以使用注释预先警告读者有关占位符值的信息。请记住,小黄瓜主要用于人类可读/可编辑。
关于前导空格,目前还没有简单的方法将它们放入示例表中。在小黄瓜项目中提出了一个issue来解决这个问题。
一些替代方案:
Examples: | name | response | | ...has three leading spaces | 100 |
When the user inputs " string with one leading space" in the path
When the user inputs """ This one has three leading spaces """
https://stackoverflow.com/questions/31972702
复制相似问题