Add unit tests for PerLevelDataLoaderDispatchStrategy coverage by andimarek · Pull Request #4308 · graphql-java/graphql-java · GitHub
Skip to content

Add unit tests for PerLevelDataLoaderDispatchStrategy coverage#4308

Merged
andimarek merged 3 commits intomasterfrom
test/per-level-dispatch-strategy-coverage
Mar 8, 2026
Merged

Add unit tests for PerLevelDataLoaderDispatchStrategy coverage#4308
andimarek merged 3 commits intomasterfrom
test/per-level-dispatch-strategy-coverage

Conversation

@andimarek
Copy link
Copy Markdown
Member

Summary

  • Adds dedicated unit tests for PerLevelDataLoaderDispatchStrategy to deterministically cover concurrency-dependent code paths that are otherwise only hit under specific thread timing in integration tests.
  • Covers the markLevelAsDispatchedIfReady race condition (line 447), both exception handlers (executeObjectOnFieldValuesException, executionStrategyOnFieldValuesException), and concurrent onCompletionFinished dispatch.
  • Improves line coverage from 92.5% to 98.5%, branch coverage from 92.0% to 94.0%, and method coverage from 91.3% to 100.0%.

Test plan

  • All 4 new tests pass locally
  • Full test suite passes with ./gradlew test jacocoTestReport
  • JaCoCo coverage verified: only 2 lines remain uncovered (CAS retry loop body at L388, dead guard at L505)

🤖 Generated with Claude Code

Cover concurrency-dependent code paths that were previously only exercised
non-deterministically by integration tests, causing flaky coverage gate
failures in PRs:

- markLevelAsDispatchedIfReady: test the "another thread already dispatched"
  path (line 447) that requires two threads to race on dispatchedLevels.add()
- executeObjectOnFieldValuesException: error recovery path never triggered
  by integration tests
- executionStrategyOnFieldValuesException: same error recovery pattern at
  the root execution strategy level
- Concurrent onCompletionFinished race: two threads completing the same
  level simultaneously

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 8, 2026

andimarek and others added 2 commits March 9, 2026 08:46
Make CallStack, its fields, and markLevelAsDispatchedIfReady
package-private so tests can access them directly without reflection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Convert JUnit test to Groovy/Spock to match project conventions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andimarek andimarek merged commit 761df31 into master Mar 8, 2026
11 checks 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.

1 participant