Regular Expressions
While comparing actual and expected files, some dynamical values might appear. For instance, in actual file with results of HTTP or SQL query (IDs, timestamp, etc). To avoid exception while comparison, you can use the following list of regular expression:
name | pattern |
---|---|
p(any) | any sequence of any symbols |
p(digit) | integer value (1,2,3,4,5...) |
p(money) | float value (100.10, 532.83...) |
p(email) | example123@gmail.com |
p(ip) | 10.10.10.10 |
p(url) | http://google.com |
p(uuid) | 550e8400-e29b-41d4-a716-446655440000 |
p(color) | #1f1f1f |
p(y-m-d) | 2015-11-12 |
p(d-m-y) | 12-11-2015 |
p(notEmpty) | any symbols but not empty |
Here is an example of using regular expressions in expected file:
{
"id": "p(digit)",
"token": "p(any)"
}
Also, we can set condition for our expected value. For instance:
condition | description |
---|---|
c(>100) | any integer value more than 100 |
c(>-111.11) | any float value more than -111.11 |
c(<=145387) | any integer value lower than or equal to 145387 |
c(>2001-02-16 20:00:00) | any timestamp after 2001-02-16 20:00:00 |
c(<=now) | any timestamp before or equal to the current timestamp |