-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyCollection_postman_collection.json
92 lines (92 loc) · 2.26 KB
/
MyCollection_postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
"info": {
"_postman_id": "982f5c34-8b58-4fad-8569-9ec270456322",
"name": "MyProductApi Collection",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "5106050"
},
"item": [
{
"name": "Get Products By Name",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:5159/product/{{productRequestedName}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "5159",
"path": [
"product",
"{{productRequestedName}}"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"if(pm.iterationData.get(\"productRequestedName\") != undefined)",
"{",
" var productRequestedName = pm.iterationData.get(\"productRequestedName\");",
" pm.collectionVariables.set(\"productRequestedName\", productRequestedName);",
"",
" var productExpectedName = pm.iterationData.get(\"productExpectedName\");",
" pm.collectionVariables.set(\"productResponseName\", productExpectedName);",
"",
" var productPrice = pm.iterationData.get(\"price\");",
" pm.collectionVariables.set(\"productPrice\", productPrice);",
"}"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var resultApi = pm.response.json();",
"",
"pm.test(\"Api Retorno OK\", function(){",
" pm.response.to.be.ok;",
" pm.response.to.json;",
" pm.response.to.be.withBody;",
"})",
"",
"pm.test(\"Verificar nome do produto retornado pela api\", function(){",
" pm.expect(resultApi.name).to.equal(pm.collectionVariables.get(\"productResponseName\"));",
"});",
"",
"pm.test(\"Verificar valor do produto retornado pela api\", function(){",
" pm.expect(resultApi.price).to.eql(JSON.parse(pm.collectionVariables.get(\"productPrice\")));",
"});",
""
]
}
}
],
"variable": [
{
"key": "productRequestedName",
"value": "smart",
"type": "string"
},
{
"key": "productPrice",
"value": "800",
"type": "string"
},
{
"key": "productResponseName",
"value": "Smart TV",
"type": "string"
}
]
}