AI Personal Learning
and practical guidance
讯飞绘镜

Windsurf: a tool for writing code for interface automation testing

I tried to use Windsurf After writing the code for interface automation testing, I actually felt its convenience and efficiency.Windsurf does not require high code ability of users, and the accuracy rate of generated code is high at the same time. What's more, the scenario coverage of the test cases generated by Windsurf is also relatively high. When the code is completed, Windsurf can also 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
提示词:这是一个python项目,请根据在线文档描述的接口信息,生成接口测试代码。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:

请求样例: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' 返回样例:{    "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": ""}

 

提示词:请根据@example.txt里面的请求和返回样例修改代码,完善测试场景

At this point, the code has been generated and runs without error.

  • Generate mind maps from code

Once the code was working, I had Windsurf generate mind maps based on the code.

提示词:请根据测试代码生成测试案例的思维导图

Windsurf can only generate mind maps in Markdown format as follows:

# Coze API 测试案例## 1. 基础配置   - API 基础 URL: https://api.coze.cn   - API 版本: v3   - 端点: /chat/retrieve   - 认证方式: Bearer Token## 2. 正常场景测试 (test_retrieve_chat_success)   ### 请求参数验证   - chat_id 正确   - conversation_id 正确      ### 响应验证   - HTTP 状态码为 200   - 响应码 code 为 0   - msg 字段存在      ### 数据结构验证   - 验证 data 对象存在   - 验证 chat 基本信息     * id     * conversation_id     * bot_id     * completed_at     * created_at     * status   - 验证 usage 信息     * input_count     * output_count     * token_count## 3. 异常场景测试   ### 无效的 chat_id (test_retrieve_chat_invalid_chat_id)   - 使用无效的 chat_id   - 验证错误响应   - 检查错误信息   ### 无效的 conversation_id (test_retrieve_chat_invalid_conversation_id)   - 使用无效的 conversation_id   - 验证错误响应   - 检查错误信息   ### 缺少参数测试 (test_retrieve_chat_missing_params)   - 缺少 chat_id   - 缺少 conversation_id   - 验证错误响应   ### 认证异常测试 (test_retrieve_chat_invalid_auth)   - 使用无效的认证令牌   - 验证错误响应   - 检查错误信息## 4. 测试数据   ### 示例值   - chat_id: ****   - conversation_id: ****   - bot_id: ****
May not be reproduced without permission:Chief AI Sharing Circle " Windsurf: a tool for writing code for interface automation testing
en_USEnglish