How serenity-bdd/serenity-rest-starter works
Main Components
• Maven Build System: Represented by the pom.xml, which handles project dependencies and build orchestration.
• Serenity BDD Configuration: This includes serenity.properties and serenity.conf files that configure and control the Serenity framework.
• Test Runner/Execution: Mark the central test suite file (CucumberTestSuite.java) that orchestrates the test execution.
• Step Definitions: Include the step definitions package (e.g., starter/postcodes/PostCodeStepDefinitions.java) which links Gherkin steps to Java method implementations.
• Feature Files: Represent the Gherkin feature files (located in src/test/resources/features/postcodes/looking_up_post_codes.feature) that describe test scenarios in a human-readable format.
• REST API Client Components: Illustrate the API client classes (for example, PostCodeAPI.java and LocationResponse.java) that encapsulate API calls and response handling.
• Additional Libraries/Frameworks: Call out the use of Cucumber 6 for BDD, Serenity for reporting and test management, and RestAssured for forming REST calls.
Out the Relationships and Interactions
• The Cucumber feature files are consumed by the Cucumber test runner (invoked via CucumberTestSuite.java).
• Step definitions, in turn, interact with the REST API client classes to issue HTTP requests using RestAssured.
• The responses and test results are handled and reported using Serenity BDD, with configuration details drawn from the serenity.properties and serenity.conf files.
• Logging is configured via logback-test.xml to capture runtime details.
Architectural Patterns and Principles
• Separation of Concerns: Each component has a clear responsibility (test definitions, API interactions, configuration, build management).
• Layered Approach: The tests are structured in a layer where the feature files describe scenarios, step definitions handle test logic, and API client classes manage external interactions.
Relevant Technologies and Frameworks
• Maven (pom.xml) – project build and dependency management.
• Serenity BDD – for test execution reporting and advanced BDD practices.
• Cucumber 6 – for writing feature files and orchestrating BDD test scenarios.
• RestAssured – for sending HTTP REST requests and verifying responses.
• Logback (logback-test.xml) – for logging purposes.
• From here, show the branching into two main paths: one side for “Test Scenario Definition” (feature files) and the other side for “Test Implementation” (step definitions and API client calls).
• Reporting/feedback loop from Serenity at the end of the flow to indicate how test outcomes are captured and reported.