jkube
jkube copied to clipboard
Refactor SystemMock utility in common-test to use mockito and use in GradleUtilTest to mock System properties
Description
Blocked on #957 #857 #31
I was writing some tests related to System properties in #957 where SystemMock could be used for mocking System properties. Unfortunately, it's based on JMockit(as the rest of JKube Kit) and the Gradle Plugin module is based on Mockito.
We plan to Migrate JKube tests to Mockito in the future https://github.com/eclipse/jkube/issues/857
Whenever we're able to merge Gradle module to main branch and migrate to Mockito. GradleUtilTest tests
which are using System.setProperty
and then System.clearProperty
should be updated to use SystemMock instead.
I think we might be able to deal with this using JUnit5 extensions. I see these options
- Use JUnit Poineer https://junit-pioneer.org/docs/system-properties/ :x:
- Define your own custom extension for setting and clearing property before and after test :heavy_check_mark:
After using these, there won't be a need of SystemMock anymore
I'd vote for our own extension. It won't be hard to implement and won't require additional dependencies. Something as simple as an annotation to set a system property and an extension that would backup its original value and restore it for each test execution would be quite simple to implement. Maybe in the scope of #857
please assign this to me and label it as GSoC @manusa @rohanKanojia