Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
12.89k stars 482 forks source link

Add expected value field in all assert Error Message #3012

Open fabricereix opened 3 months ago

fabricereix commented 3 months ago

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;>
   |
jcamiel commented 3 months ago

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

fabricereix commented 3 months ago

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

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": 𝄢,
   |