JBehave

Scenario runner should report before and after story only once when running given scenarios

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.4
  • Component/s: Core
  • Labels:
    None
  • Number of attachments :
    0

Description

When running a scenario with given scenarios, i.e. when running scenarios embedded in another scenario, the scenario runner should only report event beforeStory/afterStory once.

Activity

Hide
Cristiano Gavião added a comment - - edited

Hi,

in reality, what is happen is that the main scenario do not runs when a step fails on embedded scenario.

And consequently AfterStory() is not being called too.

regards

Show
Cristiano Gavião added a comment - - edited Hi, in reality, what is happen is that the main scenario do not runs when a step fails on embedded scenario. And consequently AfterStory() is not being called too. regards
Hide
Mauro Talevi added a comment -

Need to handle failure, so that the afterStory() is called, regardless of outcome.

Show
Mauro Talevi added a comment - Need to handle failure, so that the afterStory() is called, regardless of outcome.
Hide
Cristiano Gavião added a comment -

As a workaround to handle failure on the embedded scenario, I've created my own class that implements ScenarioReporter:

public class StepFailureScenarioReporterDecorator2 implements ScenarioReporter
	
public void afterStory(boolean embeddedStory) {
		delegate.afterStory(embeddedStory);
		if (embeddedStory == false)
			if (failure != null) {
				throw failure;
			}
	}

As well I configure my scenarios to use:

@Override
	public ErrorStrategy forHandlingErrors() {
		return ErrorStrategy.SILENT;
	}
	@Override
	public PendingErrorStrategy forPendingSteps() {
		return PendingErrorStrategy.PASSING;
	}
Show
Cristiano Gavião added a comment - As a workaround to handle failure on the embedded scenario, I've created my own class that implements ScenarioReporter:
public class StepFailureScenarioReporterDecorator2 implements ScenarioReporter
	
public void afterStory(boolean embeddedStory) {
		delegate.afterStory(embeddedStory);
		if (embeddedStory == false)
			if (failure != null) {
				throw failure;
			}
	}
As well I configure my scenarios to use:
@Override
	public ErrorStrategy forHandlingErrors() {
		return ErrorStrategy.SILENT;
	}
	@Override
	public PendingErrorStrategy forPendingSteps() {
		return PendingErrorStrategy.PASSING;
	}
Hide
Mauro Talevi added a comment -

Added given_non_successful.scenario that depends on a non successful embedded scenario.

Verified that after story is being called (from inspecting reports) if running in ignore failure mode.

Although, now that we can support multiple scenario reporters I would like to see that the handling of failures be moved to a bespoke reporter, rather than being in the PrintStreamScenarioReporter.

Show
Mauro Talevi added a comment - Added given_non_successful.scenario that depends on a non successful embedded scenario. Verified that after story is being called (from inspecting reports) if running in ignore failure mode. Although, now that we can support multiple scenario reporters I would like to see that the handling of failures be moved to a bespoke reporter, rather than being in the PrintStreamScenarioReporter.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: