Last active
September 20, 2017 05:47
-
-
Save ptrthomas/d6beb17e92a43220d254af942e3ed3d9 to your computer and use it in GitHub Desktop.
Karate's set via table approach for payload building: https://github.com/intuit/karate#set-multiple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: set via table where variable does not exist | |
note how karate will create parent paths if needed | |
* set foo | |
| path | value | | |
| bar | 'baz' | | |
| a.b | 'c' | | |
| fizz | { d: 'e' } | | |
* match foo == { bar: 'baz', a: { b: 'c' }, fizz: { d: 'e' } } | |
Scenario: set via table with fancy array paths and multi-dimensional arrays | |
* set foo | |
| path | value | | |
| bar[0] | 'baz' | | |
| a[0].b | 'ban' | | |
| c[0] | [1, 2] | | |
| c[1] | [3, 4] | | |
* match foo == { bar: [ 'baz'], a: [{ b: 'ban' }], c: [[1, 2], [3, 4]] } | |
Scenario: set via table, and blanks are skipped | |
* set search | |
| path | 0 | 1 | 2 | | |
| name.first | 'John' | 'Jane' | | | |
| name.last | 'Smith' | 'Doe' | 'Waldo' | | |
| age | 20 | | | | |
* match search[0] == { name: { first: 'John', last: 'Smith' }, age: 20 } | |
* match search[1] == { name: { first: 'Jane', last: 'Doe' } } | |
* match search[2] == { name: { last: 'Waldo' } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment