Created
March 5, 2020 13:56
-
-
Save testautomation/6ffdf48c928ea30c8d9882e05a23ddef to your computer and use it in GitHub Desktop.
RESTInstance example - JSON Schema keyword `pattern` for testing if a JSON string contains something
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
*** Settings *** | |
Library REST | |
*** Test Cases *** | |
Use JSON Schema keyword pattern to test JSON string for substrings | |
[Setup] GET https://jsonplaceholder.typicode.com/users/1 | |
# matches "Leanne Graham" as a substring: | |
String response body name pattern="anne Grah" | |
# quotes are not necessary, it is still read as a string by the library: | |
String response body name pattern=anne Grah | |
# pattern supports regular expressions: | |
String response body name pattern=(sqilz|Leanne Graham) | |
# checking that 'name' does not contain the word: | |
String response body name pattern=^((?!asyrjasalo).)*$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source: asyrjasalo/RESTinstance#12 (comment)