[ https://jira.codehaus.org/browse/JBEHAVE-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Tanner updated JBEHAVE-733: --------------------------------- Attachment: JunitTest.txt Corrected JUnit Test > Composed steps don't behave like steps in a story when using parameters > ----------------------------------------------------------------------- > > Key: JBEHAVE-733 > URL: https://jira.codehaus.org/browse/JBEHAVE-733 > Project: JBehave > Issue Type: Bug > Components: Core > Affects Versions: 3.5.4 > Environment: Windows XP using Eclipse Indigo in Java > Reporter: David Tanner > Attachments: JunitTest.txt > > Original Estimate: 1 hour > Remaining Estimate: 1 hour > > 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={"I > click the login button"}) > 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()) ) { > return candidate; > } > 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) { > step.perform(null); > } > assertThat(steps.button, equalTo("Login")); > } > > static class CompositeStepParamterMatching extends Steps { > private String button; > > @When("I login") > @Composite(steps={"I click the Login button"}) > public void whenILogin(){} > > @When("I click the <button> button") > public void whenIClickTheButton(@Named("button") String button){ > this.button = button; > } > > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email