目前我正在用 Python Lettuce 编写一些集成测试。我想为一些 XML 的比较创建一个通用步骤。
我知道在步骤定义之后的 .feature 文件中
Scenario: I want to compare XML's...
...
And I check generated transaction "XYZ" contents with parameters:
...
我可以添加 step.hashes,这将在步骤定义中的 step.hashes 属性中可用(some_step_definitions.py 波纹管)
@step(u'And I check generated transaction "([^"]+)" contents with parameters:$')
def check_generated_content(step, transaction_type):
*(some xml mappings for comparision, appending dictionaries to step.hashes)*
for item in mappings:
step.hashes.append({
'key1': 'val1',
'key2': 'val2'
})
我的问题是:是否可以在步骤代码(check_generated_content)中附加标题(key1,key2),当执行测试时,我在测试报告中有标题,例如:
Scenario: I want to compare XML's...
...
And I check generated transaction "XYZ" contents with parameters:
| key1 | key2 |
| val1 | val2 |
...
当我不指定时
And I check generated transaction "XYZ" contents with parameters:
| key1 | val1 |
在功能文件中,我得到了测试报告:
And I check generated transaction "XYZ" contents with parameters:
| | |
| | |
总之..我只想写
And I check generated transaction "XYZ" contents with parameters:
代替
And I check generated transaction "XYZ" contents with parameters:
| key1 | val1 |
每次。