forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
call-table.feature
51 lines (39 loc) · 1.47 KB
/
call-table.feature
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
Feature: calling another feature file in a loop
Background:
* url demoBaseUrl
* table kittens
| name | age |
| 'Bob' | 2 |
| 'Wild' | 1 |
| 'Nyan' | 3 |
| 'Keyboard' | 5 |
| 'LOL' | 3 |
| 'Ceiling' | 2 |
* def result = call read('kitten-create.feature') kittens
# use json-path to 'un-pack' the array of kittens created
* def created = $result[*].response
# for each iteration, a variable called '__loop' is set for convenience
# which can be accessed in the called feature as well
* match result[*].__loop == [0, 1, 2, 3, 4, 5]
# which is not even needed for most data-driven assertions
* match created[*].name == $kittens[*].name
Scenario: create parent cat using kittens
# create mom cat
Given path 'cats'
And request { name: 'Billie', kittens: '#(created)' }
When method post
Then status 200
# the '^^' is an embeddable short-cut for 'contains only' !
And match response == { id: '#number', name: 'Billie', kittens: '#(^^created)' }
# get kittens for billie using the id from the previous response
Given path 'cats', $.id, 'kittens'
When method get
Then status 200
# some demo match examples
* match each response == { id: '#number', name: '#string' }
* match response == "#[6] { id: '#number', name: '#string' }"
# pure data-driven assertion, compare with the original data
* match response[*].name contains only $kittens[*].name
* assert response.length == 6
# prefer match instead of assert
* match response == '#[6]'