I have two similarly worded steps, but still different enough (I would hope):
@When("I send $method '$url'")
public void sendMethodURL(
@Named("method") final String method,
@Named("url") final String url)
{
// stuff
}
@When("I send $method '$url' with JSON '$body'")
public void sendMethodURLBody(
@Named("method") final String method,
@Named("url") final String url,
@Named("body") final String inputJSON)
{
// stuff
}
However, in my story, I have:
When I send POST '/blah/foo/bar' with JSON '["some", "json"]'
Yet it's calling sendMethodURL
where method
is "POST '/blah/foo/bar' with JSON"
and url is "[\"some\", \"json\"]"
. Clearly, I'd rather it call sendMethodURLBody
instead.
What am I doing wrong here? How can I get JBehave to differentiate between the two steps?
Edit: I realize it's the RegexStepMatcher matching the first @When it finds that matches (which is sendMethodURL
)... but how can I keep the grammar as it is, but differentiate the two so it no longer matches both steps? The order of the methods seems to work, but there must be a less fragile way.