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

后端 未结 5 2092
野性不改
野性不改 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:44

    You can't mock static methods/properties. So, when your classA uses some static member of classB you can't test classA in isolation.

    UPDATE: I don't see any problem of wrapping some static class into object. It doesn't take lot of time, but it allows you to decrease coupling in your system.

提交回复
热议问题