Skip to content

Conversation

cmccarthyIrl
Copy link
Owner

@cmccarthyIrl cmccarthyIrl commented Jul 13, 2025

Summary of Changes

The changes include significant improvements to the Spring Cucumber TestNG parallel test harness:

🔧 GitHub Actions Workflow Updates (run.yml)

  • Enhanced CI/CD Pipeline: Updated from single OS to matrix strategy with multiple OS versions
  • Concurrency Control: Added automatic cancellation of previous runs on new commits
  • Browser Management: Improved Chrome setup using dedicated browser actions
  • Environment Validation: Added comprehensive environment checks
  • Artifact Management: Enhanced test report and screenshot upload with proper retention policies
  • Resource Cleanup: Added proper cleanup of background processes

📦 Dependency Updates (pom.xml)

  • Spring Boot: Upgraded from 3.5.0 to 3.5.3
  • Cucumber: Updated from 7.22.0 to 7.25.0
  • Logback: Updated from 1.5.13 to 1.5.18
  • AssertJ: Updated from 3.23.1 to 3.26.0
  • Maven Plugins: Updated remote resources plugin from 1.7.0 to 3.1.0
  • New Dependencies: Added Jackson 2.19.0, Jakarta Annotations 3.0.0, Awaitility 4.3.0

🏗️ New Configuration System

  • TestConfiguration Class: New centralized configuration management with properties for:
    • Parallel execution settings
    • API configuration (timeouts, retries)
    • UI configuration (headless mode, window size, timeouts)
  • Enhanced Properties: New application properties for comprehensive test configuration

🔄 Service Layer Improvements

  • RestService: Enhanced with retry mechanisms, configurable timeouts, and better error handling
  • WeatherService: Added proper request specification handling
  • Application Properties: Simplified with Lombok annotations

🧪 Test Infrastructure Enhancements

  • Driver Management:
    • Configurable headless/headed mode
    • Dynamic window sizing
    • Improved remote driver setup
    • Better resource cleanup
  • Parallel Execution: Enhanced TestNG suite configuration for better parallel test execution
  • Retry Logic: Improved retry mechanisms with proper spacing and formatting

🧹 Code Quality Improvements

  • Modern Java: Replaced traditional switch statements with modern switch expressions
  • Security: Enhanced random string generation with SecureRandom
  • Lombok Integration: Reduced boilerplate code with proper getter/setter annotations
  • Error Handling: Better exception handling and logging throughout

🗑️ Cleanup

  • Removed Legacy Scripts: Deleted old driver download scripts
  • Code Formatting: Fixed spacing and formatting issues in retry annotations

📊 Testing Improvements

  • Suite Configuration: Updated TestNG suites with better parallel execution settings
  • Hook Management: Streamlined test hooks and scenario management
  • Driver Lifecycle: Improved WebDriver creation, management, and cleanup

@cmccarthyIrl cmccarthyIrl requested review from Copilot and removed request for Copilot July 13, 2025 07:37
@cmccarthyIrl cmccarthyIrl merged commit 1ec2ede into master Jul 13, 2025
2 checks passed
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the CI/CD pipeline, updates core dependencies, and introduces a centralized test configuration system to improve parallel test execution, retry logic, and resource cleanup.

  • Updated GitHub Actions for matrix builds, caching, environment validation, artifact retention, and cleanup.
  • Centralized test settings via a new TestConfiguration class and applied across driver management and REST services.
  • Upgraded key dependencies (Spring Boot, Cucumber, Logback, AssertJ) and added Jackson, Jakarta Annotations, and Awaitility.

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wikipedia/src/test/resources/suite/WikipediaSuiteTest.xml Updated suite name, enabled parallel methods execution, renamed test.
wikipedia/src/test/java/com/cmccarthy/ui/utils/DriverWait.java Added suppression for unused warnings.
wikipedia/src/test/java/com/cmccarthy/ui/utils/DriverManager.java Injected TestConfiguration, managed headless mode, window sizing, and cleanup.
wikipedia/src/test/java/com/cmccarthy/ui/step/Hooks.java Simplified driver teardown by calling quitDriver().
wikipedia/src/test/java/com/cmccarthy/ui/config/WikipediaContextConfiguration.java Reformatted @ComponentScan for clarity.
weather/src/test/resources/suite/WeatherSuiteTest.xml Updated suite name, enabled parallel methods execution, renamed test.
weather/src/test/java/com/cmccarthy/api/service/WeatherService.java Refactored to use retry-enabled REST calls via RestService.
pom.xml Bumped Spring Boot, Cucumber, Logback, AssertJ, Maven plugin versions; added new dependencies.
common/src/main/resources/downloadDriver.sh Removed legacy driver-download script.
common/src/main/resources/application-headless-github.properties Added comprehensive test, API, and UI configuration properties.
common/src/main/java/com/cmccarthy/common/utils/StringUtil.java Replaced Apache utility with secure random string generators.
common/src/main/java/com/cmccarthy/common/utils/DateTimeUtil.java Switched legacy switch to modern switch expressions.
common/src/main/java/com/cmccarthy/common/utils/Constants.java Removed obsolete driver and resource directory constants.
common/src/main/java/com/cmccarthy/common/utils/ApplicationProperties.java Added Lombok getters and cleaned up manual getters/setters.
common/src/main/java/com/cmccarthy/common/service/RestService.java Introduced configurable RestAssured settings, retry logic, and HTTP methods.
common/src/main/java/com/cmccarthy/common/config/TestConfiguration.java Added centralized test configuration with nested classes for API, UI, and parallel settings.
.github/workflows/run.yml Enhanced CI workflow with matrix strategy, caching, concurrency control, and cleanup.
Comments suppressed due to low confidence (1)

.github/workflows/run.yml:10

  • The concurrency block appears indented under on; it should be a top-level key in the workflow, not nested under on, to take effect.
concurrency:

Comment on lines +6 to +10
import org.springframework.context.annotation.Configuration;

@Setter
@Getter
@Configuration
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spring Boot may not bind @ConfigurationProperties on a scanned @Configuration class without enabling it; consider adding @EnableConfigurationProperties(TestConfiguration.class) in your test context or using @ConfigurationPropertiesScan.

Suggested change
import org.springframework.context.annotation.Configuration;
@Setter
@Getter
@Configuration
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@Setter
@Getter
@Configuration
@EnableConfigurationProperties(TestConfiguration.class)

Copilot uses AI. Check for mistakes.

.get(applicationProperties.getWeatherAppUrl());

final RequestSpecification requestSpecification = restService.getRequestSpecification().param("q", location)
.param("appid", "0a1b11f110d4b6cd43181d23d724cb94");
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API key is hard-coded in the test service; consider externalizing it into application.properties or TestConfiguration to avoid leaking credentials.

Copilot uses AI. Check for mistakes.

public void setLocalWebDriver() throws IOException {
switch (applicationProperties.getBrowser()) {
public void setLocalWebDriver() {
String browser = applicationProperties.getBrowser();
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browser is read from ApplicationProperties but there’s a defaultBrowser in TestConfiguration; consider using testConfig.getDefaultBrowser() for consistency.

Suggested change
String browser = applicationProperties.getBrowser();
String browser = testConfig.getDefaultBrowser();

Copilot uses AI. Check for mistakes.

.accept("application/json");
}

@Retryable(value = {Exception.class}, maxAttempts = 3, backoff = @Backoff(delay = 1000))
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry maxAttempts is hard-coded to 3; consider using testConfiguration.getApi().getMaxRetries() to keep retry settings in sync with the centralized configuration.

Suggested change
@Retryable(value = {Exception.class}, maxAttempts = 3, backoff = @Backoff(delay = 1000))
@Retryable(value = {Exception.class}, maxAttemptsExpression = "#{@restService.getMaxAttempts()}", backoff = @Backoff(delay = 1000))

Copilot uses AI. Check for mistakes.

Comment on lines +55 to +58
for (int i = 0; i < length; i++) {
int digit = ThreadLocalRandom.current().nextInt(min, max + 1) % 10;
sb.append(digit);
}
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using % 10 after nextInt(min, max + 1) is redundant and could introduce bias; you can directly bound the random digit with ThreadLocalRandom.current().nextInt(0,10) or between min and max without modulo.

Suggested change
for (int i = 0; i < length; i++) {
int digit = ThreadLocalRandom.current().nextInt(min, max + 1) % 10;
sb.append(digit);
}
for (int i = 0; i < length; i++) {
int digit = ThreadLocalRandom.current().nextInt(min, max + 1);
sb.append(digit);
}

Copilot uses AI. Check for mistakes.

@cmccarthyIrl cmccarthyIrl deleted the feature/wip branch July 16, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant