Hi Rickard,

at the moment the candidate steps that are constructed from the Steps class do not carry with them the annotation which denotes the type of step. They simply hold the pattern and check that the string step that is provided to them for matching starts with one of the allowed starting words (Given/When/Then/And or equivalent in other locales).

Hence, a behaviour such as you've hit upon is possible, albeit may not be desirable from you point of view. I personally would not define it a bug, but as the old saying says: "one man's ceiling is another man's floor" :-)

One immediate workaround is to slightly reword your steps so that matching pattern is unique , e.g.

Given foo named Bar
...
When foo is cretaed with named Xyzzy

The idea behind the current implementation was that the uniqueness of the matching pattern would be sufficient, given that the language typically is different in step of different types. The enhancement that would satisfy your use case is that it should be unique for each given step type or annotation.

But, as always we're driven by user requests and use cases. Why don't you raise an enhancement request in Jira and we'll evaluate the impact and backward compatibility. OTOH, I don't see any serious obstacles to this kind of change, but I would to look into in a bit more detail before giving a definite answer.

Cheers

Rickard Öberg wrote:
Hi,

I just found out that there is a serious bug with regard to how candidate steps are handled, and the weird part is that it seems to be intentional.

Here's the problem: if in my Step class I have the following methods
@Given("foo named $name")
public void givenFoo(String name) {...}
@When("foo named $name is created")
public void whenFooIsCreated(String name) {...}

and then use these in my scenarios:
Given foo named Bar
...
When foo named Xyzzy is created
---
I would *expect* that the annotations are used so that "When foo named Xyzzy is created" cannot match the @Given method. But, this is not the case. It seems like I can use any annotation on the methods, and it will be the same. The above could be defined with:
@Given("foo named $name")
public void givenFoo(String name) {...}
@Given("foo named $name is created")
public void whenFooIsCreated(String name) {...}

and it would be working the same way.

This causes me a lot of problems, because with the above I may randomly get givenFoo("Xyzzy is created") being invoked. And it is entirely random; sometimes it works, sometimes it doesn't. I'm assuming there's a hashmap somewhere that causes this randomness. And randomness is what I'm looking for in a test framework, if you see what I mean.

So, first question: what is the intention behind not caring about the specific annotation being used on the methods?

Second question: can this be changed so that the annotations matter?

thanks, Rickard

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to