Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matching scenario outline variables with java code definitions does not work #31

Open
joe2236 opened this issue Feb 7, 2014 · 6 comments
Labels
Issue A defect or bug which renders one or more features unusable under certain circumstances

Comments

@joe2236
Copy link

joe2236 commented Feb 7, 2014

hi,

when using simple scenario outlines like

simple scenario feature

    ...
    When i send <command>
    Then i get a response <output>

    Examples:  
    |  command    |  output    |
    | "TEST1"     | 1          |
    | "TEST2"     | 2          |

and the steps are not defined yet then the java cucumberrunner will autogenerate it with

simple scenario java

    ...     
    @When("^i send \"([^\"]*)\"$")
    public void i_send(String arg1) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
    }

    @Then("^i get a response (\\d+)$")
    public void i_get_a_response(int arg1) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
    }

when i use this declarations cucumber does work with no problems - but the matching in your editor plugin allways says for example
No definition found for i send <command>

when i change the regex to

    @When("^i send (.*)$")
    public void i_send(String arg1) throws Throwable {
        // Express the Regexp above with the code you wish you had
        throw new PendingException();
    }

the matching is working in the editor

but i think thats not exact enough - so imho the matching should be adapted to work with all correct regular expressions or am i doing something completely wrong ?

i am using

  • eclipse jee Kepler Service Release 1
  • cucumber 1.1.5
  • cucumber editor 0.7.4
  • jbehave editor 0.3.0
  • xtext 2.4.3
  • cucumber eclipse feature 0.0.6

regards
joe

@rlogiacco
Copy link
Owner

Ok, I'm not sure what should be the correct behavior, but I can see why the
error is reported and I believe there might be a solution... I'm not sure I
wish to use such 'feature' myself though: what if I don't put the double
quotes on the second line? The first one matches, the second doesn't: would
you expect a warning? I believe you wish a warning sign to be put beside
the second row, first column, saying that placeholder substitution doesn't
match.... I'm not sure that would be a viable solution within the plugin,
mostly because of performance implications... Please consider every
character you type the document get's re-parsed and a new tentative to
match the step is performed.

The alternative would be to disable stepdef matching check on scenario
outline steps containing placeholder(s): that would be viable, but would
imply a loss in functionality....

Il venerdì 7 febbraio 2014, joe2236 [email protected] ha scritto:

hi,

when using simple scenario outlines like
simple scenario feature

...    When i send <command>    Then i get a response <output>
Examples:      |  command    |  output    |    | "TEST1"     | 1          |    | "TEST2"     | 2          |

and the steps are not defined yet then the java cucumberrunner will
autogenerate it with
simple scenario java

...
@When("^i send \"([^\"]*)\"$")
public void i_send(String arg1) throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}

@Then("^i get a response (\\d+)$")
public void i_get_a_response(int arg1) throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}

when i use this declarations cucumber does work with no problems - but the
matching in your editor plugin allways says for example
No definition found for i send

when i change the regex to

@When("^i send (.*)$")
public void i_send(String arg1) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}

the matching is working in the editor

but i think thats not exact enough - so imho the matching should be
adapted to work with all correct regular expressions or am i doing
something completely wrong ?

i am using

  • eclipse jee Kepler Service Release 1
  • cucumber 1.1.5
  • cucumber editor 0.7.4
  • jbehave editor 0.3.0
  • xtext 2.4.3
  • cucumber eclipse feature 0.0.6

regards
joe

Reply to this email directly or view it on GitHubhttps://github.com//issues/31
.

@rlogiacco
Copy link
Owner

In other words, if we have

Scenario Outline: command output
  When i send <command>
  Then i get a response <output>

    Examples:  
    |  command    |  output    |
    | "TEST1"     | 1          |
    | "TEST2"     | 2          |

With this corresponding stepdef specifying part of the example values within the regexp

@When("^i send \"([^\"]*)\"$")
    public void i_send(String arg1) throws Throwable {
    ...
}

SOLUTION 1

Verify the regexp by substituting the <command> placeholder with each of its values ("TEST1" and "TEST2") and after this try to apply the reverse matching to verify a matching stepdef exists.

PROS: identifies matching and un-matching values within the table
CONS: slower than actual implementation; gets slower on increasing the number of examples; warnings will have to be linked to example lines to provide enough context

SOLUTION 2

Because we are within a scenario outline, when we encounter the <command> placeholder we disable the reverse matching

PROS: no erroneous matching errors are reported; no performance bottlenecks
CONS: no reverse matching happens on steps containing placeholders is performed at all

SOLUTION 3

We can apply solution 1 but using only first line values are used for reverse matching checks

PROS: no erroneous matching errors are reported; no performance bottlenecks
CONS: first line in examples assumes an additional semantic value which it doesn't have within the language

By doing some experiments, the most reliable solution would be number 1, but I'm not sure it would perform well enough to be usable.

@joe2236
Copy link
Author

joe2236 commented Feb 11, 2014

hi
i would also prefer solution 1 but you can say best what this means for performance.
TIA joe

@daniel-da
Copy link

Hi,
I'm for solution 1 and 2 configurable from preferencies.
D.

@rlogiacco rlogiacco added the Issue A defect or bug which renders one or more features unusable under certain circumstances label Mar 22, 2016
@github-actions
Copy link

This issue has not been updated for a while: marking it as stale.

@github-actions github-actions bot added the Stale Probably not relevant anymore and to be closed label May 29, 2020
@github-actions github-actions bot closed this as completed Jun 6, 2020
@rlogiacco rlogiacco reopened this Jun 7, 2020
@rlogiacco
Copy link
Owner

this might actually get implemented once @drkstr101 gets the new step matching algorithm

@rlogiacco rlogiacco reopened this Jun 15, 2020
@rlogiacco rlogiacco removed the Stale Probably not relevant anymore and to be closed label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue A defect or bug which renders one or more features unusable under certain circumstances
Projects
None yet
Development

No branches or pull requests

3 participants