Skip to content

Stop using PowerMock & JUnit 4#759

Open
axlewin wants to merge 42 commits intomainfrom
improvement/remove-powermock
Open

Stop using PowerMock & JUnit 4#759
axlewin wants to merge 42 commits intomainfrom
improvement/remove-powermock

Conversation

@axlewin
Copy link
Contributor

@axlewin axlewin commented Feb 23, 2026

  • Removes all usage of PowerMock in the unit tests to facilitate upgrading Java to >= 17.
  • Migrates all unit tests from JUnit 4 to JUnit 5, since we no longer need JUnit 4 to support PowerMock.
  • Introduces Mockito alongside EasyMock to allow mocking final methods in IsaacLLMFreeTextValidatorTest. Does not (yet) migrate any other tests to Mockito.

In many cases we can remove PowerMock from the test code without modifying the actual implementations being tested, but ec77d14 and b24628f both expose methods that were previously private; we probably need a better solution here.

Maven now finds 567 unit tests to run where it previously found 506.

so that we no longer need Whitebox to test it as a private member of the manager
EasyMock cannot mock final methods.
via GroupManagerTest.
This functionality can be achieved with the equivalent EasyMock methods
to use Mockito, and not use PowerMock
Replay the necessary mocks so that the correct exceptions are thrown.
(JUnit 4 -> JUnit 5)
The Rule annotation is incompatible with JUnit 5, and ExpectedException.none is deprecated anyway.
In JUnit 5 the expected argument order is reversed, so that the message comes last.
The same functionality can now be achieved with just JUnit 5.
Primarily to use JUnit 5. Also correct some spelling, stricten some access modifiers, close a test appender, remove some 'var's, and fix some checkstyle issues.
The additional objects (correctAnswer, wrongAnswer...) need to be initialised before the mock expectations that rely on them are set.
@axlewin axlewin changed the title Stop using PowerMock Stop using PowerMock & JUnit 4 Feb 25, 2026
@axlewin axlewin marked this pull request as ready for review February 26, 2026 10:40
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.87%. Comparing base (dbf3201) to head (8929322).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #759      +/-   ##
==========================================
- Coverage   39.95%   39.87%   -0.09%     
==========================================
  Files         546      547       +1     
  Lines       23901    23909       +8     
  Branches     2873     2873              
==========================================
- Hits         9550     9533      -17     
- Misses      13444    13470      +26     
+ Partials      907      906       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants