Skip to content

Migrate System Rules to System Stubs and JUnit Pioneer - #1152

Merged
sambsnyd merged 9 commits into
mainfrom
tim/system-rules-stubs-pioneer-migration
Oct 5, 2026
Merged

sambsnyd merged 9 commits into
mainfrom
tim/system-rules-stubs-pioneer-migration

Conversation

@timtebeek

@timtebeek timtebeek commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Adds MigrateSystemRules to JUnit4to5Migration, moving the JUnit 4 rules of com.github.stefanbirkner:system-rules to JUnit Pioneer annotations (system property rules with literal values) and System Stubs @SystemStub fields (other property, stream, standard input and environment variable rules), and turning ExpectedSystemExit into catchSystemExit(..).
Rules used in ways without a direct equivalent, or that other classes may use, get a TODO comment.
SystemRulesDependencies scans the migrated sources within the same cycle, so system-stubs-jupiter and junit-pioneer are added to the source set that uses them, Pioneer 1.x is upgraded where @RestoreSystemProperties is introduced, and system-rules is removed only once unused.
The existing EnvironmentVariables recipe joins this group and now retypes through ChangeType.
Validated on a 14-repository corpus with the Moderne CLI; tests also run with production cycle settings to cover the dependency changes.

Adds MigrateSystemRules, which migrates System Rules' JUnit 4 rules in JUnit
Jupiter tests: literal system property rules become JUnit Pioneer annotations,
the other property, stream, standard input and environment variable rules
become System Stubs @SystemStub fields, and ExpectedSystemExit becomes
catchSystemExit(..). Rules that can not be migrated, or that other classes may
use, get a TODO comment. The dependencies follow the migrated code, and JUnit
4to5Migration now runs the migration after UpdateTestAnnotation.
@timtebeek timtebeek added the recipe Recipe request label Oct 2, 2026
@timtebeek
timtebeek marked this pull request as ready for review October 5, 2026 15:39
@sambsnyd
sambsnyd merged commit ce9b1fd into main Oct 5, 2026
1 check passed
@sambsnyd
sambsnyd deleted the tim/system-rules-stubs-pioneer-migration branch October 5, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Recipe request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants