Details
Description
To get more natural German story texts, it would be very helpful if the Steps.listCandidates() method could be amended.
This would allow for automatically generating slight variations of the texts without having to specify them all as aliases. Currently I am doing this:
@Then("soll foo bar with $xyz")
@Aliases(values =
)
The word "soll" is made optional this way. The reasoning behind this is that when using "And" it is more natural to write
Then soll something else
And foo bar with $xyz
instead of
Then soll something else
And soll foo bar with $xyz
It would be very nice to not have define aliases for all these variants, because it makes the code harder to maintain. Instead, I though I'd add this dynamically, the same way annotated Aliases are, but it seems this functionality would require providing a new subclass of org.jbehave.core.steps.Steps which I cannot see how to do.
I suggest a change like this:
1) In org.jbehave.core.steps.Steps add another call in listCandidates() after each of the addCandidatesFromAliases(...) like addCustomDerivedCandidates(...) with the same signature and a protected empty default implementation.
2) Allow configuration to specify a custom subclass of org.jbehave.core.steps.Steps. In there custom additions to the candidates list could be made, like the one I described.
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | Steps.java [ 58482 ] |
Attachment | Steps.java [ 58496 ] |
Attachment | jbehave-702-1.zip [ 58559 ] |
Summary | Allow injection of the "Steps" class to customize its behavior | Allow directives to support multiple step pattern variant |
Issue Type | Improvement [ 4 ] | New Feature [ 2 ] |
Fix Version/s | 3.6 [ 17721 ] |
Assignee | Mauro Talevi [ maurotalevi ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Hi Daniel, not very clear how your "dynamical" approach would work and how generic this solution would be. Can you provide an example of your proposed addCustomDerivedCandidates().
In general, I think subclassing steps is not a good solution as it mixes declaration and implementation.
If there is a need, we can enhance the declarative functionality, either via modifying the @Aliases annotation or providing a new one.