Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expected value field in all assert Error Message #3012

Open
fabricereix opened this issue Jul 4, 2024 · 2 comments
Open

Add expected value field in all assert Error Message #3012

fabricereix opened this issue Jul 4, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@fabricereix
Copy link
Collaborator

fabricereix commented Jul 4, 2024

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 fabricereix added the enhancement New feature or request label Jul 4, 2024
@jcamiel
Copy link
Collaborator

jcamiel commented Jul 4, 2024

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
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants