JBehave
  1. JBehave
  2. JBEHAVE-583

Of multiple exclusion meta filters only one is evaluated

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.4.5
    • Fix Version/s: 3.5
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Assuming meta info

      Meta:
      @environment all
      @skip
      

      the following filter may not exclude the scenario, although it should:

      -environment preview -skip
      

      Method match in MetaFilter returns immediately when one filter expression does not match. If "environment" is tested before "skip", match will return false, and scenario will not be excluded. The logic should be changed such that match will return true, iff any exclusion filter matches.

      The actual order of evaluation depends on the order of property names returned by #getPropertyNames, which appears to be alphabetical.

          private boolean match(Properties properties, Meta meta) {
              for (Object key : properties.keySet()) {
                  String property = (String) properties.get(key);
                  for (String metaName : meta.getPropertyNames()) {
                      if (key.equals(metaName)) {
                          String value = meta.getProperty(metaName);
                          if (StringUtils.isBlank(value)) {
                              return true;
                          } else if (property.contains("*")) {
                              return value.matches(property.replace("*", ".*"));
                          }
                          return properties.get(key).equals(value);
                      }
                  }
              }
              return false;
          }
      

        Activity

        Hide
        Dennis Homann added a comment -

        Attached reproducing test case

        Show
        Dennis Homann added a comment - Attached reproducing test case
        Dennis Homann made changes -
        Field Original Value New Value
        Attachment MetaFilterReproducerTest.java [ 56481 ]
        Hide
        Mauro Talevi added a comment -

        Thanks, added test cases.

        Show
        Mauro Talevi added a comment - Thanks, added test cases.
        Mauro Talevi made changes -
        Fix Version/s 3.5 [ 17393 ]
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Mauro Talevi [ maurotalevi ]
        Resolution Fixed [ 1 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: