JBehave
  1. JBehave
  2. JBEHAVE-868

Parameterised scenarios are skipped when filtered by story meta

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.7.4
    • Fix Version/s: 3.7.5, 3.8
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Scenarios parameterised by examples are skipped if scenario level meta filtering is used. This seems to be a direct result of changes introduced by JBEHAVE-846.

      eg:

      <metaFilters>
          <metaFilter>+foo *</metaFilter>
      </metaFilters>
      
      Meta:
      @foo bar
      
      Scenario:
      
      Given I am a 'Partner' user
      
      When a 'Business Support' case is created with:
      |name                |value              |
      |Code                |<Code>             |
      |Process             |<Process>          |
      |Sub Process         |<Sub Process>      |
      
      Then the case has 1 item in basket 'Partner Team'
      
      Examples:
      |<Code>  |<Process>        |<Sub Process>         |
      |XYZ     |Business Support |Bank Statement Upload |
      

      Execution of the above results in the before and after steps being executed but all scenario steps being skipped.

      Debugging the code shows that the check:

      if ( !context.filter.allow(parameterMeta) ){
          continue;
      }
      

      in the method:

      StoryRunner.java
      private void runScenariosParametrisedByExamples(RunContext context, Scenario scenario, Meta storyAndScenarioMeta)
              throws Throwable {
          ExamplesTable table = scenario.getExamplesTable();
          reporter.get().beforeExamples(scenario.getSteps(), table);
          Keywords keywords = context.configuration().keywords();
          for (Map<String, String> scenarioParameters : table.getRows()) {
              Meta parameterMeta = parameterMeta(keywords, scenarioParameters);
              if ( !context.filter.allow(parameterMeta) ){
                  continue;
              }
              reporter.get().example(scenarioParameters);
              if (context.configuration().storyControls().resetStateBeforeScenario()) {
                  context.resetState();
              }
              runBeforeOrAfterScenarioSteps(context, scenario, storyAndScenarioMeta, Stage.BEFORE, ScenarioType.EXAMPLE);
              addMetaParameters(scenarioParameters, storyAndScenarioMeta);
              runGivenStories(scenario.getGivenStories(), scenarioParameters, context);
              runScenarioSteps(context, scenario, scenarioParameters);
              runBeforeOrAfterScenarioSteps(context, scenario, storyAndScenarioMeta, Stage.AFTER, ScenarioType.EXAMPLE);
          }
          reporter.get().afterExamples();
      }
      

      always passes resulting in 'continue' and the scenario execution being skipped.

      Using the example above, context.filter='+foo *', but because the meta parameter 'foo' is at scenario level and not at examples table level, parameterMeta is empty and the filter.allow() is false resulting in 'continue'.

        Activity

        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 3.7.5 [ 18997 ]
        Hide
        Tim Brizard added a comment -

        Just to be clear, this has also broken the ability to be able to filter at the story level. This is a pretty big deal for all of us using meta filtering and is preventing us from upgrading.

        Show
        Tim Brizard added a comment - Just to be clear, this has also broken the ability to be able to filter at the story level. This is a pretty big deal for all of us using meta filtering and is preventing us from upgrading.
        Hide
        timothy brizard added a comment - - edited

        Very simple story file where both scenarios are skipped when using 3.7.3 and specifying meta filter '+category smoke'.

        Meta:
        @category smoke
        
        Scenario:
        # Assumption: logged in and reservation exists
        # Comments: checks basic details
        
        Given I am logged into my account
        When I lookup my <car reservation>
        Then I will see <car type>
        And I will see the <total price>
        
        Examples:
        | car reservation | car type | total price |
        | 1223395844      | midsize  | 566.21      |
        
        
        Scenario:
        # Assumption: logged in and reservation does not exist
        # Comments: checks error handling
        
        Given I am logged into my account
        When I lookup my <car reservation>
        Then I will see a message that the reservation is not found
        
        
        Examples:
        | car reservation | 
        | 1223395844      | 
        
        
        Show
        timothy brizard added a comment - - edited Very simple story file where both scenarios are skipped when using 3.7.3 and specifying meta filter '+category smoke'. Meta: @category smoke Scenario: # Assumption: logged in and reservation exists # Comments: checks basic details Given I am logged into my account When I lookup my <car reservation> Then I will see <car type> And I will see the <total price> Examples: | car reservation | car type | total price | | 1223395844 | midsize | 566.21 | Scenario: # Assumption: logged in and reservation does not exist # Comments: checks error handling Given I am logged into my account When I lookup my <car reservation> Then I will see a message that the reservation is not found Examples: | car reservation | | 1223395844 |
        Mauro Talevi made changes -
        Assignee Mauro Talevi [ maurotalevi ]
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Mauro Talevi added a comment -

        Deployed 3.8-SNAPSHOT with fix. The meta_filtering.story in the trader example has been update to incorporate this usecase.

        Can you please verify it works for you before we cut the release?

        Show
        Mauro Talevi added a comment - Deployed 3.8-SNAPSHOT with fix. The meta_filtering.story in the trader example has been update to incorporate this usecase. Can you please verify it works for you before we cut the release?
        Hide
        Paul Brunckhorst added a comment -

        Seems to be working fine for me now with 3.8-SNAPSHOT. Thanks.

        Show
        Paul Brunckhorst added a comment - Seems to be working fine for me now with 3.8-SNAPSHOT. Thanks.
        Mauro Talevi made changes -
        Fix Version/s 3.8 [ 19104 ]

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Paul Brunckhorst
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: