How cmccarthyirl/spring-cucumber-testng-parallel-test-harness works
Main Components
• Common Module: Acts as the shared library for the entire framework. It contains utility classes (for string manipulation, date/time, logging, and custom event evaluation), service classes (e.g., for REST calls), property configuration (various application-*.properties files), and resource files (XML/Extent configuration, demo screenshots). It is the backbone where the central configuration (like the “FrameworkContextConfiguration” class) is defined.
• Weather Module: Focused on API tests, this module uses Rest Assured to test weather-related API endpoints. It includes test runners (WeatherRunnerTest), configuration classes, API models (POJO classes like Clouds.java, Coord.java, etc.), and service classes to interact with API endpoints.
• Wikipedia Module: Focused on UI tests, this module leverages Selenium WebDriver. It has its own test runner (WikipediaParallelRunnerTest), page objects (e.g., AbstractPage, WikipediaHomePage), UI step definitions, and driver management utilities (DriverHelper, DriverManager, etc.). It also includes custom expected conditions that help drive UI interactions.
Relationships and Interactions
• Test Execution: At runtime, TestNG (via dedicated test runner classes in both weather and wikipedia modules) directs the tests. Test classes are annotated with Cucumber options so that feature files are executed.
• Step Definitions and Hooks: Step definitions (within packages such as “api/step” or “ui/step”) implement test behavior using Cucumber and are hooked into Spring Boot Test via the “FrameworkContextConfiguration”. Hooks (in the “Hooks.java” classes) are used for “before” and “after” test run operations—like driver initialization and logging.
• Dependency Injection & Shared Services: The Spring context loaded from common configuration allows shared utilities and service classes (from the common module) to be available to both API and UI test modules.
• Reporting & Logging: Throughout the test execution, results are logged (using LogManager and external logging libraries) and captured by reporting tools such as Allure and Extent Reports.
Architectural Patterns and Design Principles
• Modular Design: The separation into common, weather, and wikipedia modules reinforces a modular architecture, which simplifies maintenance and scalability.
• BDD (Behavior Driven Development): Using Cucumber, tests are written in natural language feature files that are then mapped to Java step definitions.
• Separation of Concerns: API tests (weather) and UI tests (wikipedia) keep responsibilities separate while sharing common services and configuration.
• Dependency Injection: The use of Spring Boot Test with its context configuration highlights dependency inversion and loose coupling across modules.