美文网首页SAP 实用篇
Simulate Mockito in ABAP

Simulate Mockito in ABAP

作者: 华山令狐冲 | 来源:发表于2020-01-01 13:48 被阅读0次

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的原创文章,请关注公众号"汪子熙":


相关文章

网友评论

    本文标题:Simulate Mockito in ABAP

    本文链接:https://www.haomeiwen.com/subject/jhowoctx.html