Integrated: 8366678: Use JUnit in test/langtools/tools/javac
Christian Stein
cstein at openjdk.org
Mon Sep 22 06:05:31 UTC 2025
On Tue, 2 Sep 2025 12:30:08 GMT, Christian Stein <cstein at openjdk.org> wrote:
> Please review this change to use JUnit in tests of `test/langtools/tools/javac`.
>
> ### Assess Status Quo
> A local `make test TEST=test/langtools/tools/javac` run before the conversion yields:
>
> Test results: passed: 3,938; excluded: 4; did not match keywords: 2; did not meet platform requirements: 2
> Framework-based tests: 3043 = 2762 TestNG + 281 JUnit
>
>
> ### Perform Automatic Conversion
> - [junit-convert](
> https://github.com/lahodaj/netbeans/tree/openjdk-testng-junit-fixes-and-hacks/java/java.openjdk.project/junit-convert)
>
> ### Perform Manual Adjustments
>
> Some of the following adjustments will be integrated into the `junit-convert` tool.
>
> #### Make argument source factory method `static`
>
> Method 'public java.lang.Object[][] org.openjdk.tests.javac.FDTest.caseGenerator()'
> must be static: local factory methods must be static
> unless the PER_CLASS @testinstance lifecycle mode is used;
> external factory methods must always be static.
>
>
> #### Make `@AfterAll`-annotated method `static`
>
> [ERROR] @afterall method 'public void org.openjdk.tests.vm.FDSeparateCompilationTest.cleanupCompilerCache()'
> must be static unless the test class
> is annotated with `@TestInstance(Lifecycle.PER_CLASS)`.
>
>
> #### Remove `static` modifier from `@Test`-annotated methods
> This configuration error should have been detected by JUnit Jupiter and reported via the Discovery
> Issues API: https://docs.junit.org/current/user-guide/#running-tests-discovery-issues
>
> #### Rename test property to `JUnit.dirs`
>
> package org.junit.jupiter.api does not exist
>
>
> #### Prune extra contructors
>
> Class [FDTests] must declare a single constructor
> Class [MethodReferenceTestKinds] must declare a single constructor
>
>
> Initially by adding custom test instance factory to help JUnit select the correct constructor.
> Now by deleting all-but-one constructor to used by file-local code and JUnit alike.
>
> ### Results
> Re-run tests via `make test TEST=test/langtools/tools/javac` after the conversion; yielding:
>
> Test results: passed: 3,939; excluded: 4; did not match keywords: 2; did not meet platform requirements: 2
> Framework-based tests: 3043 = 0 TestNG + 3043 JUnit
This pull request has now been integrated.
Changeset: 682fd784
Author: Christian Stein <cstein at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/682fd7846c9a6f80c399c7e44f3fccb9a07c6c47
Stats: 653 lines in 39 files changed: 195 ins; 97 del; 361 mod
8366678: Use JUnit in test/langtools/tools/javac
Reviewed-by: liach
-------------
PR: https://git.openjdk.org/jdk/pull/27046
More information about the compiler-dev
mailing list