An annotation is a type of text that has been pre-defined and has a specified meaning. It tells the compiler/interpreter what to do when the program runs. The annotations on Cucumber are as follows:
- Given: It specifies the requirements for running the test.
Example: Given I have an account on Interviewbit.
- When: It establishes the starting point for any test scenario.
Example: When I log in to Interviewbit.
- Then: It contains the expected result of the test which is to be executed.
Example: Then registration should be successful.
- And: Between any two statements, it gives the logical AND condition. AND can be combined with the GIVEN, WHEN, and THEN statements.
Example: When I enter my account number AND CVV.
- But: It denotes a logical OR relationship between two propositions. OR can be combined with the GIVEN, WHEN, and THEN statements.
Example: Then I should be logged in BUT I must enter the OTP.