Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which BDD framework allows a simplistic approach to "story writing"? [closed]

I'm trying to use BDD in a very simple way, in order to minimize the amount of Java code. I want to create exactly two files, one is my story:

Given user is named "John Doe" 
And user is authenticated
When user changes his password to "a1b2c3"
Then user password equals to "a1b2c3"

Next, I create a Java class:

public class UserManipulator {
  @Given("$user is named $name")
  public User shouldExistOrBeCreated(String name) {
    User user = //...
    return user;
  }
  @Given("$user is authenticated")
  public void shouldBeLoggedIn() {
    // ...
  }
  @When("$user changes his password to $pwd")
  public void shouldChangePassword(User user, String pwd) {
    // ...
  }
  @Then("$user password equals to $pwd")
  public void shouldHaveThisPassword(User user, String pwd) {
    assertEquals(user.getPassword(), pwd);
  }
}

And that's it. I don't want to have any more files, any more unit tests. I want some BDD-framework to find my story file, parse all my Java files, and run them one by one. Is it possible to achieve?

ps. What is important here is a possible reuse of Java methods in my other stories. For example, this is the story no.2:

Given user is named "Michael Doe"   <-- reuse
When user adds $100.00 to his account
Then user account balance is $100.00
like image 961
yegor256 Avatar asked Oct 08 '10 12:10

yegor256


People also ask

What are the advantages of BDD framework in software development?

Every resource in the software development phase can contribute to the BDD framework. Due to its easy concept of layman text in the form of feature file allows the stakeholders of technical resources to write the scenarios in Gherkin language using the user stories. The compatibility of the plain text helps to gain maximum coverage on testing.

What is the difference between a user story and a BDD?

A user story has a slightly different structure to your BDD. Your user story should comprise the following: As a new user (John), I can register a new account on the homepage so that I can access LinkedIn. If you have multiple scenarios, you’d add these after Scenario 1 in a sequence.

How should I structure my BDD scenarios?

Your BDD scenarios should form part of 1 specification. This includes both the user story and the scenarios. So, for example, if you’re writing a user story in Jira or some other beloved backlog management tool you could structure your specification in Jira in the following order:

What is BDD and how does it work?

Using Scenarios – BDD is designed to speed up the development process. Everyone involved in development relies upon the same scenarios. Scenarios are requirements, acceptance criteria, test cases, and test scripts all in one; there is no need to write any other artifact.


1 Answers

You want to have a look at:

  • easyb,
  • or JBehave ant its Getting Started guide,
  • and maybe Specatular and its Getting Started guide.

Also, this presentation on BDD in Java and Groovy could be of interest.

like image 198
haylem Avatar answered Jan 11 '23 23:01

haylem