In this guide, we'll explore the advanced rules feature of Mock APIs, empowering users to create multiple responses with distinct rules for precise testing
In the dynamic world of software development, testing and prototyping APIs play a crucial role. Mock APIs are invaluable tools that allow developers to simulate real API responses, ensuring a seamless integration process. In this guide, we'll explore the advanced rules feature of EazyMock, empowering users to create multiple responses with distinct rules for precise testing scenarios.
EazyMock are not just about simulating generic responses; they are about replicating the complexity of real-world APIs. With the advanced rules feature, users can define specific conditions for different parts of the API request, including the body, query parameters, headers, and path.
Begin by creating a new EazyMock API. Most platforms provide a user-friendly interface for this. Once your API is set up, you'll notice an option for advanced rules.
The process of creating a EazyMock API is outlined in this blog.
In this sample we together find out how to use rules to create multi-response with a single API by EazyMock
1. POST API where user can post article and filter by region ----- Using body rules
2. GET API where user can get list TOP article by age ---- Using query rules
3. GET API where use can get article via pages number ---- Using path rules
Users have the flexibility to generate two distinct responses: one tailored for the "Asia region" and another for the "America region." This involves creating two unique request bodies to align with each response.
Asia | America |
---|---|
Subsequently, when utilizing API testing tools, we can verify that the responses correspond appropriately to the distinct requests.
Asia | America |
---|---|
By defining two query rules, users can obtain two distinct responses.
/?age=20 for 1 response
/?age=30 for another response
Age 20 | Age 30 |
---|---|
Age 20 | Age 30 |
---|---|
/:path_id
example:
GET /article/pages/:page_id
Subsequently, users can obtain a response following the specified path format.
Page 1 | Page 2 |
---|---|
Comments