Skip to content

Make dead Spock conditions in execution and directive tests run - #4565

Merged
bbakerman merged 1 commit into
graphql-java:masterfrom
costajohnt:fix-dead-spock-conditions
Nov 17, 2026
Merged

bbakerman merged 1 commit into
graphql-java:masterfrom
costajohnt:fix-dead-spock-conditions

Conversation

@costajohnt

@costajohnt costajohnt commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Several Spock checks in these tests were never evaluated as conditions, so they could not fail. Spock only asserts top-level expressions in then:/expect:; a comparison inside if/else is evaluated and discarded, and !x instanceof Y parses as (!x) instanceof Y, which is always false.

  • ExecutionStrategyTest (non-null scalar feature): the whole then: was an if/else, so it asserted nothing. Made live, all three rows failed, because the test passed the nullable type instead of the non-null typeInfo it built, completeValue reports the error through the field value future rather than throwing, and the no-error row expected an exception. The test now uses typeInfo, joins the future, and asserts the exception and error count against errorExpected.
  • SubscriptionExecutionStrategyTest: message.data == null was inside a closure. The actual payload is [newMessage: null] (newMessage is nullable, so the null bubbles up to it), which is now asserted.
  • DeferWithDataLoaderTest: the batch loader counter checks were inside if/else; they now use assert and pass in all three rows.
  • ValueTraverserTest, SchemaGeneratorDirectiveHelperTest: !x instanceof GraphQLObjectType becomes !(x instanceof GraphQLObjectType).

Test-only change. The five classes pass locally (151 tests). Found with groovyfmt, a Groovy formatter and linter.

Spock only treats top-level expressions in then:/expect: blocks as
conditions. Checks nested in if/else or for loops were evaluated and
discarded, and "!x instanceof GraphQLObjectType" parses as
"(!x) instanceof GraphQLObjectType", which is always false.

- ExecutionStrategyTest: the non-null scalar feature asserted nothing.
  Once the checks ran, every row failed: the parameters used the nullable
  field type instead of the non-null typeInfo the test builds, and
  completeValue reports the NonNullableFieldWasNullException through the
  field value future rather than throwing it. The no-error row also
  expected an exception. Use typeInfo, unwrap the future and assert
  the exception and error count for each row.
- SubscriptionExecutionStrategyTest: the null-propagation event has
  data [newMessage: null] (newMessage is nullable), not null. Assert it.
- DeferWithDataLoaderTest: assert the batch loader call counts.
- ValueTraverserTest, SchemaGeneratorDirectiveHelperTest: fix the
  always-false instanceof guards.

@bbakerman bbakerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@bbakerman
bbakerman enabled auto-merge November 17, 2026 22:48
@github-actions

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 17 6370 (±0) 6315 (±0) 0 (±0) 0 (±0) 55 (±0)
Java 21 6370 (±0) 6315 (±0) 0 (±0) 0 (±0) 55 (±0)
Java 25 6370 (±0) 6315 (±0) 0 (±0) 0 (±0) 55 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 19142 (±0) 18977 (±0) 0 (±0) 0 (±0) 165 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 26786 2696 90.9% ±0.0%
Branches 7681 1170 86.8% ±0.0%
Methods 7414 1091 87.2% ±0.0%

Changed Class Coverage (1 class)

Class Line Branch Method
g.e.ExecutionStrategy +0.4% 🟢 ±0.0% ±0.0%

Full HTML report: build artifact jacoco-html-report

Updated: 2026-11-17 22:57:58 UTC

@bbakerman
bbakerman merged commit faaae49 into graphql-java:master Nov 17, 2026
9 checks passed
@costajohnt

Copy link
Copy Markdown
Contributor Author

Thanks for merging!

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