Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save testautomation/6ffdf48c928ea30c8d9882e05a23ddef to your computer and use it in GitHub Desktop.
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
*** 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