Variantes del patrón JBehave: tratando de hacer coincidir las alternativas

I have the following in my story that I am trying to match

!-- Block 1
When I "action" of document "document" to "status" and nextAction
When I "action" for document "document" to "status" and nextAction
When I "action" document "document" to "status" and nextAction
!-- Block 2
When I "action" of document "document" and nextAction
When I "action" for document "document" and nextAction
When I "action" document "document" and nextAction
!-- Block 3
When I "action" of document "document" to "status"
When I "action" for document "document" to "status"
When I "action" document "document" to "status"
!-- Block 4
When I "action" of document "document"
When I "action" for document "document"
When I "action" document "document"

Entre "acción" y documento puede haber of, por o vacio to "status" es opcional and nextAction es opcional

In the steps file I have the following

@When ("I \"$action\"{| of| for} document \"$document\"{ to \"$status\"|}{ and $nextAction|}")

This is matching blocks 1 and 2 but not blocks 3 and 4 from the story file.

Can you give me some pointers as to how I need to amend the steps file to be able to match all 4 blocks?

I have tried adding aliases with the to status and the and next action removed however JBehave errors with a duplicate candidate steps error.


preguntado el 03 de mayo de 12 a las 14:05

1 Respuestas

If the only variation is the 2x2 grid of options on (to "status") included or not and (nextAction) included or not - then I would just have the 4 annotated methods with the "of|for" variant. Then have all those methods call into the one method (unannotated).

That will be much cleaner than using variants to include/exclude whole phrases.

Also most of the JBehave folks don't watch StackOverflow so I'd ask the user list as well.

contestado el 09 de mayo de 12 a las 22:05

Thank you. I have had to create multiple annotations elsewhere that call into the same function further along. - Gazen Ganados

Sorry Brian, you said that I should also ask the user list if I have any further questions. Can you let me know how I do that. Thanks - Gazen Ganados

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.