7

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?

Martin
  • 3,018
  • 1
  • 26
  • 45
  • Can you provide a [SSCCE](http://www.sscce.org/) with the `@Given`, `@When`, and `@Then` annotated methods necessary to run your BDD scenario and reproduce the behavior you observe? – William Price May 14 '14 at 08:35
  • I would have to upload the whole workspace. I will see if I can build a "smaller" one that replicates the error. I don't know if I can "reopen" the bounty then, but I will try... – Martin May 15 '14 at 07:17
  • It would cost you another -100 rep to offer another bounty. It's your choice, but I'll try to help regardless. I've been using JBehave with sequences of `And ...` and it's been working for me, so I'm curious about your case. – William Price May 15 '14 at 17:00

3 Answers3

0

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.

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24
0

It is ridiculous but this caused PENDING step to me:

When app with ...
And  app with ...

Notice that extra space after And

lukyer
  • 7,595
  • 3
  • 37
  • 31
0

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.

WesternGun
  • 11,303
  • 6
  • 88
  • 157