Reputation: 3058
So,
I am having a strange behaviour with JBehave. I have a Scenario where I need a StepDef structure like the following:
Given some precondition
When something happens
And something else happens
And yet something else happens
And still one more thing happens
And one more
Then I expect some result
As far as I know, this is a valid syntax for a Scenario Stepdefinition. However, JBehave marks everything from the second "And" as "Pending". If I change the order of the "And" statements, it always runs the first "And" and marks "Pending" starting with the third. If I write it like this it works fine:
Given some precondition
When something happens
When something else happens
When yet something else happens
When still one more thing happens
When one more
Then I expect some result
It seems as if my configuration is limiting the amount of consecutive "And" statements that can be interpreted. However I don't seem to find the problem. What am I doing wrong here?
Upvotes: 7
Views: 5677
Reputation: 12728
I don't think you can use @And
. I don't find such annotation in the Java Library I use. I only see @When
, @Then
. JBehave official site suggests the same:
https://jbehave.org/reference/latest/annotations.html
Step Annotations
JBehave supports the following method step annotations:
@Given
@When
@Then
@Alias
@Aliases
@Pending
Because there isn't @And
but in your story you start a line with And
, it does not fine step definition and fails.
A step definitions only can be defined in a public void method annotated with these annotations. (Pending)
normally means your definition does not exactly match the usage in story file. Check every space/word/parameters in the method.
Upvotes: 0
Reputation: 7983
It is ridiculous but this caused PENDING step to me:
When app with ...
And app with ...
Notice that extra space after And
Upvotes: 0
Reputation: 2838
Lots of things can cause the "pending" message. I have seen hidden spaces (whitespace) cause the error when it's in the .story file but not in the corresponding steps file's method. If you have the second example story, with all "When" statements working, then take that exact story file and ONLY change the "When" 's to "And" 's (except the first one, of course). That would eliminate the possibility that it's whitespace. I assume you know that in either case, all the steps would start with @When("...") (just trying to eliminate all options). Just show us the method headers for each step listed above - we don't need to see the underlying code.
Upvotes: 0