What are mock objects in Java?

后端 未结 5 1731
死守一世寂寞
死守一世寂寞 2020-11-30 06:18

I like to know what mock objects are in Java. Why do we create them and what are their uses?

5条回答
  •  野性不改
    2020-11-30 06:58

    Mock objects let you simulate and verify real objects, without actually running the real code in those objects. You can set up a mock to return specific results on method calls, you can verify that a method was or wasn't called, and other cool stuff.

    Mockito is a very simple and straightforward Java mock object library.

提交回复
热议问题