Skip to content

Writing Cypress Test Scenarios

Paulo Gomes da Cruz Junior edited this page Jun 16, 2026 · 3 revisions

Writing Test Scenarios

This guide is intended for anyone — technical or not — who wants to write end-to-end test scenarios for the application. No coding experience is required.

What is Cucumber/Gherkin?

Cucumber is a popular tool used for behavior-driven development (BDD) in software testing. It allows you to write executable specifications in a natural language format called Gherkin. Gherkin is a plain-text language that is easy to understand and can be used by non-technical stakeholders as well.

To learn more about Cucumber, Gherkin and BDD, you can enroll on a free course.

In summary, Gherkin is a writing format that leverages plain English to allow users to describe the expected behavior in simple steps that are easy to understand by non-technical persons, but also make sense to be executed in that specific order. Think of it like a set of steps in a cake recipe.

Submitting a test via GitHub Issues

To make things easier for non-technical team members, we developed a strategy to leverage the use of GitHub issues, something that is quite similar to Jira tickets.

  1. Click on New issue.
  2. From the list of issue types, select User provided automated test-case.
  3. Fill out the form following the instructions provided.

The issue will be automatically converted to a .feature file that will be used for testing.

Note

Pay attention to the format of the test description. Gherkin feature files are sensitive to spacing and the keywords are really picky when it comes to casing (uppercase vs. lowercase).

Creating a Feature

Every test group is called a Feature in Gherkin. It will have a meaningful name and can include a short description of what you are testing:

Feature: User Registration
  As a new user I want to register on the website so that I can access exclusive content

Note

The description should be indented one level deeper than the Feature keyword. You can use a tab or two spaces.

Creating Scenarios

Scenarios represent specific test cases. Each scenario consists of a series of steps. Steps can be one of the following: Given, When, Then, And, or But.

Scenario: Successful user registration
  Given I am on the registration page
  When I fill in the registration form with valid information
  And I click the "Register" button
  Then I should see a success message

Note

Each step should be indented one level deeper than the Scenario keyword, and the scenario itself should be at least one level deeper than the Feature above it.

Full example

Feature: User Registration
  As a new user I want to register on the website so that I can access exclusive content

  Scenario: Successful user registration
    Given I am on the registration page
    When I fill in the registration form with valid information
    And I click the "Register" button
    Then I should see a success message

Congratulations! You have successfully written a basic Cucumber/Gherkin end-to-end test. You can continue adding more scenarios to cover different test cases in the application.

Remember, the power of Cucumber lies in its ability to bridge the communication gap between technical and non-technical team members, enabling collaboration and providing a common language for defining software behavior.

Authentication annotations

Some scenarios require authentication. Instead of writing login steps manually, use an annotation directly above the Scenario keyword. The annotation will handle the full login flow and leave the browser on the expected page.

@loginAsIDIR
Scenario: Submit individuals
  When I click on the "Create client" button
  And I can read "Create client"

The @ symbol is required before the instruction, and it should be placed right above the Scenario keyword.

Annotation Description
@loginAsBCeID Log in as a BCeID user type
@loginAsIDIR Log in as an IDIR user type

Note

The authentication hooks require credentials to be set via environment variables (idir_username, idir_password, bceid_username, bceid_password). See the Developer Guide for setup details.

Next steps

  • See the Step Reference for the full list of ready-to-use step instructions.
  • Developers can check the Developer Guide for setup and implementation details.

Waste Plus Wiki

Home

Architecture

Codes

Decisions

Knowledge Base

Development

Changes

Clone this wiki locally