This framework is developed using Behavior-Driven Development (BDD) principles with Cucumber and integrated with Serenity Reports. It is designed specifically for automating REST APIs, providing robust reporting and flexibility for handling API responses and requests.
- Enables writing human-readable test scenarios that bridge the gap between non-technical stakeholders and developers.
- Provides detailed, narrative-style test reports with test case histories and visual documentation.
- The framework allows passing response values from one API request to another. Simply reference the value using the $ symbol as "$key" to inject it into subsequent API requests dynamically.
Logs are configured at a high level, printing detailed information for each test scenario, including:
- Scenario name
- Duration
- Execution status (pass/fail)
- Failure cause or error (if any)
- The framework can push scenario execution details (status, duration, errors) into a database for further analysis and tracking.
- The Serenity reports are ideal for both User Acceptance Testing (UAT) and API automation. They present test results in a clear and easily understandable format, making them shareable with non-technical stakeholders.
- The framework is designed to run seamlessly in Jenkins pipelines. Serenity reports can be accessed and shared with business users, provided the tests are executed through a Jenkins pipeline.
- Java 17 or higher
- Maven 3.6v or higher
- Junit 5.0v or higher
- RestAssured 5.4.0v or higher
- Cucumber 7.16v or higher
- Serenity 4.1.4v or higher
In the pom.xml, we have configured serenity reports as well as single-page reports.
To build the project and download all dependencies, run the whole suite following Maven command:
mvn clean install
mvn clean install -Dcucumber.options="--features src/test/resources/features/placeValidations.feature"
mvn clean install -Dcucumber.options="--features src/test/resources/features/placeValidations.feature,src/test/resources/features/Example.feature"
mvn clean install -Dcucumber.options="--tags @Regression"
mvn clean install -Dcucumber.options="--features src/test/resources/features/placeValidations.feature --tags @Regression"
It is recommended to create a separate folder for storing test reports and generate a sub-folder with a time-stamp for each run in the Jenkins pipeline. This will keep your reports organized and traceable over time.
Use a Perl script to:
- Automatically create a new folder with a time-stamp
- Move the generated Serenity report files into this sub-folder after each test run
Invoke the Perl script as a Post-Build Action in your Jenkins pipeline, ensuring that the reports are properly archived after every execution.
Select "This project is parameterized" and set below parameters.
- For 1st parameter, select String parameter and set below details:
- Name: Features
- Default value: src/test/resources/features
- Description: -- Pass the features path here by separated coma (,). -- By default, it will pick up all features.
- For 2nd parameter, select choice parameter and set below details:
- Name: Tags
- Choices: Regression, Smoke, Sanity
- Description: -- Choose the tags. By default Regression
- For Root POM, give as "pom.xml"
- For Goals and Options, use the following command:
clean verify -Dcucumber.options="--features ${Features} --tags @${Tags}"
- Go to "Advanced" and check the "use custom workspace". Add project directory path.
Note: Add project path in the custom workspace field and Also remainings as per requirements.