JBehave
  1. JBehave
  2. JBEHAVE-204

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

        Mauro Talevi made changes -
        Field Original Value New Value
        Assignee Mauro Talevi [ maurotalevi ]
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        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.
        Mauro Talevi made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        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.
        Mauro Talevi made changes -
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Resolved [ 5 ]

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Mauro Talevi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: