I want to mark scenario as skipped in case of any fail in Background. I have the following structure in feature file:
Background:
* call read('classpath:path/to/reusable.feature@ParticularScenario')
...
Scenario: That one I want to skip if background call statement fails
Given ...
When ...
Then ...
I tried to use * if () karate.abort()
expression in background after call statement but it does nothing.
I don't recommend this and strongly urge you to re-structure your tests.
But here is a possible solution. I say again, I don't like this at all.
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()
But otherwise, Karate is not designed for this, sorry.