Static class/method/property in unit test, stop it or not

后端 未结 5 2090
野性不改
野性不改 2020-12-03 07:37

Should a static class/method/property be used in a unit test development environment, given that there is no way to test it without introducing a wrapper that is again not t

5条回答
  •  情话喂你
    2020-12-03 07:54

    Technically you can mock the static method in Java with PowerMock, but if you need to do this I would seriously recommend to refactor your code. I think that static methods should always be private and used only inside the classes they are defined in, for internal purposes. I consider publicly exposed static method as a code smell.

提交回复
热议问题