RFR: 8376038: Refactor java/sql tests to use JUnit [v2]
Justin Lu
jlu at openjdk.org
Tue Jan 27 17:48:14 UTC 2026
On Tue, 27 Jan 2026 17:41:35 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> Please review this PR which converts the JDBC TestNG tests to use JUnit.
>>
>> This is mainly done using the automated tool in https://github.com/openjdk/jdk/commit/0cec3097aec02e72ccb6ebbf0b2b046220578d1b, with some manual follow up commits. The testng folder is migrated to junit with the TEST.properties updated as well. Most changes are annotation updates and switching from testNG imports to JUnit. I decided to simplify cases of `BaseTest.trueFalse()` to use booleans in a `ValueSource` directly in https://github.com/openjdk/jdk/commit/757e7966666d39748db2912b32ccf8b1df18bd62.
>>
>> Framework test stats before:
>> 680 = 680 TestNG + 0 JUnit
>>
>> Framework test stats after:
>> 680 = 0 TestNG + 680 JUnit
>
> Justin Lu has updated the pull request incrementally with 11 additional commits since the last revision:
>
> - clean up some of the statement lambdas
> - use static imports for assertions
> - TestInstance cleanup -> Base test remains PER_CLASS (as needed), child classes remove redundant annotations
> - Convert testNG Object[][] style data providers to Stream
> - Convert test/jdk/java/sql/junit/test/sql/ param tests to ensure original semantics
> - Resolve errors stemming from JUnit auto-closeable resolution
> - Resolve undetected BaseTest data providers
> - Resolve no automated replacement for assertEqualsNoOrder
> - Apply automated conversion to javax/sql and update testng to junit naming for folder & properties
> - Refactor JavatimeTest.java to use JUnit and migrate under junit folder
> - ... and 1 more: https://git.openjdk.org/jdk/compare/8ba8213f...06098254
The latest batch of commits updates the _javax/sql_ testNG files to use JUnit as well. `BaseTest` which the majority of tests rely on remain `Lifecycle.PER_CLASS` (as needed) but the non `BaseTest` extending classes were able to migrate to the default life cycle. Note that the parameterized tests were updated to have their `autoCloseArgument` attribute set to false, since there were failures when left on the default value of true. For example, `close()` is a no-op for many of the `Stub` classes which get tested.
> AutoCloseable arguments
>
> Arguments that implement java.lang.AutoCloseable (or java.io.Closeable which extends java.lang.AutoCloseable) will be
> automatically closed after the parameterized class or test invocation. To prevent this from happening, set the autoCloseArguments attribute in @ParameterizedTest to false.
_JavaTimeTest_ was also updated to use JUnit and moved under the folder accordingly. Do we want the _jdk/test/jdk/javax/sql/rowset_ tests to also be migrated to use JUnit as well? Also, is it appropriate to place _jdk/test/jdk/java/sql/driverModuleTests/DriverManagerModuleTests.java_ under _jdk/test/jdk/java/sql/junit/test/sql/othervm_ since it is now a JUnit test?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29354#issuecomment-3806592650
More information about the core-libs-dev
mailing list