Karate 后台操作失败时将场景测试标记为跳过
我想在后台出现任何故障时将场景标记为跳过。我在要素文件中具有以下结构:Karate 后台操作失败时将场景测试标记为跳过,karate,web-api-testing,Karate,Web Api Testing,我想在后台出现任何故障时将场景标记为跳过。我在要素文件中具有以下结构: Background: * call read('classpath:path/to/reusable.feature@ParticularScenario') ... Scenario: That one I want to skip if background call statement fails Given ... When ... Then ... 我尝试在call语句后在后台使用*if
Background:
* call read('classpath:path/to/reusable.feature@ParticularScenario')
...
Scenario: That one I want to skip if background call statement fails
Given ...
When ...
Then ...
我尝试在call语句后在后台使用
*if()karate.abort()
表达式,但它没有任何作用。我不建议这样做,强烈建议您重新构建测试结构
但这里有一个可能的解决方案。我再说一遍,我一点也不喜欢这个
Background:
* def error = false
* eval
"""
try {
var result = karate.call('reusable.feature');
karate.set(result);
} catch (e) {
karate.log('background failed:', e);
karate.set('error', true);
}
"""
Scenario:
* if (error) karate.abort()
但除此之外,空手道不是为这个而设计的,对不起