Skip to content

test: optimize edge case tests with parallel execution support#39

Merged
marevol merged 1 commit intomainfrom
test/optimize-edge-case-tests-parallel-execution
Jan 15, 2026
Merged

test: optimize edge case tests with parallel execution support#39
marevol merged 1 commit intomainfrom
test/optimize-edge-case-tests-parallel-execution

Conversation

@marevol
Copy link
Copy Markdown
Contributor

@marevol marevol commented Jan 15, 2026

Summary

  • Enable parallel test execution in maven-surefire-plugin to improve CI performance
  • Refactor PlaywrightClientEdgeCaseTest to use shared client and server instances
  • Fix shared worker cleanup bug in PlaywrightClient

Changes Made

  • pom.xml: Configure maven-surefire-plugin with parallel=classes, threadCount=4, and perCoreThreadCount=true
  • PlaywrightClient.java: Reset SHARED_WORKER to null when closing a shared worker instance, preventing stale references
  • PlaywrightClientEdgeCaseTest.java:
    • Add @BeforeAll to initialize shared client and server once per test class
    • Add @AfterAll to cleanup resources after all tests complete
    • Convert individual test methods from creating/destroying resources to using shared instances
    • Reduces test execution time and resource overhead significantly

Testing

  • All existing tests continue to pass
  • Test execution time reduced due to shared resource reuse

Breaking Changes

None

🤖 Generated with Claude Code

- Enable parallel test execution in maven-surefire-plugin (4 threads per core)
- Refactor PlaywrightClientEdgeCaseTest to use shared client and server
- Add @BeforeAll/@afterall lifecycle methods for resource sharing
- Fix shared worker cleanup in PlaywrightClient to reset SHARED_WORKER

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@marevol marevol requested a review from Copilot January 15, 2026 04:57
Copy link
Copy Markdown

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 optimizes test performance by enabling parallel test execution and refactoring edge case tests to use shared resources instead of creating new instances for each test method.

Changes:

  • Configured Maven Surefire plugin to run test classes in parallel with 4 threads per core
  • Fixed a resource cleanup bug where SHARED_WORKER wasn't reset when closing shared worker instances
  • Refactored PlaywrightClientEdgeCaseTest to use class-level shared client and server instances across all test methods

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pom.xml Added parallel execution configuration to maven-surefire-plugin
PlaywrightClient.java Fixed bug by resetting SHARED_WORKER to null when closing a shared worker instance
PlaywrightClientEdgeCaseTest.java Refactored to use @BeforeAll/@afterall with shared client and server instances instead of per-test initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +52
private static PlaywrightClient sharedClient;
private static CrawlerWebServer sharedServer;
private static File docRootDir;
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Shared static resources without synchronization may cause issues when tests run in parallel. Since maven-surefire-plugin is configured with parallel=classes, multiple test classes could run concurrently, and if this test class is instantiated multiple times or accessed concurrently, the shared resources could be accessed by multiple threads without proper synchronization.

Copilot uses AI. Check for mistakes.
@@ -285,35 +242,11 @@ protected Optional<MimeTypeHelper> getMimeTypeHelper() {
*/
@Test
public void test_execute_concurrentRequests() {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The test name 'test_execute_concurrentRequests' is misleading because the implementation executes requests sequentially (as noted in the comment on line 245), not concurrently. Consider renaming to 'test_execute_sequentialRequests' or 'test_execute_multipleRequests'.

Suggested change
public void test_execute_concurrentRequests() {
public void test_execute_sequentialRequests() {

Copilot uses AI. Check for mistakes.
@marevol marevol merged commit 3537383 into main Jan 15, 2026
1 check passed
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.

2 participants