forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.feature
54 lines (45 loc) · 2.38 KB
/
examples.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
52
53
54
Feature: patterns for using cucumber scenario-outline and examples with karate
Background:
* url demoBaseUrl
Scenario Outline: name: <name> and country: <country>
avoid empty cells and use null in 'Examples' to work better with karate
and also consider stuffing whole chunks of json into cells
Given path 'search'
And params { name: <name>, country: <country>, active: <active>, limit: <limit> }
When method get
Then status 200
# response should NOT contain a key expected to be missing
And match response !contains <missing>
Examples:
| name | country | active | limit | missing |
| 'foo' | 'IN' | true | 1 | {} |
| 'bar' | null | null | 5 | { country: '#notnull', active: '#notnull' } |
| 'baz' | 'JP' | null | null | { active: '#notnull', limit: '#notnull' } |
| null | 'US' | null | 3 | { name: '#notnull', active: '#notnull' } |
| null | null | false | null | { name: '#notnull', country: '#notnull', limit: '#notnull' } |
Scenario Outline: expressions - index: <index> and country: <country>
combine 'Examples' embedded expressions and karate expression evaluation
* def names = { first: 'foo', second: 'bar', third: 'baz', fourth: null, fifth: null }
* def missing =
"""
[
{},
{ country: '#notnull', active: '#notnull' },
{ active: '#notnull', limit: '#notnull' },
{ name: '#notnull', active: '#notnull' },
{ name: '#notnull', country: '#notnull', limit: '#notnull' }
]
"""
Given path 'search'
# note how the Examples column for 'name' works here
And params { name: '#(<name>)', country: <country>, active: <active>, limit: <limit> }
When method get
Then status 200
And match response !contains missing[<index>]
Examples:
| name | country | active | limit | index |
| names.first | 'IN' | true | 1 | 0 |
| names.second | null | null | 5 | 1 |
| names.third | 'JP' | null | null | 2 |
| names.fourth | 'US' | null | 3 | 3 |
| names.fifth | null | false | null | 4 |