Windsurf: A Powerful Tool for API Automation Testing

I tried using Windsurf to write code for API automation testing and experienced its convenience and efficiency.
Windsurf does not require high coding skills from users, while the accuracy of the generated code is relatively high. Moreover, it excels in generating test case scenario coverage. Once the code is completed, Windsurf can also automatically generate a mind map, making it easier for manual review.
Overall, I feel this is a powerful tool for writing test code.
  • Writing API test code based on Coze’s API
Prompt: This is a python project. Please generate API test code based on the interface information described in the online documentation. https://www.coze.cn/docs/developer_guides/retrieve_chat
After using the above prompt, Windsurf can generate runnable Python code. However, both Windsurf and Cursor struggle with recognizing key information in the Coze online API documentation, resulting in some errors. Therefore, I copied the request and response examples from the documentation into a local txt file and let Windsurf recognize it again. This time, the accuracy of recognition was very high.
For detailed interface description, see: https://www.coze.cn/docs/developer_guides/retrieve_chat. Request and response examples are as follows:
Request Example: curl --location --request GET 'https://api.coze.cn/v3/chat/retrieve?chat_id=738137187639794****&conversation_id=738136585609548****' \ --header 'Authorization: Bearer pat_OYDacMzM3WyOWV3Dtj2bHRMymzxP****' \ --header 'Content-Type: application/json' \ Response Example: {    "code": 0,    "data": {        "bot_id": "737946218936519****",        "completed_at": 1718609575,        "conversation_id": "738136585609548****",        "created_at": 1718609571,        "id": "738137187639794****",        "status": "completed",        "usage": {            "input_count": 242,            "output_count": 56,            "token_count": 298        }    },    "msg": ""}
Prompt: Please modify the code based on the request and response examples in @example.txt to improve the testing scenarios.
Thus, the code has been generated and runs without errors.
  • Generating a mind map based on the code

Once the code runs correctly, I asked Windsurf to generate a mind map based on the code.

Prompt: Please generate a mind map of test cases based on the test code.
Windsurf can only generate mind maps in Markdown format, which are as follows:
# Coze API Test Cases ## 1. Basic Configuration   - API Base URL: https://api.coze.cn   - API Version: v3   - Endpoint: /chat/retrieve   - Authentication Method: Bearer Token ## 2. Normal Scenario Tests (test_retrieve_chat_success)   ### Request Parameter Validation   - chat_id is correct   - conversation_id is correct      ### Response Validation   - HTTP status code is 200   - response code is 0   - msg field exists      ### Data Structure Validation   - Validate that the data object exists   - Validate basic chat information     * id     * conversation_id     * bot_id     * completed_at     * created_at     * status   - Validate usage information     * input_count     * output_count     * token_count ## 3. Abnormal Scenario Tests   ### Invalid chat_id (test_retrieve_chat_invalid_chat_id)   - Use an invalid chat_id   - Validate error response   - Check error message   ### Invalid conversation_id (test_retrieve_chat_invalid_conversation_id)   - Use an invalid conversation_id   - Validate error response   - Check error message   ### Missing Parameter Tests (test_retrieve_chat_missing_params)   - Missing chat_id   - Missing conversation_id   - Validate error response   ### Authentication Exception Tests (test_retrieve_chat_invalid_auth)   - Use an invalid authentication token   - Validate error response   - Check error message ## 4. Test Data   ### Example Values   - chat_id: ****   - conversation_id: ****   - bot_id: ****
Then use a tool to convert it into a visual mind map as shown below:
Windsurf: A Powerful Tool for API Automation Testing

Leave a Comment