Ton*_*nis 6 python python-behave
考虑一个Behave场景:
When some magic number is generated
Then the number should be greater than 5
Run Code Online (Sandbox Code Playgroud)
所以我有一个@when函数产生(比方说)一个随机数,我需要在@then条件测试中出现这个数字.
如何将一步结果传递给另一步?
Pet*_*ood 10
您可以在传递给步骤的上下文对象上设置数据.从文档:
@given('I request a new widget for an account via SOAP')
def step_impl(context):
client = Client("http://127.0.0.1:8000/soap/")
context.response = client.Allocate(customer_first='Firstname',
customer_last='Lastname', colour='red')
@then('I should receive an OK SOAP response')
def step_impl(context):
eq_(context.response['ok'], 1)
Run Code Online (Sandbox Code Playgroud)
您还可以在测试运行的各个其他点,每个步骤,功能,方案,标记等之前和之后修改上下文.
| 归档时间: |
|
| 查看次数: |
2894 次 |
| 最近记录: |