-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompleteExample.testsuite
More file actions
173 lines (143 loc) · 6.35 KB
/
CompleteExample.testsuite
File metadata and controls
173 lines (143 loc) · 6.35 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
TestCollection: CompleteExample
description: "This is an example test collection to show functionality"
Global Resources: // Accessible to all tests
TextResource @ "http://localhost:3000/text"
Persons @ "http://localhost:3000/persons"
Person @ "http://localhost:3000/persons/{personId}"
Addresses @ "http://localhost:3000/addresses"
Address @ "http://localhost:3000/addresses/{addressId}"
Global Headers: // Accessible to all tests
ApiKey name="Api-Key" value="xxx-api-xxx-key-xxx"
Secret name="secret" value="ThisIsTheSecret"
ClientName name="Client-Name" value= "Norway-Testing"
BehalfOf name="Behalf-of" value= "Sverige-Testing"
Headers included in every test:
ApiKey, Secret
Tests:
// Demonstrating Global resource vs local resource
Test name: Global_resource
GET @ TextResource
assert status code 200
Test name: Local_resource
GET Text @ "http://localhost:3000/text"
assert status code 200
// Demonstrating injecting var into resource url
Test name: Inject_var_into_url
Environment:
var person1Id reference="personId" /*<-- This is the reference in the url*/ value="23a1c108-97bf-4906-be5a-5872a566767b"
GET Person @ "http://localhost:3000/persons/{personId}" inject person1Id // <-- the injection
assert status code 200
Test name: Inject_var_into_subsequent_calls_url
Environment:
Object personBody has fields name = "Jone", job = "Developer"
var person1Id reference="personId"// This is the reference in the url
POST with body personBody @ Persons
save person1Id by ref // <-- saves personId from response body to environment var person1Id
assert status code 200
// The reason is to use an value from an call into the url in the next call:
GET Person @ "http://localhost:3000/persons/{personId}" inject person1Id // <-- the injection
assert status code 200
// Demonstrating different assertions
Test name: Assert_status_code
GET Text @ "http://localhost:3000/text"
assert status code 200
Test name: Assert_text
GET Text @ "http://localhost:3000/text"
assert text "This is the test text"
Test name: Assert_body_with_injected_personId
Environment:
var person1Id reference="personId" value="23a1c108-97bf-4906-be5a-5872a566767b"
Object personBody has fields name = "Ola Norman", job = "Elektriker"
GET @ Person inject person1Id
assert body personBody inject person1Id // <-- injects person id generated from API into test body to be able to assert the whole body
Test name: Assert_headers
Environment:
var headerValue reference="" /*not in use here, due to only demonstration */ value="Header-value"
Header HeaderWithRefToVar name="Header-with-ref" reference=headerValue
GET Text @ "http://localhost:3000/text" with header(s) HeaderWithRefToVar
assert header(s) ApiKey, Secret, xPower name="X-Powered-By" value="Express", HeaderWithRefToVar
Test name: Assert_multiple
GET Text @ "http://localhost:3000/text"
assert text "This is the test text"
assert status code 200
// Demonstrating headers
Test name: Globaly_included_headers
GET @ Persons
assert status code 200
Test name: Global_headers
GET @ Persons with header(s) ClientName, BehalfOf
assert status code 200
Test name: Local_headers
Environment:
Header LocalHeader1 name="Local-header-1" value="local-header-value-1"
Header LocalHeader2 name="Local-header-2" value="local-header-value-2"
GET @ Persons with header(s) LocalHeader1, LocalHeader2
assert status code 200
Test name: Global_and_Local_header
Environment:
Header LocalHeader1 name="Local-header-1" value="local-header-value-1"
GET @ Persons with header(s) ClientName, LocalHeader1
assert status code 200
Test name: Headers_with_reference_to_var
Environment:
var personJob reference="job"
Header PersonJobHeader name="person-job" reference=personJob
// Call to collect the data we want to use in next call
GET PersonWithId @ "http://localhost:3000/persons/23a1c108-97bf-4906-be5a-5872a566767b"
save personJob by ref // Save the value to the value used in the header
assert status code 200
// The reason is to use a saved value in subsequent calls
GET @ Persons with header(s) PersonJobHeader
assert status code 200
// Demonstrating how to include body
Test name: Post_body
Environment:
Object personBody has fields name = "Jone", job = "Developer"
POST with body personBody @ Persons
assert status code 200
Test name: Post_body_containing_body
Environment:
Object addressBody has fields street="Test street", popularity="High"
Object personBody has fields name = "Jone", job = "Developer", address -> addressBody
POST with body personBody @ Persons
assert status code 200
// Demonstrating normal use: Create two dependent objects, change object, delete object
Test name: SeperateAddress_test
Environment:
var addressId reference="addressId"
var person1Id reference="personId"
Object AddressBody has fields street="Test street", popularity="High"
Object PersonBodyWithSeperateAddress has fields name = "Body", tests = "Person without address"
Object personPutBody has fields name = "Ola", job = "CEO"
POST with body AddressBody @ Addresses
save addressId by ref
assert status code 200
POST with body PersonBodyWithSeperateAddress inject addressId @ Persons
save person1Id by ref
assert status code 200
assert body PersonBodyWithSeperateAddress inject addressId, person1Id
PUT with body personPutBody @ Person inject person1Id
assert body personPutBody inject person1Id
assert status code 200
DELETE @ Person inject person1Id
assert status code 200
DELETE @ Address inject addressId
assert status code 200
// Extended url injection testing
Test name: Url1_test
Environment:
Object Url1Body has fields url="/urltest1/value1/test/value2"
var TestId1 reference="firstId" value="value1"
var TestId2 reference="secondId" value="value2"
GET Url @ "http://localhost:3000/urltest1/{firstId}/test/{secondId}" inject TestId1, TestId2
assert status code 200
assert body Url1Body
Test name: Url2_test
Environment:
Object Url2Body has fields url="/urltest2/value1/value2/test"
var TestId1 reference="firstId" value="value1"
var TestId2 reference="secondId" value="value2"
GET UrlTest2 @ "http://localhost:3000/urltest2/{firstId}/{secondId}/test" inject TestId1, TestId2
assert status code 200
assert body Url2Body
// End