Skip to content

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.

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是最关键的