简介

什么是接口?

系统进行数据交换的桥梁。

接口基础 - 图1

为什么要做接口?

  1. 保证整个数据的准确性
  2. 所有的app 都是调用接口与后台进行数据交互的,所以如果接口出现了问题,影响所有的应用。接口的重要性比较高。

怎么做的接口测试?

  1. 使用PostMan
  2. 使用Jmeter

postman 工具做接口

下载安装

https://www.postman.com/downloads/
image.png

使用Postman

image.png

练习

请求方式: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 格式文本。

返回结果

  1. {
  2. "success": true,
  3. "data": [
  4. {
  5. "id": "6150675e25504b519d4d17af",
  6. "author_id": "61370a1e4a677a514ffbd3bd",
  7. "tab": "ask",
  8. "content": "<div class=\"markdown-text\"><p>床前明月光,疑是地上霜。举头望明月,低头思故乡。</p>\n</div>",
  9. "title": "静夜诗-李白",
  10. "last_reply_at": "2021-09-26T12:28:14.951Z",
  11. "good": false,
  12. "top": false,
  13. "reply_count": 0,
  14. "visit_count": 2,
  15. "create_at": "2021-09-26T12:28:14.951Z",
  16. "author": {
  17. "loginname": "wanxinliang",
  18. "avatar_url": "/public/images/userlogo.png"
  19. }
  20. },
  21. {
  22. "id": "615063d5372165072343a1d6",
  23. "author_id": "61370a1e4a677a514ffbd3bd",
  24. "tab": "ask",
  25. "content": "<div class=\"markdown-text\"><p>床前明月光,疑是地上霜。举头望明月,低头思故乡。</p>\n</div>",
  26. "title": "静夜诗-李白",
  27. "last_reply_at": "2021-09-26T12:13:09.759Z",
  28. "good": false,
  29. "top": false,
  30. "reply_count": 0,
  31. "visit_count": 1,
  32. "create_at": "2021-09-26T12:13:09.759Z",
  33. "author": {
  34. "loginname": "wanxinliang",
  35. "avatar_url": "/public/images/userlogo.png"
  36. }
  37. },
  38. {
  39. "id": "615062f0ef0a1d515f503bd9",
  40. "author_id": "6136fd78882368516c0bf9f1",
  41. "tab": "ask",
  42. "content": "<div class=\"markdown-text\"><p>努力学习,开心找工作 加油!!!</p>\n</div>",
  43. "title": "今天复习接口 哈哈哈哈哈啦啦啦",
  44. "last_reply_at": "2021-09-26T12:09:20.901Z",
  45. "good": false,
  46. "top": false,
  47. "reply_count": 0,
  48. "visit_count": 0,
  49. "create_at": "2021-09-26T12:09:20.901Z",
  50. "author": {
  51. "loginname": "sunhaimei",
  52. "avatar_url": "/public/images/userlogo.png"
  53. }
  54. },
  55. {
  56. "id": "6150612aa1c1f16f129a4e11",
  57. "author_id": "6136fd78882368516c0bf9f1",
  58. "tab": "ask",
  59. "content": "<div class=\"markdown-text\"><p>努力学习,开心找工作 加油!!!</p>\n</div>",
  60. "title": "今天复习接口 哈哈哈哈哈啦啦啦",
  61. "last_reply_at": "2021-09-26T12:01:46.475Z",
  62. "good": false,
  63. "top": false,
  64. "reply_count": 0,
  65. "visit_count": 0,
  66. "create_at": "2021-09-26T12:01:46.475Z",
  67. "author": {
  68. "loginname": "sunhaimei",
  69. "avatar_url": "/public/images/userlogo.png"
  70. }
  71. },
  72. {
  73. "id": "61503e30bee17109c791947f",
  74. "author_id": "6136c8d9882368516c0bf9e6",
  75. "tab": "share",
  76. "content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
  77. "title": "11111111111111111",
  78. "last_reply_at": "2021-09-26T09:32:32.367Z",
  79. "good": false,
  80. "top": false,
  81. "reply_count": 0,
  82. "visit_count": 1,
  83. "create_at": "2021-09-26T09:32:32.367Z",
  84. "author": {
  85. "loginname": "testuser1",
  86. "avatar_url": "/public/images/userlogo.png"
  87. }
  88. },
  89. {
  90. "id": "61503e1bb2e1206ef2ae3ce4",
  91. "author_id": "6136c8d9882368516c0bf9e6",
  92. "tab": "share",
  93. "content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
  94. "title": "11111111111111111",
  95. "last_reply_at": "2021-09-26T09:32:11.305Z",
  96. "good": false,
  97. "top": false,
  98. "reply_count": 0,
  99. "visit_count": 1,
  100. "create_at": "2021-09-26T09:32:11.305Z",
  101. "author": {
  102. "loginname": "testuser1",
  103. "avatar_url": "/public/images/userlogo.png"
  104. }
  105. },
  106. {
  107. "id": "61503db8ef0a1d515f503bd7",
  108. "author_id": "6136c8d9882368516c0bf9e6",
  109. "tab": "share",
  110. "content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
  111. "title": "11111111111111111",
  112. "last_reply_at": "2021-09-26T09:30:32.123Z",
  113. "good": false,
  114. "top": false,
  115. "reply_count": 0,
  116. "visit_count": 1,
  117. "create_at": "2021-09-26T09:30:32.123Z",
  118. "author": {
  119. "loginname": "testuser1",
  120. "avatar_url": "/public/images/userlogo.png"
  121. }
  122. },
  123. {
  124. "id": "61503dad25504b519d4d17a6",
  125. "author_id": "6136c8d9882368516c0bf9e6",
  126. "tab": "share",
  127. "content": "<div class=\"markdown-text\"><p>111111111111111111</p>\n</div>",
  128. "title": "11111111111111111",
  129. "last_reply_at": "2021-09-26T09:30:21.212Z",
  130. "good": false,
  131. "top": false,
  132. "reply_count": 0,
  133. "visit_count": 1,
  134. "create_at": "2021-09-26T09:30:21.212Z",
  135. "author": {
  136. "loginname": "testuser1",
  137. "avatar_url": "/public/images/userlogo.png"
  138. }
  139. },
  140. {
  141. "id": "61503bf581000551adafdd9b",
  142. "author_id": "6136c8d9882368516c0bf9e6",
  143. "tab": "share",
  144. "content": "<div class=\"markdown-text\"><p>222222222222222</p>\n</div>",
  145. "title": "111111111111",
  146. "last_reply_at": "2021-09-26T09:23:01.747Z",
  147. "good": false,
  148. "top": false,
  149. "reply_count": 0,
  150. "visit_count": 1,
  151. "create_at": "2021-09-26T09:23:01.747Z",
  152. "author": {
  153. "loginname": "testuser1",
  154. "avatar_url": "/public/images/userlogo.png"
  155. }
  156. },
  157. {
  158. "id": "61503be5c0827a5179eb635d",
  159. "author_id": "6136c8d9882368516c0bf9e6",
  160. "tab": "share",
  161. "content": "<div class=\"markdown-text\"><p>222222222222222</p>\n</div>",
  162. "title": "111111111111",
  163. "last_reply_at": "2021-09-26T09:22:45.891Z",
  164. "good": false,
  165. "top": false,
  166. "reply_count": 0,
  167. "visit_count": 1,
  168. "create_at": "2021-09-26T09:22:45.891Z",
  169. "author": {
  170. "loginname": "testuser1",
  171. "avatar_url": "/public/images/userlogo.png"
  172. }
  173. },
  174. {
  175. "id": "615039e9372165072343a1cf",
  176. "author_id": "6136c8dfef0a1d515f5028e0",
  177. "tab": "share",
  178. "content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
  179. "title": "这是一个测试分享模块的话题",
  180. "last_reply_at": "2021-09-26T09:14:17.146Z",
  181. "good": false,
  182. "top": false,
  183. "reply_count": 0,
  184. "visit_count": 1,
  185. "create_at": "2021-09-26T09:14:17.146Z",
  186. "author": {
  187. "loginname": "testuser2",
  188. "avatar_url": "/public/images/userlogo.png"
  189. }
  190. },
  191. {
  192. "id": "61503892bee17109c791947b",
  193. "author_id": "6136c8d9882368516c0bf9e6",
  194. "tab": "ask",
  195. "content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
  196. "title": "111111111111111111",
  197. "last_reply_at": "2021-09-26T09:08:34.220Z",
  198. "good": false,
  199. "top": false,
  200. "reply_count": 0,
  201. "visit_count": 1,
  202. "create_at": "2021-09-26T09:08:34.220Z",
  203. "author": {
  204. "loginname": "testuser1",
  205. "avatar_url": "/public/images/userlogo.png"
  206. }
  207. },
  208. {
  209. "id": "61503836a1c1f16f129a4e0b",
  210. "author_id": "6136c8d9882368516c0bf9e6",
  211. "tab": "ask",
  212. "content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
  213. "title": "111111111111111111",
  214. "last_reply_at": "2021-09-26T09:07:02.567Z",
  215. "good": false,
  216. "top": false,
  217. "reply_count": 0,
  218. "visit_count": 1,
  219. "create_at": "2021-09-26T09:07:02.567Z",
  220. "author": {
  221. "loginname": "testuser1",
  222. "avatar_url": "/public/images/userlogo.png"
  223. }
  224. },
  225. {
  226. "id": "61503828ef0a1d515f503bcf",
  227. "author_id": "6136c8d9882368516c0bf9e6",
  228. "tab": "ask",
  229. "content": "<div class=\"markdown-text\"><p>111111111111111</p>\n</div>",
  230. "title": "111111111111111111",
  231. "last_reply_at": "2021-09-26T09:06:48.938Z",
  232. "good": false,
  233. "top": false,
  234. "reply_count": 0,
  235. "visit_count": 1,
  236. "create_at": "2021-09-26T09:06:48.938Z",
  237. "author": {
  238. "loginname": "testuser1",
  239. "avatar_url": "/public/images/userlogo.png"
  240. }
  241. },
  242. {
  243. "id": "61503791bee17109c7919474",
  244. "author_id": "6136c8d9882368516c0bf9e6",
  245. "tab": "ask",
  246. "content": "<div class=\"markdown-text\"><p>hahahahaahahaha</p>\n</div>",
  247. "title": "hahahahaahahaha",
  248. "last_reply_at": "2021-09-26T09:04:17.408Z",
  249. "good": false,
  250. "top": false,
  251. "reply_count": 0,
  252. "visit_count": 1,
  253. "create_at": "2021-09-26T09:04:17.408Z",
  254. "author": {
  255. "loginname": "testuser1",
  256. "avatar_url": "/public/images/userlogo.png"
  257. }
  258. },
  259. {
  260. "id": "6150370e372165072343a1cc",
  261. "author_id": "6136c8d9882368516c0bf9e6",
  262. "tab": "share",
  263. "content": "<div class=\"markdown-text\"><p>测试下测试测试下测试测试下测试</p>\n</div>",
  264. "title": "测试下测试测试下测试",
  265. "last_reply_at": "2021-09-26T09:02:06.895Z",
  266. "good": false,
  267. "top": false,
  268. "reply_count": 0,
  269. "visit_count": 1,
  270. "create_at": "2021-09-26T09:02:06.895Z",
  271. "author": {
  272. "loginname": "testuser1",
  273. "avatar_url": "/public/images/userlogo.png"
  274. }
  275. },
  276. {
  277. "id": "615011efa1c1f16f129a4dff",
  278. "author_id": "61370269c0827a5179eb4bc7",
  279. "tab": "ask",
  280. "content": "<div class=\"markdown-text\"><p>sanshizuihaola</p>\n</div>",
  281. "title": "keaidesanshi",
  282. "last_reply_at": "2021-09-26T06:23:43.746Z",
  283. "good": false,
  284. "top": false,
  285. "reply_count": 0,
  286. "visit_count": 3,
  287. "create_at": "2021-09-26T06:23:43.746Z",
  288. "author": {
  289. "loginname": "yu_miao691",
  290. "avatar_url": "/public/images/userlogo.png"
  291. }
  292. },
  293. {
  294. "id": "6150084d25504b519d4d1790",
  295. "author_id": "6136fd6b882368516c0bf9f0",
  296. "tab": "ask",
  297. "content": "<div class=\"markdown-text\"><p>laotian</p>\n</div>",
  298. "title": "woyoulailtietie",
  299. "last_reply_at": "2021-09-26T05:42:37.179Z",
  300. "good": false,
  301. "top": false,
  302. "reply_count": 0,
  303. "visit_count": 0,
  304. "create_at": "2021-09-26T05:42:37.179Z",
  305. "author": {
  306. "loginname": "lihuangcnodc",
  307. "avatar_url": "/public/images/userlogo.png"
  308. }
  309. },
  310. {
  311. "id": "615007f8a1c1f16f129a4df9",
  312. "author_id": "6136fd2aef0a1d515f5028e3",
  313. "tab": "ask",
  314. "content": "<div class=\"markdown-text\"><p>上山打老虎</p>\n</div>",
  315. "title": "一二三四五",
  316. "last_reply_at": "2021-09-26T05:41:12.508Z",
  317. "good": false,
  318. "top": false,
  319. "reply_count": 0,
  320. "visit_count": 0,
  321. "create_at": "2021-09-26T05:41:12.508Z",
  322. "author": {
  323. "loginname": "guoyuru",
  324. "avatar_url": "/public/images/userlogo.png"
  325. }
  326. },
  327. {
  328. "id": "615006f1ef0a1d515f503bbc",
  329. "author_id": "6136fd4a191f5651564c20b4",
  330. "tab": "ask",
  331. "content": "<div class=\"markdown-text\"><p>我我我我88我我我我88</p>\n</div>",
  332. "title": "我我我我88",
  333. "last_reply_at": "2021-09-26T05:36:49.514Z",
  334. "good": false,
  335. "top": false,
  336. "reply_count": 0,
  337. "visit_count": 0,
  338. "create_at": "2021-09-26T05:36:49.514Z",
  339. "author": {
  340. "loginname": "lantian",
  341. "avatar_url": "/public/images/userlogo.png"
  342. }
  343. }
  344. ]
  345. }

请使用postman 发送这个请求,并查看服务器返回的结果;
image.png

添加参数查看服务器返回结果
image.png