我正在使用 pytest bdd 自动化 api。我需要为
@pytest.mark.xfail
我的步骤定义之一实现。但是在添加了这个装饰器之后,它并没有按预期工作。
示例 >
example.feature
Scenario: Validate the API response where availableLicense should not be greater than the totalLicense.
Given Send valid input
Then validate the availableLicense count should not be greater than totalLicense.
test_example.py
@given('Send valid input')
def valid_data(context, url,token_url, api_key):
context.response = api_req('get',url, token_url, api_key)
@then('validate the availableLicense count should not be greater than totalLicense.')
@pytest.mark.xfail
def validate_license_count(context):
<some logic>
assert avail_license <= total_license
当上述断言失败时,我的测试用例仍然显示为失败。我应该在这里做什么?