Best BDD Techniques for Designing Cucumber Scripts for Forms

Let's say you have a form that creates a new user. How do you write a cucumber script?

1).

Given I am logged in as admin
When I create a new user
Then I should see "Successfully created user"

2.)

Given I am logged in as admin
When I go to Create new user
And I fill in "Name" with "Name111"
And I fill in "Password" with "Password111"
And I press "Create new user"
Then I should see "Successfully created user"

If you choose 1.), where you document the requirements for the user (the user must have a username and password). I see that BDD is a behavior, but at some point you and the interested party must specify what properties the user should have, right?

I am very new to BDD, so I appreciate any advice ...

+5
source share
3 answers

You must read Imperative versus declarative scenarios .

- Aslak. The creator of the cucumber.

+13

, , . , , / . , , .

, , , . :

Given Fred is logged in
When Fred <does something>
Then Fred should <get some really differentiating value>
And <something else happens>

, . :

Given there is already a question on BDD and Cucumber
Given Peyote is logged in
When Peyote proposes a question on BDD and Cucumber
Then Peyote should see other questions on BDD and Cucumber.

" ", , . .

. BDD , , , , , , , . - .

, , , - , BDD ATDD ( ). , , , , , , , , , SetUp, TearDown, Act, Arrange, Assert - , BAs .

, BDD!

+2

Or one will work. With # 1, you will create a step to submit form filling. I prefer hybrid # 1 and # 2 because I often use script schemes, for example:

Background: 
 Given the following users exist:
   | email             | password        |
   | test@example.com  | testpassword23  |
   | test2@example.com | notthistime     |
   | test3@example.com | welcomeback     |

  @login @authentication
  Scenario Outline: Authentication
     Given I am on the new user session page
     When I login with "<s_email>" and "<s_password>"
     And I press "Login"
     Then I should see "<s_message>"

  Examples:
    | s_email           | s_password       | s_message                      |
    | test@example.com  | testpassword23   | Signed in successfully         |
    | test2@example.com | itriedreallyhard | Invalid email or password.     |
    | teOst@example.com | testpassword23   | Invalid email or password.     |
+1
source

All Articles