jkube icon indicating copy to clipboard operation
jkube copied to clipboard

Refactor SystemMock utility in common-test to use mockito and use in GradleUtilTest to mock System properties

Open rohanKanojia opened this issue 3 years ago • 2 comments

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.

rohanKanojia avatar Sep 30 '21 13:09 rohanKanojia

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

rohanKanojia avatar Jun 14 '22 14:06 rohanKanojia

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

manusa avatar Jun 15 '22 11:06 manusa

please assign this to me and label it as GSoC @manusa @rohanKanojia

baruKreddy avatar Nov 23 '22 13:11 baruKreddy