Mobile App testing with Proxyman
Testing mobile applications is an integral part of the software development process, and tools like Proxyman have become indispensable in this workflow. Thanks to its features, Proxyman not only simplifies the work of testers but also accelerates analysis and allows for precise simulations of various scenarios. Why should you use it, and how can you make the most of its capabilities? This article explores these questions.
What is Proxyman?
Proxyman is a tool that enables real-time analysis and modification of API requests and responses. This gives testers the ability to replicate hard-to-reproduce cases and quickly verify how an application responds to different situations. Proxyman offers three key features:
- Breakpoint – allows you to pause requests and responses for modification.
- Map Local – enables static replacement of an entire response.
- Scripting – automates the modification of requests and responses using scripts.
Each of these options is used depending on the needs and nature of the test. Let’s take a closer look at each one.
Breakpoint
The Breakpoint feature allows you to pause a request or response for manual editing. For instance, you can modify data in headers, the body, or even the response code. This is an ideal solution for tests that do not require repetitive execution. However, due to the manual nature of the process, it is best suited for simple, one-off cases.
How to Configure a Breakpoint
- In the Tools > Breakpoint tab, add a new rule or right-click on an existing log to set up a breakpoint.
- Specify details such as the endpoint URL, request method, and whether the Breakpoint should pause the request, response, or both.
- When the endpoint is triggered in the application, the Breakpoint will automatically halt the request, allowing you to edit it. After making changes, click Execute to continue.
Map Local
The Map Local feature allows you to replace an API response with a static, predefined response. This is especially useful for bypassing API-side issues or quickly testing the application’s behavior under specific conditions.
How to Configure Map Local
- In the Tools > Map Local tab, create a new rule or use an existing log by right-clicking on it.
- Prepare the response you want to return – this can include modifications to the body, response code, or headers.
- When the endpoint is triggered by the application, Proxyman will automatically return the prepared response, bypassing the server API.
Scripting
Scripting in Proxyman enables automated modification of requests and responses. This is particularly useful for tests that require repetitive actions or complex data modifications.
How to Create a Script
- Create a new rule in the Scripting tab or use an existing log.
- Choose the type of script, such as modifying the response body. Proxyman provides ready-to-use snippets in its Proxyman Scripting documentation, making it easier even for those without programming experience.
- Example: A script that changes the status in the response to
"BLOCKED"
.
function onResponse(context, url, request) {
response.headers["Content-Type"] = "application/json";
var jsonBody = response.body;
jsonBody["status"] = "BLOCKED";
response.body = jsonBody;
return response;
}
- Trigger the endpoint in the application, and Proxyman will automatically apply the modifications.
Use Case Example
Suppose we want to check how the application behaves when the API returns a response with the status "BLOCKED"
for the service at the endpoint: GET https://api.example.com/v1/service/status
.
Method 1: Breakpoint
- Configure a Breakpoint to intercept the endpoint call in the application. When paused, manually modify the API response to
"status": "BLOCKED".
- Click Execute for the application to process the modified data.
Method 2: Map Local
- Prepare a response with the desired status and assign it to the chosen endpoint.
- Proxyman will automatically return the modified response whenever the endpoint is triggered.
Method 3: Scripting
- Create a script to modify the response in real-time.
- The script will automatically adjust the data for every endpoint call.
Why Choose Proxyman?
Proxyman significantly enhances the workflow of testers for both mobile and web applications. Its capabilities to verify and modify APIs allow testers to quickly answer “What if…?” questions, saving time and resources. If you’re looking for a tool that enables precise testing and flexible real-time modifications, Proxyman is worth trying.