I tried to use Windsurf to write the code for interface automation testing, and actually felt its convenience and efficiency.Windsurf does not require high code ability of the user, and at the same time, the accuracy of the generated code is high. What's more, the scenario coverage of the test cases generated by Windsurf is also relatively high. When the code is completed, Windsurf is also able to automatically generate a mind map, providing a convenient manual review. Overall use, I feel that this is a powerful tool for writing test code.
- Write interface test code based on Coze's APIs
Hint word: This is a python project, please generate the interface test code according to the interface information described in the online documentation. https://www.coze.cn/docs/developer_guides/retrieve_chat
After using the above cues, Windsurf was able to generate Python code properly and was runnable. However, both Windsurf and Cursor were less effective in recognizing Coze's online API documentation, with some errors in recognizing key information about the interface. So, I copied the sample requests and responses from the documentation to a local txt file and then asked Windsurf to recognize them. This time the accuracy of the recognition was very high. A detailed description of the interface can be found at: https://www.coze.cn/docs/developer_guides/retrieve_chat. Sample request and answer examples are below:
Sample request:
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'
Return sample:
{
"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": ""
}
Cue: 请根据@example.txt里面的请求和返回样例修改代码 to refine the test scenarios
At this point, the code has been generated and runs without error.
- Generate mind maps from code
Once the code was working properly, I had Windsurf generate mind maps based on the code.
Hint word: Please generate a mind map of the test case based on the test code
Windsurf can only generate mind maps in Markdown format 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 test (test_retrieve_chat_success)
### Request parameter validation
- chat_id correct
- conversation_id correct
### Response Validation
- HTTP status code is 200
- Response code code is 0
- msg field exists
### Data structure validation
- Verify that the data object exists
- Verify chat basic information
* id
* :: conversation_id
* :: bot_id
* :: completed_at
* :: created_at
* :: Status
- Verify usage information
* :: input_count
* :: output_count
* :: token_count
## 3. Abnormal Scenario Testing
### Invalid chat_id (test_retrieve_chat_invalid_chat_id)
- Using an invalid chat_id
- Validating Error Responses
- Check for error messages
### Invalid conversation_id (test_retrieve_chat_invalid_conversation_id)
- Using an invalid conversation_id
- Validating Error Responses
- Check for error messages
### Missing Parameters Test (test_retrieve_chat_missing_params)
- Missing chat_id
- Missing conversation_id
- Validating Error Responses
### Authentication Exception Test (test_retrieve_chat_invalid_auth)
- Use of invalid authentication tokens
- Validating Error Responses
- Check for error messages
## 4. Test Data
### Example Values
- chat_id: ****
- conversation_id: ****
- bot_id: ****