Skip to content

Conversation

@AbgarSim
Copy link
Contributor

@AbgarSim AbgarSim commented Dec 18, 2025

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #4041 ☕️

Before Optimisitation
Screenshot 2025-12-19 at 12 03 10

After Optimisation
Screenshot 2025-12-19 at 11 57 23

If you write sample code, please follow the samples format.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/java-bigquery API. labels Dec 18, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @AbgarSim, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant modernization effort by migrating the project's testing infrastructure from JUnit 4 to JUnit 5. This transition not only updates the core testing framework but also introduces parallel test execution, aiming to drastically improve the speed and efficiency of the test suite. The changes span across dependency management, test class annotations, and assertion method usage, ensuring full compatibility with the latest JUnit platform features.

Highlights

  • Migration to JUnit 5: The project's testing framework has been upgraded from JUnit 4 to JUnit 5. This involved updating core JUnit dependencies and adapting test annotations and assertion methods across numerous test files to align with the JUnit 5 API.
  • Parallel Test Execution: Parallel execution of tests has been enabled by introducing a junit-platform.properties file. This configuration sets up concurrent execution for test classes and methods with a fixed parallelism of 8, aiming to significantly improve test suite performance.
  • Mockito Integration Update: Mockito integration has been updated for JUnit 5 by adding the mockito-junit-jupiter dependency. Existing @RunWith(MockitoJUnitRunner.class) annotations were replaced with @ExtendWith(MockitoExtension.class) to ensure compatibility and leverage JUnit 5's extension model.
  • Assertion Modernization: JUnit 4 static assertion methods from org.junit.Assert (e.g., assertEquals, assertNotNull, fail) have been replaced with their JUnit 5 counterparts from org.junit.jupiter.api.Assertions for improved readability and consistency.
  • Lifecycle Method Updates: JUnit 4 test lifecycle annotations such as @Before and @BeforeClass have been migrated to their JUnit 5 equivalents, @BeforeEach and @BeforeAll respectively, providing clearer semantics for test setup and teardown.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 does a great job migrating the project to JUnit 5 and enabling parallel test execution. The changes in pom.xml and the introduction of junit-platform.properties are correct.

However, the migration of the test source code is incomplete. Many test files still use assertions from JUnit 4 (org.junit.Assert), which can lead to a mixed test dependency setup. For a clean migration, it's best to consistently use JUnit 5's assertions from org.junit.jupiter.api.Assertions.

I've left a few specific comments to highlight this issue. A global search-and-replace for org.junit.Assert imports should help clean this up across the codebase.

@AbgarSim AbgarSim force-pushed the feat/junit-5-migration branch from af000f8 to 02aae0e Compare December 19, 2025 09:49
@AbgarSim AbgarSim marked this pull request as ready for review December 19, 2025 09:51
@AbgarSim AbgarSim requested review from a team as code owners December 19, 2025 09:51
@AbgarSim AbgarSim requested a review from suzmue December 19, 2025 09:51
@AbgarSim AbgarSim force-pushed the feat/junit-5-migration branch 3 times, most recently from c2cf29a to 4caa1c9 Compare December 19, 2025 10:06
@lqiu96 lqiu96 requested review from jinseopkim0 and lqiu96 and removed request for suzmue December 19, 2025 16:16
pom.xml Outdated
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.11.4</version>
Copy link
Member

Choose a reason for hiding this comment

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

Our SDK actually manages a set of common dependencies upstream here: https://github.com/googleapis/sdk-platform-java/blob/b68791d074c02e02a5ccf2f937a5922749a14f56/gapic-generator-java-pom-parent/pom.xml#L40 (a bit of a convoluted process to get here).

You should be able to reference the ${junit.version} there so it's centrally managed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I'm not quite sure how this repo is linked to gapic-generator-java-pom-parent and just using ${junit.version} fails locally.

However, following the trail of parents of this repo i was able to reach native-image-shared-config pom which has <junit-vintage-engine.version>5.11.4</junit-vintage-engine.version>

I used this placeholder instead, please advice if this is acceptable or how to reach ${junit.version}

@lqiu96
Copy link
Member

lqiu96 commented Dec 19, 2025

Thanks again @AbgarSim, really appreciate the work going into migrating to JUnit 5! The tests generally look good. I added a few comments mostly about dependencies.

For the the wildcard imports (import static org.junit.jupiter.api.Assertions.*;, can you break them down into the individual imports that are used?

Additionally, we have the dependencies check reporting:

Error:  Used undeclared dependencies found:
Error:     org.junit.jupiter:junit-jupiter-api:jar:5.11.4:test
Error:     junit:junit:jar:4.13.2:test
Error:  Unused declared dependencies found:
Error:     org.junit.jupiter:junit-jupiter:jar:5.11.4:test

@AbgarSim AbgarSim force-pushed the feat/junit-5-migration branch 2 times, most recently from b78fec2 to 6c3b014 Compare December 19, 2025 20:40
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Dec 19, 2025
@AbgarSim AbgarSim force-pushed the feat/junit-5-migration branch from 6c3b014 to 62566a8 Compare December 19, 2025 20:46
@AbgarSim
Copy link
Contributor Author

Hi @lqiu96 thanks for the feedback!

I've pushed the following adjustments:

  • Deleted junit-platform.properties - will move it as separate PR
  • Adjusted all the Assertion.* imports, good catch missed those
  • Used the junit-vintage-engine.version for junit dep - as per my comment above please advice if this is ok
  • Split JUnit Jupiter into explicit junit-jupiter-api and junit-jupiter-engine, this should address the dependencies check

@AbgarSim AbgarSim requested a review from lqiu96 December 19, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/java-bigquery API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JUnit 5 migration and parallel Unit Test Execution

2 participants