Why is it hard to unit test a system that depends on singletons?

前端 未结 7 1901
Happy的楠姐
Happy的楠姐 2020-12-02 23:41

I\'ve read cases for and against using the singleton pattern. One common case against describes the difficulties in unit testing with singletons, but I\'m unclear as to why

7条回答
  •  天涯浪人
    2020-12-02 23:51

    A great article about this is Singletons are Pathological Liars. This describes, using a simple example, why testing using singletons is unexpectedly hard.

提交回复
热议问题