Why do we need mocking frameworks?

后端 未结 11 1745
清歌不尽
清歌不尽 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条回答
  •  Happy的楠姐
    2020-12-30 03:30

    Using a mocking framework can be a much more lightweight and simple solution to provide mocks than actually creating a mock object for every object you want to mock.

    For example, mocking frameworks are especially useful to do things like verify that a call was made (or even how many times that call was made). Making your own mock objects to check behaviors like this (while mocking behavior is a topic in itself) is tedious, and yet another place for you to introduce a bug.

    Check out Rhino Mocks for an example of how powerful a mocking framework can be.

提交回复
热议问题