Details
Description
Problem Statement:
When I use a composite step that calls another step which takes parameters, the correct step is rejected because it doesn't match the patternString.
Steps to Recreate:
1. Create a step and method that take a parameter, (ex. @When("I click the $button button")public void clickButton(String button)
2. Create a Composite step that references step 1. (ex. @When("I login")
@Composite(steps=
)
Actual Results:
The second step will give you a pending method, that matches step 1. but they don't match because of the paramter.
Suggested Change:
Found this while debugging in the StepCandidate.class on line 179:
if (StringUtils.startsWith(composedStep, candidate.getStartingWord())
&& StringUtils.endsWith(composedStep, candidate.getPatternAsString()) )
Could be changed to:
if (StringUtils.startsWith(composedStep, candidate.getStartingWord())
&& (StringUtils.endsWith(composedStep, candidate.getPatternAsString()) || candidate.matches(composedStep))) { return candidate; }
JUnit Test:
@Test
public void shouldMatchCompositStepsWhenStepParamterIsProvided(){
CompositeStepParamterMatching steps = new CompositeStepParamterMatching();
List<StepCandidate> candidates = steps.listCandidates();
StepCandidate candidate = candidates.get(0);
assertThat(candidate.isComposite(), is(true));
Map<String, String> noNamedParameters = new HashMap<String, String>();
List<Step> composedSteps = new ArrayList<Step>();
candidate.addComposedSteps(composedSteps, "When I login", noNamedParameters, candidates);
assertThat(composedSteps.size(), equalTo(2));
for (Step step : composedSteps)
assertThat(steps.button, equalTo("Login"));
}
static class CompositeStepParamterMatching extends Steps {
private String button;
@When("I login")
@Composite(steps=
)
public void whenILogin(){}
@When("I click the <button> button")
public void whenIClickTheButton(@Named("button") String button)
}
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | JunitTest.txt [ 59130 ] |
Attachment | JunitTest.txt [ 59131 ] |
Fix Version/s | 3.6 [ 17721 ] |
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Corrected JUnit Test