The Purpose of Mocking

后端 未结 8 469
独厮守ぢ
独厮守ぢ 2020-12-29 15:33

What is the purpose of mocking?

I have been following some ASP.NET MVC tutorials that use NUnit for testing and Moq for mocking. I am a little unclear about the mock

8条回答
  •  渐次进展
    2020-12-29 15:47

    Mocking allows you to isolate your class under test from its dependencies. Generally, you create a mock for each dependency for the class under test and set up the mock to return expected values. You then provide the mock to your class under test instead of a real copy of the class that your class under test is dependent on. You can then use the mocking framework to check that the expected calls were made to the mock object(s) to ensure that your class under test is operating correctly.

提交回复
热议问题