Skip to content

chore(jdbc): update to junit5#4135

Draft
logachev wants to merge 1 commit intomainfrom
junit5
Draft

chore(jdbc): update to junit5#4135
logachev wants to merge 1 commit intomainfrom
junit5

Conversation

@logachev
Copy link
Contributor

@logachev logachev commented Mar 7, 2026

Migrate from junit4 to junit5

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/java-bigquery API. labels Mar 7, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 modernizes the testing infrastructure by migrating the project from JUnit 4 to JUnit 5. This update brings the test suite in line with current best practices, leveraging JUnit 5's modularity, new extension model, and enhanced features for writing more flexible and powerful tests. The change primarily impacts test-related code and dependencies, ensuring better maintainability and future compatibility.

Highlights

  • JUnit 5 Migration: The project has been migrated from JUnit 4 to JUnit 5, updating dependencies and test annotations across the codebase.
  • Dependency Updates: The pom.xml file was updated to remove JUnit 4 and add JUnit Jupiter API, Engine, and Params dependencies, along with Mockito JUnit Jupiter.
  • Test Annotation Modernization: JUnit 4 annotations such as @Rule, @ClassRule, @Before, @Test, @Ignore, @RunWith, and @Parameters have been replaced with their JUnit 5 equivalents like @RegisterExtension, @BeforeEach, @Test, @ParameterizedTest, @MethodSource, @Disabled, @Nested, and @TestInstance.
  • Assertion and Utility Class Changes: Imports for org.junit.Assert were updated to org.junit.jupiter.api.Assertions, and org.junit.function.ThrowingRunnable was replaced with org.junit.jupiter.api.function.Executable.
  • Custom Rule Migration: The TimeZoneRule custom JUnit rule was refactored to implement JUnit 5's extension interfaces (BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback).
Changelog
  • google-cloud-bigquery-jdbc/pom.xml
    • Removed JUnit 4 dependency.
    • Added JUnit Jupiter API, Engine, and Params dependencies.
    • Added Mockito JUnit Jupiter dependency.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/ArrowFormatTypeBigQueryCoercionUtilityTest.java
    • Updated JUnit imports.
    • Replaced @Rule with @RegisterExtension.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryArrowArrayOfPrimitivesTest.java
    • Updated assertThrows import.
    • Replaced JUnit 4 annotations with JUnit 5 equivalents for parameterized tests.
    • Refactored parameterized test structure to use @ParameterizedTest and @MethodSource.
    • Updated ThrowingRunnable to Executable.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryArrowArrayOfStructTest.java
    • Updated assertThrows import.
    • Replaced @Before with @BeforeEach.
    • Updated ThrowingRunnable to Executable.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSetTest.java
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryArrowStructTest.java
    • Updated assertThrows import.
    • Replaced @Rule with @RegisterExtension.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSetTest.java
    • Updated assertFalse import.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryBigQueryTypeCoercerBuilderTest.java
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatementTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryConnectionTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Before with @BeforeEach.
    • Simplified assertion calls by moving messages to the last argument.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDaemonPollingTaskTest.java
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaDataTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Before with @BeforeEach.
    • Simplified assertion calls by moving messages to the last argument.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDefaultCoercionsTest.java
    • Replaced JUnit 4 annotations with JUnit 5 equivalents for parameterized tests.
    • Refactored parameterized test class structure.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDriverTest.java
    • Updated fail import to JUnit Jupiter.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtilityTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Ignore with @Disabled.
    • Updated Assert.fail() to Assertions.fail().
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcParameterTest.java
    • Updated assertEquals import to JUnit Jupiter.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcProxyUtilityTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtilityTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJsonArrayOfPrimitivesTest.java
    • Updated assertThrows import.
    • Replaced JUnit 4 annotations with JUnit 5 equivalents for parameterized tests.
    • Refactored parameterized test structure to use @ParameterizedTest and @MethodSource.
    • Updated ThrowingRunnable to Executable.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJsonArrayOfStructTest.java
    • Updated assertThrows import.
    • Replaced @Before with @BeforeEach.
    • Updated Assert.assertThrows to Assertions.assertThrows.
    • Updated ThrowingRunnable to Executable.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSetTest.java
    • Replaced @Rule with @RegisterExtension.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJsonStructTest.java
    • Updated assertThrows import.
    • Replaced @Rule with @RegisterExtension.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandlerTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnectionTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetFinalizersTest.java
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetMetadataTest.java
    • Replaced @RunWith(MockitoJUnitRunner.class) with @ExtendWith(MockitoExtension.class).
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Before with @BeforeEach.
    • Replaced @Ignore with @Disabled.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactoryTest.java
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryTypeCoercerTest.java
    • Updated assertThrows import to JUnit Jupiter.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/FieldValueTypeBigQueryCoercionUtilityTest.java
    • Updated assertThrows import to JUnit Jupiter.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/NullHandlingTest.java
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/PooledConnectionDataSourceTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/PooledConnectionListenerTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Before with @BeforeEach.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @BeforeClass with @BeforeAll.
    • Replaced @AfterClass with @AfterAll.
    • Replaced @Ignore with @Disabled.
    • Updated Assert.fail() to Assertions.fail().
    • Simplified assertion calls by moving messages to the last argument.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @BeforeClass with @BeforeAll.
    • Replaced @AfterClass with @AfterAll.
    • Simplified assertion calls by moving messages to the last argument.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITPSCBigQueryTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Simplified assertion calls by moving messages to the last argument.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITProxyBigQueryTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Replaced @Ignore with @Disabled.
    • Replaced @RunWith(Enclosed.class) with @Nested.
    • Refactored parameterized tests to use @Nested, @TestInstance(Lifecycle.PER_CLASS), @ParameterizedTest, and @MethodSource.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITTPCBigQueryTest.java
    • Updated org.junit.Assert imports to org.junit.jupiter.api.Assertions.
    • Updated @Test import to JUnit Jupiter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/rules/TimeZoneRule.java
    • Refactored TimeZoneRule to implement JUnit 5 extension interfaces (BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback).
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 successfully migrates the test suite from JUnit 4 to JUnit 5. The changes are comprehensive, covering dependency updates in pom.xml, and refactoring test classes to use JUnit 5 annotations and APIs, including parameterized tests and custom rules. The migration appears to be correct and well-executed across all modified files.

Note: Security Review did not run due to the size of the PR.

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.

1 participant