Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto generate candidate-step method stubs from stext scenarios in JBehave

Tags:

bdd

jbehave

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.

like image 476
Bhuvnesh Pratap Avatar asked Jan 04 '12 07:01

Bhuvnesh Pratap


1 Answers

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.)

like image 133
dertseha Avatar answered Oct 20 '22 14:10

dertseha