It was mentioned in http://jira.codehaus.org/browse/JBEHAVE-216 that
as a bit of a hack, by sorting the annotations in descending string length.
This is good solution and by no means a hack.
Ordering of candidates
Given the following candidate steps:
- the user logs in as $user
- the user logs in as $user, with password $password
Remove the parameters, to be left with:
- the user logs in as
- the user logs in as , with password
And the stepAsText is:
- the user logs in as nobody, with password secret
This step could match both candidates, so the ordering is important. If ordering longest candidates first, this will always try to match the most specific patterns first. This approach will be completely deterministic, and eliminate the need for prioritising steps manually.
Filtering of candidates
Given the stepAsText is:
- the user logs in as nobody
Then since the stepAsText.length() is less than the length of candidate 2 (after removal of parameters), its impossible for the stepAsText to match that candidate.
If the stepAsText is:
- the user logs in as nobody interesting
Then since the stepAsText.length() is greater than the length of both candidates (after removal of parameters), its possible for the stepAsText to match either candidate.
So its possible to immediately eliminate candidates that are longer than the stepAsText.
Therefore, filtering based on stepAsText length can also be used to improve the efficiency of step collection.
It was mentioned in http://jira.codehaus.org/browse/JBEHAVE-216 that
This is good solution and by no means a hack.
Ordering of candidates
Given the following candidate steps:
Remove the parameters, to be left with:
And the stepAsText is:
This step could match both candidates, so the ordering is important. If ordering longest candidates first, this will always try to match the most specific patterns first. This approach will be completely deterministic, and eliminate the need for prioritising steps manually.
Filtering of candidates
Given the stepAsText is:
Then since the stepAsText.length() is less than the length of candidate 2 (after removal of parameters), its impossible for the stepAsText to match that candidate.
If the stepAsText is:
Then since the stepAsText.length() is greater than the length of both candidates (after removal of parameters), its possible for the stepAsText to match either candidate.
So its possible to immediately eliminate candidates that are longer than the stepAsText.
Therefore, filtering based on stepAsText length can also be used to improve the efficiency of step collection.