I know this an old question, but I have found a solution for this, and I share for the community :
'!-- ' is the sign for cancellable step, means steps that need to be disabled.
In our project, we use a story Parser :
this.currentConf.useStoryParser(new TransformingStoryParser(this.currentConf.storyParser(), this.transformComment, this.transformCutter));
We needed to put documentation in user stories, so we made a difference between comments and cancellable steps :
!-- Then ...
=> Cancellable steps (native way)
!--| This is a a comment...
=> Comment
With the transformer, comments are stripped from the story before it is executed.
This is the same for '|--', a cancellable example. We have introduced '|--|', or a 'cutter' to prevent the rest of the story to be executed.
The classes (this.transformComment, this.transformCutter) :
public class ParserTransformingComment implements StoryTransformer {
public ParserTransformingComment() {
}
/**
* Suppression de commentaires
*/
private Rewriter vC = new Rewriter("(?ms)^((!--\\|[^\\r\\n]*)(?:\\r?\\n)?)") {
@Override
public String replacement() {
System.out.println("Ignoré : " + this.group(1));
return "";
}
};
@Override
public String transform(String pStoryAsText) {
return vC.rewrite(pStoryAsText);
}
}
public class ParserTransformingCutter implements StoryTransformer {
public ParserTransformingCutter() {
}
/**
* Gestion des 'cutter'.
*/
private Rewriter vS = new Rewriter("(?ms)^(\\|--\\|.*)") {
@Override
public String replacement() {
System.out.println(">>> Cette section va être ignorée : ");
System.out.println(StringUtils.lineStart("> ",this.group(1)));
System.out.println("-------------");
return "";
}
};
@Override
public String transform(String pStoryAsText) {
return vS.rewrite(pStoryAsText);
}
}
EDIT:
As of Jbehave 4.3, comments are handled in a better way, even without StoryTransformer :
!--BlahBlah -- ignored completely by Jbehave
!-- Then ... -- steps ignored (registered in the report)
!-- Blah blah -- comment (registered in the report)
Regards,
David C.