The matching of step candidate to textual steps is central to JBehave's design. The first candidate that matches is used to create an executable step. In some case, though, one can have cases in which multiple candidates can match the same textual step, e.g. when the steps are very similar.
To address this concern, JBehave provide a StepFinder which allows for a customisable PrioritisingStrategy. The default strategy is ByPriorityField which prioritises the steps by the priority field explicitly set in the Given/When/Then annotations. An alternative strategy is the ByLevenshteinDistance which prioritises the steps according to the Levenshtein Distance.
To specify a custom strategy, simply create a StepFinder with the desired strategy, and override the default step collector in the configuration:
StepCollector stepCollector = new MarkUnmatchedStepsAsPending(new StepFinder(new ByLevenshteinDistance())); new MostUsefulConfiguration().useStepCollector(stepCollector);