hurl
hurl copied to clipboard
Improving Assert Error for String
Here is a typical assert error in hurl.
error: Assert Failure
--> tests/error_assert_value_error.hurl:8:0
|
8 | jsonpath "$.count" greaterThan 5
| actual: int <2>
| expected: greater than int <5>
|
This error is quite clear, but for string comparison, it might not be as clear.
For example, for multiline string, you may receive the following error
error: Assert Failure
--> test.hurl:4:0
|
4 | body equals "one\ntwo\nthree"
| actual: string <one
| to
| three>
| expected: string <one
| two
| three>
|
It could be better to display both the actual and expected strings on one line. Converting the newline character to \n
The previous error would become:
error: Assert Failure
--> test.hurl:4:0
|
4 | body equals "one\ntwo\nthree"
| actual: string <one\nto\nthree>
| expected: string <one\ntwo\nthree>
|
To go one step further, the different characters could be highlighted (for example in red) one\ntwo\nthree