?????????BDD??Behavior Driven Development?????????????????????????????Cucumber?????????????д????????????????????????????????????????BDD??ATDD(Acceptance test driven development)?????????????????BDD??????????????????????????????????????????????BDD??
????????BDD??
????“??????????????????????????????” (“The hardest single part of building a software system is deciding precisely what to build” — No Silver Bullet?? Fred Brooks) ??
????????????????????????????????????????д?????????????????????????????????????????????sign off?????????????????????????????в??
?????????????????????????????????????????????????????????????????????????????????????????
??????Щ?????????????????????????????????????????????????????????????????????????????????′?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????μ??????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????1????????????????????????ν?????BDD????????????
????BDD??????
????BDD???????Dan North???BDD????????????????????ó??????????д???????????????????????ó?????????????????????е?????????????
???????BDD???????????????????????????????????????????????????????
?????????????????????????????BDD?????????????????DSL?? domain specific language?????????????????????????????????????????????
??????????????????????Э???????BDD?????????????????????????????壬???????????????????
????????????????BDD???TDD???????????????????????????Э??????????????????????????
??????????????BDD?????????н??????????????????????и???Э??????????????м????????
????BDD???????
?????????????????????“GIVEN… WHEN… THEN… ”??????????????????????д??????????????????????????????????????????ο???
????1.???????????????????
????????????????????????????????????????У??????????????????????????????????????????????????漰?κ???????????????????????????????????????????????????????????
????2.????????????????????
???????????????????????????????????????ü????????????????????????????????????????????????????????????????????????Щì????????????????BDD??????????????????????У?GIVEN???????????????????????????????????????????????????WHEN???????????????????????????????????????????????????????THEN?????“???…(should be…)”?????????????????????????????assert???????????????????????
????3.???????????????????
????????????????????????????????????????????????????????2??????????????????????????????????????????????????????????????????????????????????????????????????????о????????????????????????????????????????????????????????????????????????????????????????????????????????????Щ?????????棬????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????£?
?????????????????????????????????????????????????????????????????????
????Scenario: Check Inbox
????Given a user "Tom" with password "123"
????And a user "Jerry" with password "abc"
????And an email to "Tom" from "Jerry"
????When I sign in as "Tom" with password "123"
????Then I should see one email from "Jerry" in my inbox
????Scenario: Check Inbox
????Given a user "Tom"
????And a user "Jerry"
????And an email to "Tom" from "Jerry"
????When I sign in as "Tom"
????Then I should see one email from "Jerry" in my inbox
????Scenario: Check Inbox
????Given I have received an email from "Jerry"
????When I sign in
????Then I should see one email from "Jerry" in my inbox
????????????????????????Щ?????????BDD???????What???????????????How?????????д????á?
????Scenario: Redirect user to originally requested page after logging in
????Given a user "Tom" exists with password "123"
????And I am not logged in
????When I navigate to the home page
????Then I am redirected to the login form
????When I fill in "Username" with "tom"
????And I fill in "Password" with "123"
????And I press "Login"
????Then I should be on the home page
????Scenario: Redirect user to originally requested page after logging in
????Given I am an unauthenticated user
????When I attempt to view some restricted content
????Then I am shown a login form
????When I authenticate with valid credentials
????Then I should be shown the restricted content
?????????????????鵽?????????????
????Scenario: Books add to shopping cart with correct number and total price
????Given a book "BDD" with price "30.5"
????And a book "Cucumber" with price "25.8"
????When I select "BDD"
????And I click the add to shopping cart button
????Then I should see one "BDD" in my shopping cart
????And the total price is "30.5"
????When I select "Cucumber"
????And I click the add to shopping cart button twice
????Then I should see two books "Cucumber" in my shopping cart
????And the total price is "82.1"
????Scenario Outline: Books add to shopping cart with correct number and total price
????Given book <name1> with <price1>
????And book <name2> with <price2>
????When I add <number1> book <name1> and <number2> book <name2> to shopping cart
????Then I should see book <name1> and <name2> in my shopping cart
????And the total price should be <total>
????Examples:
????| name1    | price1 | number1 | name2    | price2 | number2 | total |
????| BDD      | 30.5   | 1       | -        | -      | -       | 30.5  |
????| Cucumber | 25.8   | 2       | -        | -      | -       | 51.6  |
????| BDD      | 30.5   | 1       | Cucumber | 25.8   | 2       | 82.1  |
????BDD???????Cucumber??JBehave??Twist??Concordion????????????????÷???????????з????????ο??????????????