Why Need for mocking ?

By | October 15, 2020

Before using the Mocking technique, Let’s try to understand the reasons for using mocking.

Why Need for mocking (Reason-01)?

If you want to test a component that depends on the other component, but that component is under development. It generally happens when working in a team and different components are divided between several team members. In that case, mocking plays an important role in the testing. Without mocking, we need to wait for the completion of the required elements for testing.

Why Need for mocking (Reason-02)?

As you know the real components perform slow operations while dealing with database connections or another complex read/ write operation. Sometimes the database queries can take a longer time to execute. In such cases, we require mock objects to perform testing and it can be done using mocking.

Why Need for mocking (Reason-03)?

Whenever there is any infrastructure concern or issue that makes the testing impossible. For example, when we create a connection to the database, some issues related to configurations occur. It requires mocking for creating mock components to provide unit testing.

You may Also Like:

What is Mocking?
What are the Benefits of Mockito?
How to mock interface using Mockito example?
Mockito and JUnit Integration Using Maven Example
@Mock and @Spy Mockito Annotations With Example
@InjectMocks Annotation in Mockito with Example
Mockito – Verifying Method Calls
@Captor Annotation in Mockito with Example
Adding behavior to mocked object in Mockito
Mocking Void Methods with Mockito
Mocking Exception Throwing using Mockito
Mockito’s mock Overloaded Methods

That’s all about Why Need for mocking?
If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published.