Hi
I have a BDD test that fails, but carries on running. Im looking to stop the test as soon as it fails, does anyone know how to do this?
Thanks.
Hi
I have a BDD test that fails, but carries on running. Im looking to stop the test as soon as it fails, does anyone know how to do this?
Thanks.
Its a bit hackish, but one of the things I’ve been doing is adding @tags to my feature files, one of which is @required. If any of my @required scenarios fail I skip the rests of the tests. This keeps me from hammering against a system when some precondition like creating a test user has failed.
Include/scripts/groovy/hooks.groovy
import cucumber.api.Scenario
import cucumber.api.java.After
import cucumber.api.java.Before
import org.junit.Assume
@Before
public void beforeScenario(Scenario scenario) throws Throwable {
this.scenario = scenario
if (internal.GlobalVariable.exists('cucumberRequiredFailed')) {
if (wbgeneral.getGlobalVariable('cucumberRequiredFailed')==scenario.getUri()){
Assume.assumeTrue("SKIP SCENARIO (prereq failed): " + scenario.getName(), false)
} else {
wbgeneral.addGlobalVariable('cucumberRequiredFailed', '')
}
} }
@After
public void afterScenario(Scenario scenario){
if ((scenario.getSourceTagNames().contains('@required')) && (scenario.isFailed())){
wbgeneral.addGlobalVariable('cucumberRequiredFailed', scenario.getUri())
} }