Exercise 3: Behaviour Driven Development (BDD)
In this exercise, you are asked to try creating several tests into a BDD test suite using Cucumber and Serenity. You need to pull latest changes from the upstream Sitodo PMPL codebase into your fork repository. Then, continue working on your fork of Sitodo PMPL codebase and ensure the CI/CD pipeline is still in green condition/pass.
Tasks
- Pull the latest changes from the
main
branch of upstream Sitodo PMPL codebase to themain
branch of your fork. There are several changes in the codebase from the upstream, so it might be possible that a merge conflict will happen. - Modify the
base.url
property atsrc/test/resources/serenity.conf
to the URL where you deployed your own version of Sitodo app. To speed up the testing cycle during working on the exercise, you are allowed to set thebase.url
to the locally-running app atlocalhost
, and skip executing the existing test suites (i.e. unit and functional tests). - Execute the BDD test suite by running the
CucumberTestSuite
test suite class incom.example.sitodo.bdd
package by using IDE (IntelliJ), or execute the test suite by callingmvn verify
command in the shell. - Make sure the BDD test suite pass by checking the test report at
target/site/serenity/index.html
file. Currently, there is one test in the BDD test suite that verify if a user can add a new todo item into the list. - Add more tests into the BDD test suite that verify the following scenarios: (1.) A user is able to see the correct motivation message when the list is empty, (2.) A user is able to add a new todo item and mark it as completed immediately, and (3.) A user is able to see the correct motivation message when all items in the todo list are completed.
To accomplish these tasks, you may need to update the test code in
helpers
andstepdefinitions
packages.
- Run the BDD test suite again and make sure the tests pass. You are allowed to modify the production code to make your test code can properly obtain the correct reference to the elements in the page. For example, you can add new CSS class to an element in the page in order to make that particular element can be queried more conveniently from the functional and BDD test suite.
- (Optional) Update the CI/CD configuration of your project by adding a new CI stage after successful deployment that runs the BDD test suite against the deployed app.
In other words, the BDD test suite will run the scenarios by simulating user interactions to the actual deployed app.
You can achieve this by setting the
base.url
property in the Serenity configuration to the URL of your deployed app and set theheadless.mode
totrue
. Alternatively, you can utilise environment-specific configuration in Serenity so you can have configuration for running BDD test suite locally and on CI environment.
Deliverables
At the end of this exercise, you are required to prepare the following artifacts:
- The final version of Sitodo PMPL project in your fork, including the updated codes, test configuration, and CI/CD configuration.
- An example of working pipeline in the fork repository that shows the CI/CD pipeline successfully build, test, and deploy the application.
The due date of this exercise is: 2 December 2022, 23:55 UTC+7. Submit the URL of your fork repository to the designated submission slot on SCELE. Please ensure any updates to the fork repository related to this exercise were made and pushed before the due date.
References
Created: 2022-11-25 16:40:51