[
https://jira.codehaus.org/browse/JBEHAVE-748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=295211#comment-295211
]
Arjan van Bentem edited comment on JBEHAVE-748 at 3/27/12 10:14 AM:
--------------------------------------------------------------------
Beware that the output on the screen might actually differ from the real
parameter values. Like:
{code}
Then I see <b>
And I saw 'bar'
{code}
...will, while executing, be shown as:
{code}
Then I see that
And I saw 'bar'
{code}
...while in fact the last step will not use {{bar}} but {{that}}.
was (Author: avbentem):
Beware that the output on the screen might actually differ from the real
parameter values. Like:
{code}
Then I see <b>
And I saw 'bar'
{code}
...will, while executing, be shown as:
{code}
Then I see that
And I saw 'bar'
{code}
...while in fact the last step will not use {{bar}} but {{that}}.
And just for the archives, a trivial workaround when in need of using both an
{{Example}} table and regular (positional) parameters:
{code}
// For use with Example table
@Then("I see <b>")
public void thenISeeB(@Named("b") String myB) {
assertThat(myB).isEqualTo("that");
}
// For use with regular, positional, parameters (where an @Alias
// in the above step would actually make values from the Examples
// table being used instead):
@Then("I see $b")
public void thenISeeBPositionalParameters(String myB) {
thenISeeB(myB);
}
{code}
> When @Named parameter matches name in Example table, it might be injected for
> steps that do not reference it
> ------------------------------------------------------------------------------------------------------------
>
> Key: JBEHAVE-748
> URL: https://jira.codehaus.org/browse/JBEHAVE-748
> Project: JBehave
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.5.4
> Environment: Windows 7, Java 6
> Reporter: Arjan van Bentem
>
> When a step with @Named parameters is used in a scenario that uses an Example
> table for SOME of its steps, but for this specific step is given some
> explicit value, then IF the parameter name is not fully surrounded with
> whitespace AND it matches a name from the Examples table, then the given
> value is ignored. Instead, the value from the Examples table is injected.
> If the parameter name is unrelated to anything in the Examples table, then
> all is fine, even when the parameter is not fully surrounded with whitespace.
> (This is slightly related to http://jira.codehaus.org/browse/JBEHAVE-646)
> For example, all fine:
> {code}
> @Given("I have <a> and <b>")
> public void givenAAndB(@Named("a") String myA, @Named("b") String myB) {
> assertThat(myA).isEqualTo("this");
> assertThat(myB).isEqualTo("that");
> }
> @When("I do <a>")
> public void whenIDoA(@Named("a") String myA) {
> assertThat(myA).isEqualTo("this");
> }
> @Then("I see <b>")
> public void thenISeeB(@Named("b") String myB) {
> assertThat(myB).isEqualTo("that");
> }
> // $x not surrounded by all whitespace, but "x" NOT known in Examples table:
> all fine
> @When("I did '$x'")
> public void whenIDidX(@Named("x") String myX) {
> assertThat(myX).isEqualTo("foo");
> }
> {code}
> ...but wrong:
> {code}
> // $b not surrounded by all whitespace, and "b" also known in Examples table
> @Then("I saw '$b'")
> public void thenISawB(@Named("b") String myB) {
> // Will fail: is assigned "that" from Examples table instead
> assertThat(myB).isEqualTo("bar");
> }
> {code}
> ...when used with:
> {code}
> Given I have <a> and <b>
> When I did 'foo'
> And I do <a>
> Then I see <b>
> And I saw 'bar'
> Examples:
> | a| b|
> |this|that|
> {code}
--
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