Simulate Mockito in ABAP
Mockito is a mocking framework, JAVA-based library that is used for effective unit testing of JAVA applications which are widely used in Chengdu team. With Mockito you don’t need to create any mock class manually, you just need to tell Mockito what mocked data should be returned for a given method and Mockito will do the left thing for you.
Suppose I have a simple class:
you simply tell Mockito what mocked data should be returned for each different argument in method getBook call, and when you call getBook, the mocked data will be returned. It works as a charm.
And again the idea of this TRANSIENT AND DYNAMIC MOCK class could be implemented in ABAP.
The following code has exactly the same style as Java code displayed above and it also works exactly the same logic as in Java Mockito:
Output:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":