Skip to content

test(storage): exclude jqwik tests on Java 8#13846

Open
nnicolee wants to merge 2 commits into
mainfrom
test/exclude-jqwik-java8
Open

test(storage): exclude jqwik tests on Java 8#13846
nnicolee wants to merge 2 commits into
mainfrom
test/exclude-jqwik-java8

Conversation

@nnicolee

@nnicolee nnicolee commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Jqwik version 1.9+ requires JDK 11+ at runtime. Since google-cloud-java runs tests on JDK 8 matrix environments, Jqwik's reflection-based class scanning fails when JSpecify 1.0.0 annotations are present, causing UnsupportedClassVersionError or reflection scanner crashes during JUnit test discovery on Java 8.

Solution

This PR introduces a clean profile-based exclusion to isolate Jqwik on Java 8 without impacting modern Java environments:

  1. Moved Jqwik dependency into jqwik-tests profile: The net.jqwik:jqwik library is no longer loaded globally; it is only added to the test classpath on JDK 11+ ([11,)).
  2. Added exclude-jqwik-on-java8 profile: Active only when the JDK is exactly 1.8.
  3. Excluded Jqwik test compilation: Inside the Java 8 profile, we use testExcludes to skip compiling all Jqwik-based property tests (e.g., *PropertyTest.java, jqwik packages, etc.) to prevent compile errors when Jqwik is not on the classpath.
  4. Decoupled compilation dependencies: Excluded RewindableByteBufferContentTest.java on Java 8 as well, since it has an import reference to a nested class inside RewindableContentPropertyTest.java and would otherwise pull it into compiler scope.

Rationale

  • Decouples Jqwik testing dependencies on Java 8 matrix builds, preventing pipeline failures.
  • Retains 100% test coverage for these property-based tests on modern JDKs (11, 17, 21, etc.) since matrix builds continue to compile and run them normally.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the Maven configuration to conditionally load the jqwik dependency on JDK 11+ and exclude specific test files when compiling on Java 8. The review feedback points out that hardcoding individual test files in the exclusion list is fragile and risks losing standard JUnit test coverage on Java 8. It is recommended to separate jqwik property tests into dedicated files or packages to simplify the POM exclusions to wildcard patterns.

Comment on lines +503 to +511
<exclude>**/StorageV2ProtoUtilsTest.java</exclude>
<exclude>**/JsonUtilsTest.java</exclude>
<exclude>**/ChunkSegmenterTest.java</exclude>
<exclude>**/DefaultBufferedWritableByteChannelTest.java</exclude>
<exclude>**/MinFlushBufferedWritableByteChannelTest.java</exclude>
<exclude>**/DefaultBufferedReadableByteChannelTest.java</exclude>
<exclude>**/Crc32cValueTest.java</exclude>
<exclude>**/ITSyncingFileChannelTest.java</exclude>
<exclude>**/RewindableByteBufferContentTest.java</exclude>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding individual test files in the POM's exclusion list is fragile and difficult to maintain. Additionally, if these files contain standard JUnit tests alongside jqwik property tests, excluding the entire file from compilation on Java 8 means we completely lose standard test coverage on Java 8.

Recommendation

  1. Separate Test Concerns: Move jqwik property tests into dedicated files ending with PropertyTest.java (e.g., JsonUtilsPropertyTest.java) or place them under a jqwik package.
  2. Retain Java 8 Coverage: Keep standard JUnit tests in their original files (e.g., JsonUtilsTest.java) without any jqwik imports so they can compile and run on Java 8.
  3. Simplify POM: This allows you to simplify the exclusions here to just the wildcard patterns (**/*PropertyTest.java and **/jqwik/**), removing the need to list individual files.

@lqiu96 lqiu96 changed the title fix: exclude jqwik tests on Java 8 test(spanner): exclude jqwik tests on Java 8 Jul 21, 2026
Comment thread java-storage/google-cloud-storage/pom.xml
@nnicolee nnicolee changed the title test(spanner): exclude jqwik tests on Java 8 test(storage): exclude jqwik tests on Java 8 Jul 21, 2026
@nnicolee
nnicolee marked this pull request as ready for review July 21, 2026 19:10
@nnicolee
nnicolee requested review from a team as code owners July 21, 2026 19:10
@lqiu96 lqiu96 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 21, 2026
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.

3 participants