Mock Repository Page
Last updated
Last updated
The Mock Repository page is utilized to configure the response data for API test scripts. This ensures that when a test script is called as a dependent API script and executed for Unit Testing, the predefined responses set on this page will be employed.
The Mock Repository page contains three sections.
Choose API Scripts
Mock Response Header
Mock Response Body
Choose API Scripts
This section is employed to choose an existing API test script. Once the component is selected, you can further choose the Test ID for which you wish to set a mock response.
Do you want the mock response data to be overridden by real data after script execution : If this value is true, the mock response data will be overridden by real data after script execution whenever the test script passes
Mock Response Header
If we require any response in the header, we can add a header name and specify its value in this section. For example, here I am adding "Host."
Mock Response Body
In the Mock Response Body, you can set your mock response data and define the response format. For example, I am adding {"email":"","flightnumber":""}.
After clicking the Dynamic Data button, we can set the appropriate data key.
Once you click the save button, the mock response for the selected test script will be set. Whenever the test script is called, it will return the response as per our selected mock configuration.
Example
Now, let's assume this test script is called in a predependent test script for another script.
Now, when you debug and run the test script, our mock response will be utilized.