In automated unit testing, it is sometimes necessary to use objects or procedures that look and behave like their release-intended counterparts, but are actually simplified versions that reduce complexity and facilitate testing. Such procedures are called test doubles. Mocking refers to the idea of providing these test doubles instead of the real implementation during tests. This helps in reducing the testing effort in cases where testing could be too cumbersome, or it is not possible to instantiate the entire program.
Furthermore, as we discussed with the testing pyramid, doing more unit tests is preferable during the development of the application as it forces application developers to write more testable application code and apply separation of concerns more thoroughly, which usually leads to more maintainable and understandable code. Using Mockito with the SAP Cloud SDK, we can test a small portion of the code without the need for a real SAP S/4HANA back-end system. This provides a very convenient way to test the overall functionality.
Mockito is an open source testing framework for Java released under the MIT License. The framework allows the creation of test double objects (mock objects) in automated unit tests for the purpose of test-driven development (TDD) or behavior-driven development (BDD).
To know more about Mockito, review the official documentation at https://site.mockito.org.