跳到主要内容

Mock

提示

Once the request parameters and expected responses are defined, you can generate a Mock URL even before the interface is fully developed. This enables the front-end and testing teams to start their work ahead of time.

To use Mock, you need to turn on the switch here first.

image.png

Mock Expected Data Source

When using the Mock service, it is essential to ensure that there is a pre-defined expected response for the current interface. You can first design the expected response under the Design tab (for specific usage, please refer to the API design documentation). image.png

Intelligent Mock Expectations

What is an Intelligent Expectation

In intelligent expectations, you can define trigger conditions and set which expectations will be enabled when these conditions are met or unmet. After [Saving Settings], EchoAPI will apply the underlying parameter judgment rules based on the trigger conditions. If the conditions are met, the preset expectations will be activated.

image.png

How to Add Intelligent Expectations

  1. We can add multiple trigger conditions and each trigger condition can include multiple sub-conditions.

image.png 2. After filling in the sub-conditions, select an existing expectation that will be enabled when the trigger conditions are met.

image.png 3. A trigger condition is only satisfied when all its sub-conditions are met.

image.png

Obtaining MockURL

Retrieve the Mock address for the interface to use the Mock service.

  • Cloud URL: A mock service hosted on the EchoAPI cloud, shareable with others. Once the URL link is closed, the shared link becomes inactive.

Note: Cloud Mock is disabled by default and will only take effect once activated.

image.png