forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat.feature
39 lines (34 loc) · 1.2 KB
/
cat.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
Feature: demo calling java methods with complex types
Background:
* call read('common.feature')
Scenario: using constructor and setters
* def billie = new Cat()
* eval billie.id = 1
* eval billie.name = 'Billie'
* match toJson(billie) == { id: 1, name: 'Billie' }
Scenario: using json and calling java methods
* def billie = toCat({ id: 1, name: 'Billie' })
* def bob = toCat({ id: 2, name: 'Bob' })
* def wild = toCat({ id: 3, name: 'Wild' })
* eval billie.addKitten(bob)
* eval billie.addKitten(wild)
* match toJson(billie) ==
"""
{
id: 1, name: 'Billie', kittens: [
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Wild' }
]
}
"""
Scenario Outline: data driven
* def billie = toCat({ id: 1, name: 'Billie' })
* def fun = function(n, i){ return { id: i + 2, name: n } }
* def kittens = karate.map(names, fun)
* eval billie.kittens = kittens
* match toJson(billie) contains expected
* match toJson(billie).kittens == expected.kittens
Examples:
| names! | expected! |
| ['Bob', 'Wild'] | { kittens: '#[2]' } |
| ['X', 'Y', 'Z'] | { kittens: '#[3]' } |