DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

Writing Tests in Plain English

原文链接

Gherkin language

Feature files are written in a “behavior-driven” style

When everyone understands our user stories, we waste less time in the production process and have fewer instances where we redo the work we’ve done.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Feature: 	Update credit card

Description: As a customer care advocate, I want to update a customer’s credit card on file, so that the customer’s new credit card will be charged during the next billing cycle.

Scenario: Change credit card with a valid credit card

Given: I have a customer with an existing credit card.
When: I enter a new valid credit card number.
Then: The service request is processed successfully.
And: I can see that the customer’s new card is on file.

Scenario: Change credit card with an invalid credit card number

Given: I have a customer with an existing credit card.
When: I enter a new credit card number that is not valid.
Then: An error shows that the credit card number is not valid.

The test runner parses the feature file, figures out which JavaScript functions to run and reports back.

document是最关键的