Skip to content

Use more JUnit 5 features and simplify tests - #545

Merged
slachiewicz merged 1 commit into
masterfrom
junit5-test-modernization
Nov 18, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
junit5-test-modernization

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Reviewing the test suite for simplifications showed it was already on JUnit 5 Jupiter, but still carried JUnit 3-era style and a fair amount of boilerplate. This PR deepens the JUnit 5 usage and trims the noise; behaviour is unchanged.

JUnit 5 features

  • @Nested + @DisplayName group the 13 C# argument-normalization cases.
  • @ParameterizedTest with @ValueSource merges the two identical Zip-Slip tests, and with @CsvSource replaces hand-written tables for javac version parsing.
  • assertAll (with Executable lists) reports every mismatch in a group at once.
  • @TempDir field injection, assertThrows method references, package-private test methods.

Simplifications

  • Removed duplicate assertions and a dead commented-out Hamcrest block.
  • args(...) / assertArguments(...) and writeFile(file, lastModified) helpers remove repeated map/file setup.
  • One localizedHeaders(...) source replaces four identical seven-row @MethodSource builders shared by ErrorMessageParserTest and JavacCompilerTest.
  • AbstractCompiler.getSourceFiles() no longer special-cases the empty set before toArray.
  • junit-jupiter-params added as a test dependency of the C# module (version from the parent's junit-bom).

Verification

  • Full reactor mvn -o test: 206 tests, 0 failures/errors; per-class test counts preserved.
  • spotless:check: clean.

Note: builds need JDK 21 or older - palantir-java-format 2.80.0 crashes on JDK 27 with NoSuchFieldError: endPositions.

- Use @nested, @DisplayName, @ParameterizedTest (@CsvSource, @valuesource),
  assertAll and @tempdir across the API, C#, Eclipse and javac tests
- Drop duplicate assertions, dead Hamcrest comments and map/file boilerplate
- Share the localized-header argument source between the javac test classes
- Remove the redundant empty-array branch in AbstractCompiler.getSourceFiles()
@slachiewicz
slachiewicz force-pushed the junit5-test-modernization branch from 128e08a to 4e6db70 Compare November 18, 2026 20:34
@slachiewicz slachiewicz added the maintenance Cleanup, refactoring or other internal change label Nov 18, 2026
@slachiewicz
slachiewicz merged commit c7f3754 into master Nov 18, 2026
32 of 49 checks passed
@slachiewicz
slachiewicz deleted the junit5-test-modernization branch November 18, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Cleanup, refactoring or other internal change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant