Why do we need mocking frameworks?

后端 未结 11 1758
清歌不尽
清歌不尽 2020-12-30 03:00

I have worked with code which had NUnit test written. But, I have never worked with mocking frameworks. What are they? I understand dependency injection and how it helps to

11条回答
  •  佛祖请我去吃肉
    2020-12-30 03:19

    The only reason to use a mocking library is that it makes mocking easier.

    Sure, you can do it all without the library, and that is fine if it's simple, but as soon as they start getting complicated, libraries are much easier.

    Think of this in terms of sorting algorithms, sure anyone can write one, but why? If the code already exists and is simple to call... why not use it?

提交回复
热议问题