Donate : Link

WordPress Blog : Link

Applications… : Link

Cucumber Tutorial Index Page: Link

Annotation is a predefined text, which holds a specific meaning. It lets the compiler/interpreter know, what should be done upon execution. Cucumber has got the following few annotations −

Given

  • It specifies pre-condition. It is basically a known state.
  • Example — User navigate to xyz.com

When

  • This is used when some actions to be performed.
  • Example — User enter valid id “user1” and psw “user1”

Then

  • The expected outcome or result should be placed here.
  • Example — Login should be successful

And

  • And is used to continue to combine two or more steps same type of actions.
  • Sample feature file:

But

  • It signifies logical OR condition between any two statements. OR can be used in conjunction with GIVEN, WHEN and THEN statement.
  • Example − THEN login should be successful. BUT home page should not be missing.

Scenario

  • Basically a scenario presents a particular functionality which is under test.
  • By seeing the scenario user should be able to understand the intent behind the scenario and what the test is all about.
  • Each scenario should follow Given, When, Then format. This language is called as “Gherkin”.

Scenario Outline

  • TO BE COVERED LATER

Examples

  • TO BE COVERED LATER

Background

  • Whenever any step is required to perform in each scenario then those steps need to be placed in background.
  • Sample feature file: