Finding Steps

JBehave centers around the matching of textual steps with Java methods contained in CandidateSteps instances. Each annotated method in the CandidateSteps instances corresponds to a CandidateStep, which is responsible for the matching and for the creation of an executable step.

When the number of CandidateSteps instances grows, it can become more difficult to find a matching candidate step. In this case, it may be useful to make use of the CandidateStepFinder via the Embedder:

    Embedder embedder = new Embedder();
    embedder.useConfiguration(...); // specify your configuration
    embedder.useCandidateSteps(...); // specify your candidate steps instances 
    embedder.useCandidateStepReporter(new PrintStreamCandidateStepReporter(System.out)); // defaults to System.out
    embedder.findMatchingCandidates("Given a step that I'm looking to match")

The result of the search would by default be output to console, e.g.:

Step 'When traders are subset to ".*y" by name' is matched by annotated methods:
When traders are subset to "%regex" by name
When traders are filtered by "%regex"
org.jbehave.examples.trader.TraderSteps.subsetTradersByName(java.lang.String)
from steps instances:
org.jbehave.examples.trader.TraderSteps
org.jbehave.examples.trader.BeforeAfterSteps

And if a match is not found:

Step 'Given a step that I'm looking to match' is not matched by any method
from steps instances:
org.jbehave.examples.trader.TraderSteps
org.jbehave.examples.trader.BeforeAfterSteps