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

前端 未结 7 1859
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-03 00:02

    This Google Techtalk does a pretty good job of describing the problems with singletons and global state when it comes to unit testing.

提交回复
热议问题