【发布时间】:2015-03-04 07:56:01
【问题描述】:
目前我正在用 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 |
每次。
【问题讨论】:
-
好的,我需要回答我的问题,而不是评论它:)
标签: lettuce