Skip to main content
Skip table of contents

测试用例编写指南及最佳实践 - Postman

Postman 是一个用于构建和使用 API 的平台。本文档展示了如何在 Testany 中编写 Postman 测试用例。

测试用例包 - 一个 zip 文件
目前我们仅支持将本地 zip 文件上传到 Testany,zip 文件需要至少包含一个文件:

  1. 测试用例代码文件,例如 hello-postman.postman_collection.json
    hello-postman.postman_collection.json

    JSON
    {
    	"info": {
    		"_postman_id": "2c19e161-6009-4237-8643-9c6df5b0c596",
    		"name": "hello-postman",
    		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    		"_exporter_id": "549544"
    	},
    	"item": [
    		{
    			"name": "website-active-check",
    			"event": [
    				{
    					"listen": "test",
    					"script": {
    						"exec": [
    							"pm.test(\"Status code is 200\", function(){",
    							"   pm.response.to.have.status(200);",
    							"})"
    						],
    						"type": "text/javascript"
    					}
    				}
    			],
    			"request": {
    				"method": "GET",
    				"header": [],
    				"url": {
    					"raw": "{{URL}}",
    					"host": [
    						"{{URL}}"
    					]
    				}
    			},
    			"response": []
    		}
    	]
    }

将所有相关文件压缩为一个 zip 文件,在这种情况下,测试用例包文件是

成功准备好 .zip 文件后,您将能够在 Testany 平台上注册您的测试用例。请参阅 《管理测试用例》 以获取注册的分步指南。

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.