Repository navigation
Writing Cypress 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.
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.
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.
- Click on New issue.
- From the list of issue types, select User provided automated test-case.
- 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).
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 contentNote
The description should be indented one level deeper than the Feature keyword. You can use a tab or two spaces.
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 messageNote
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.
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 messageCongratulations! 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.
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.
- 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.
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository