How do Java mocking frameworks work?

前端 未结 5 468
攒了一身酷
攒了一身酷 2021-02-03 23:10

This is NOT a question about which is the best framework, etc.

I have never used a mocking framework and I\'m a bit puzzled by the idea. How does it know how to create t

5条回答
  •  暖寄归人
    2021-02-04 00:14

    For a better understanding of mocking, you might like to make your own mock object. It's a pretty simple process - you make a class which implement the same interface as what you're mocking, and give it the behaviour you require, either recording calls to a method, or responding in a set way when called. From there the way that mocking frameworks are set up begins to make more sense.

提交回复
热议问题