Skip to content

Stop using PowerMock & JUnit 4#759

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

Stop using PowerMock & JUnit 4#759
axlewin wants to merge 39 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
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.

1 participant