hurl icon indicating copy to clipboard operation
hurl copied to clipboard

Add expected value field in all assert Error Message

Open fabricereix opened this issue 1 year ago • 2 comments

Currently, the expected value is taken from the input Hurl file for example

error: Assert body value
  --> tests_failed/assert_base64.hurl:12:8
   |
   | GET http://localhost:8000/error-assert-base64
   | ...
12 | base64,bGluZTEKbGluZTIKbGluZTMK;
   |        ^^^^^^^^^^^^^^^^^^^^^^^^ actual value is <hex, 6c696e65310a6c696e65320d0a6c696e65330a;>
   |

Display the expected value along the actual value using the same format.

error: Assert body value
  --> tests_failed/assert_base64.hurl:12:8
   |
   | GET http://localhost:8000/error-assert-base64
   | ...
12 | base64,bGluZTEKbGluZTIKbGluZTMK;
   |        ^^^^^^^^^^^^^^^^^^^^^^^^ expected: <hex, 6c696e65310a6c696e65320d0a6c696e65330a;>
   |                                 actual:   <hex, 6c696e65310a6c696e65320d0a00696e6533;>
   |

fabricereix avatar Jul 04 '24 15:07 fabricereix

Another possibiliy:

error: Assert body value
  --> tests_failed/assert_base64.hurl:12:8
   |
   | GET http://localhost:8000/error-assert-base64
   | ...
12 | base64,bGluZTEKbGluZTIKbGluZTMK;
   |        ^^^^^^^^^^^^^^^^^^^^^^^^
   |   actual:   <hex, 6c696e65310a6c696e65320d0a00696e6533;>
   |   expected: <hex, 6c696e65310a6c696e65320d0a6c696e65330a;>
   |

To be like explicit asserts

jcamiel avatar Jul 04 '24 15:07 jcamiel

We can indeed try to display for all the assert errors:

  • the exact line in the input Hurl file with its line number. This is the context. It can contain variables and Hurl escaping.
  • the expected/actual values

Example for the diff assert errors:

error: Assert body value
  --> test.hurl:8:1
   |
   | GET http://localhost:8000/test
   | ...
 8 |   "age": {{age}}
   |     -  "age": 27,
   |     +  "age": 28,
   |
error: Assert body value
  --> test.hurl:8:1
   |
   | GET http://localhost:8000/test
   | ...
 8 |   "g_clef": "\uD834\uDD1E",
   |     -  "g_clef": 𝄞,
   |     +  "f_clef": 𝄢,
   |

fabricereix avatar Jul 04 '24 17:07 fabricereix