简介
什么是接口?
系统进行数据交换的桥梁。
为什么要做接口?
- 保证整个数据的准确性
- 所有的app 都是调用接口与后台进行数据交互的,所以如果接口出现了问题,影响所有的应用。接口的重要性比较高。
怎么做的接口测试?
- 使用PostMan
- 使用Jmeter
postman 工具做接口
下载安装
https://www.postman.com/downloads/
使用Postman
练习
请求方式:GET
请求地址: http://49.233.108.117:3000/api/v1/topics
请求参数:
- page Number 页数
- tab String 主题分类。目前有 ask share job good
- limit Number 每一页的主题数量
- mdrender String 当为 false 时,不渲染。默认为 true,渲染出现的所有 markdown 格式文本。
返回结果
{
"success": true,
"data": [
{
"id": "6150675e25504b519d4d17af",
"author_id": "61370a1e4a677a514ffbd3bd",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>床前明月光,疑是地上霜。举头望明月,低头思故乡。</p>\n</div>",
"title": "静夜诗-李白",
"last_reply_at": "2021-09-26T12:28:14.951Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 2,
"create_at": "2021-09-26T12:28:14.951Z",
"author": {
"loginname": "wanxinliang",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "615063d5372165072343a1d6",
"author_id": "61370a1e4a677a514ffbd3bd",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>床前明月光,疑是地上霜。举头望明月,低头思故乡。</p>\n</div>",
"title": "静夜诗-李白",
"last_reply_at": "2021-09-26T12:13:09.759Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T12:13:09.759Z",
"author": {
"loginname": "wanxinliang",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "615062f0ef0a1d515f503bd9",
"author_id": "6136fd78882368516c0bf9f1",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>努力学习,开心找工作 加油!!!</p>\n</div>",
"title": "今天复习接口 哈哈哈哈哈啦啦啦",
"last_reply_at": "2021-09-26T12:09:20.901Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-09-26T12:09:20.901Z",
"author": {
"loginname": "sunhaimei",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "6150612aa1c1f16f129a4e11",
"author_id": "6136fd78882368516c0bf9f1",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>努力学习,开心找工作 加油!!!</p>\n</div>",
"title": "今天复习接口 哈哈哈哈哈啦啦啦",
"last_reply_at": "2021-09-26T12:01:46.475Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-09-26T12:01:46.475Z",
"author": {
"loginname": "sunhaimei",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503e30bee17109c791947f",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
"title": "11111111111111111",
"last_reply_at": "2021-09-26T09:32:32.367Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:32:32.367Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503e1bb2e1206ef2ae3ce4",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
"title": "11111111111111111",
"last_reply_at": "2021-09-26T09:32:11.305Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:32:11.305Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503db8ef0a1d515f503bd7",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
"title": "11111111111111111",
"last_reply_at": "2021-09-26T09:30:32.123Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:30:32.123Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503dad25504b519d4d17a6",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
"title": "11111111111111111",
"last_reply_at": "2021-09-26T09:30:21.212Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:30:21.212Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503bf581000551adafdd9b",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>222222222222222</p>\n</div>",
"title": "111111111111",
"last_reply_at": "2021-09-26T09:23:01.747Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:23:01.747Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503be5c0827a5179eb635d",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>222222222222222</p>\n</div>",
"title": "111111111111",
"last_reply_at": "2021-09-26T09:22:45.891Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:22:45.891Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "615039e9372165072343a1cf",
"author_id": "6136c8dfef0a1d515f5028e0",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
"title": "这是一个测试分享模块的话题",
"last_reply_at": "2021-09-26T09:14:17.146Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:14:17.146Z",
"author": {
"loginname": "testuser2",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503892bee17109c791947b",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
"title": "111111111111111111",
"last_reply_at": "2021-09-26T09:08:34.220Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:08:34.220Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503836a1c1f16f129a4e0b",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
"title": "111111111111111111",
"last_reply_at": "2021-09-26T09:07:02.567Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:07:02.567Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503828ef0a1d515f503bcf",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
"title": "111111111111111111",
"last_reply_at": "2021-09-26T09:06:48.938Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:06:48.938Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "61503791bee17109c7919474",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>hahahahaahahaha</p>\n</div>",
"title": "hahahahaahahaha",
"last_reply_at": "2021-09-26T09:04:17.408Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:04:17.408Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "6150370e372165072343a1cc",
"author_id": "6136c8d9882368516c0bf9e6",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>测试下测试测试下测试测试下测试</p>\n</div>",
"title": "测试下测试测试下测试",
"last_reply_at": "2021-09-26T09:02:06.895Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 1,
"create_at": "2021-09-26T09:02:06.895Z",
"author": {
"loginname": "testuser1",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "615011efa1c1f16f129a4dff",
"author_id": "61370269c0827a5179eb4bc7",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>sanshizuihaola</p>\n</div>",
"title": "keaidesanshi",
"last_reply_at": "2021-09-26T06:23:43.746Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 3,
"create_at": "2021-09-26T06:23:43.746Z",
"author": {
"loginname": "yu_miao691",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "6150084d25504b519d4d1790",
"author_id": "6136fd6b882368516c0bf9f0",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>laotian</p>\n</div>",
"title": "woyoulailtietie",
"last_reply_at": "2021-09-26T05:42:37.179Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-09-26T05:42:37.179Z",
"author": {
"loginname": "lihuangcnodc",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "615007f8a1c1f16f129a4df9",
"author_id": "6136fd2aef0a1d515f5028e3",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>上山打老虎</p>\n</div>",
"title": "一二三四五",
"last_reply_at": "2021-09-26T05:41:12.508Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-09-26T05:41:12.508Z",
"author": {
"loginname": "guoyuru",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "615006f1ef0a1d515f503bbc",
"author_id": "6136fd4a191f5651564c20b4",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>我我我我88我我我我88</p>\n</div>",
"title": "我我我我88",
"last_reply_at": "2021-09-26T05:36:49.514Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-09-26T05:36:49.514Z",
"author": {
"loginname": "lantian",
"avatar_url": "/public/images/userlogo.png"
}
}
]
}
请使用postman 发送这个请求,并查看服务器返回的结果;
添加参数查看服务器返回结果