6

I am using Jbehave as my BDD framework. I am looking for a way to auto generate candidate step method stubs from the text scenarios like

Given there is a flight
And there is a customer
When the customer books the flight
Then the customer is shown on the manifest

to Java like this:

<@> Given("there is a flight")
<a@> Pending
public void thereIsAFlight() {
}

<@> Given("there is a customer") // note 'Given', even though story line is 'And'
<@> Pending
public void thereIsACustomer() {
}

<@> When("the customer books the flight")
<@> Pending
public void theCustomerBooksTheFlight() {
}

<@> Then("the customer is shown on the flight manifest")
<@> Pending
public void thenTheCustomerIsShownOnTheFlightManifest() {
}

Does JBehave provide it as an implicit functionality or people use some IDE plugin ? I'll highly appreciate any help here.

Bhuvnesh Pratap
  • 437
  • 1
  • 5
  • 16

2 Answers2

5

When you run JBehave it traces all steps that haven't found a matching binding code and dumps corresponding stub implementations as well, quite similar to what you wrote. This output is available on the console but also in the HTML reports (should you have them turned on). Copy them and place them into your steps class(es).

If you're asking to have JBehave automatically write the stub implementations into the .java files, then I highly doubt that there exists such a feature - it would be difficult to know which steps class & file to use. (Next to SCM integration problems and so forth.)

dertseha
  • 1,086
  • 8
  • 11
  • 1
    This features exists for cucumber-jvm. I am thinking of switching engines due to a lack of support for a feature that should be part of any gold standard bdd testing engine. – Ajax Apr 10 '16 at 00:27
0

i use IntelliJBehave: https://github.com/kumaraman21/IntelliJBehave/wiki it will not generate method automatically, but it does let you some useful abilities such as: syntax highlighting, navigation from steps to methods, error highlighting and more.

Tidhar Klein Orbach
  • 2,896
  • 2
  • 30
  • 47