Using BDD and Cucumber in Squash AUTOM
This page describes how to use BDD and Cucumber JVM: declaring Gherkin test cases, implementing the tests, and running them.
The target audience for this HOWTO is:
- The persons who want to have an overview of the whole process, they can go through the document, skipping the technical details.
- The persons who will be involved in such a process.
For the administration part, they should know the basics of Squash TM administration. Pointers toward precise instructions are provided.
For the test automation part, they should know the basics of Git, Java, and Maven. Some architecture and coding tips are provided. The code uses Selenium to interact with the browser.
Overview of the process
Setting the scene
We will see how a development team in charge of creating an e-commerce site will set up automated tests to validate the first functionalities delivered by the developers: account creation, login and filling the shopping cart. By mutual agreement, they decided to formalize the test cases in Gherkin in order to avoid ambiguities and to ensure the reuse of the test steps. The automatician will use the technologies she masters to save time.
We will use the following personas in this HOWTO:
- Pravash, the product owner for the project;
- Fabrice, the functional tester;
- Antonine, the automation programmer in charge of implementing the test cases defined by Fabrice;
- Annita, the Squash TM administrator.
The phases we will describe are:
Squash TM administrator
|Set up Squash TM|
|Write test cases|
|Transmit test cases|
|Get test cases|
|Automate test cases|
|Deliver automated test cases|
|Indicate automation is performed|
|Run automated tests|
(You can click a phase to access it directly.)
Some initial remarks
This example describes how to perform User Interface tests. Their goal is to verify that the UI behaves properly, not to check that user workflows are handled as expected (e.g. that an order is properly generated and recorded in the order database).
That workflows should be tested at the service level, by calling the Web Service API (SOAP, REST, GraphQL…) of the SUT. Web Services tend to be much more stable that the UI, so the maintenance cost is lower for Web Service tests than for UI tests. Web Service tests are also simpler and faster to write.
Currently, the HOWTO does not contain any Web Service tests.
Accessing the code
The code used in this HOWTO is available in https://gitlab.com/henixdevelopment/open-source/code-samples/howto-bdd-cucumber-01.
This HOWTO uses
- Squash TM 3.0.2
- Cucumber-JVM 7.2.3
- Selenium 4.1.1
- Java 11.0.13
- Maven 3.6.3
but its content is mostly applicable to any version of these, only some technical details will change if using another version of Squash TM, Cucumber, Java, or Maven.
Installing Prestashop as a SUT example
We need an example SUT for illustrating the BDD test lifecycle. For this purpose, we use the demo of Prestashop. If you want to reproduce the steps described in this document, this page describes how to install Prestashop.