-
Notifications
You must be signed in to change notification settings - Fork 520
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 --fail-fast to stop executing tests when if there are asserts error #3354
Comments
Hi, I would like to work on this issue. Can I take this on? |
Hi @krakenbite You can of course but be warned that this one can be more difficult that it seems. For a starter, you can also work on issues labeled "good first issues"
good first issue
|
@jcamiel Thanks for your response! I already had a look at the code and I think I already found the right places which need modification. As we currently bail-out on errors, question is how we want to handle errors in the future. How do we want to display them to the user if one or several files have issues? Also, I think I can have a look at this issue as I like to challenge myself with difficult problems and don't need an issue labeled
good first issue
|
Hi @krakenbite Trying to give you some examples, I'm realizing that we're alredy in "no fail fast" mode. $ hurl --test --jobs 1 *.hurl
a.hurl: Success (1 request(s) in 157 ms)
b.hurl: Success (1 request(s) in 164 ms)
error: Assert status code
--> c.hurl:2:6
|
| HEAD https://hurl.dev
2 | HTTP 300
| ^^^ actual value is <200>
|
c.hurl: Failure (1 request(s) in 166 ms)
error: Assert failure
--> d.hurl:4:0
|
| GET https://hurl.dev
| ...
4 | xpath "string(//title)" == "foo"
| actual: string <Hurl - Run and Test HTTP Requests>
| expected: string <foo>
|
d.hurl: Failure (1 request(s) in 242 ms)
e.hurl: Success (1 request(s) in 162 ms)
f.hurl: Success (1 request(s) in 169 ms)
g.hurl: Success (1 request(s) in 172 ms)
h.hurl: Success (1 request(s) in 172 ms)
i.hurl: Success (1 request(s) in 165 ms)
j.hurl: Success (1 request(s) in 243 ms)
k.hurl: Success (1 request(s) in 168 ms)
l.hurl: Success (1 request(s) in 173 ms)
m.hurl: Success (1 request(s) in 180 ms)
--------------------------------------------------------------------------------
Executed files: 13
Executed requests: 13 (5.5/s)
Succeeded files: 11 (84.6%)
Failed files: 2 (15.4%)
Duration: 2378 ms Note that we're talking about assertion failure, all the file are valid Hurl files. If one of the file is not syntaxically correct, we're stopping execution asap. We do not want to change the running behavior when some files are not valid Hurl files. So, we can change the issue to support a "fail fast" mode, which is not the default. In this mode, running the previous test will display: $ hurl --test --jobs 1 --fail-fast *.hurl
a.hurl: Success (1 request(s) in 157 ms)
b.hurl: Success (1 request(s) in 164 ms)
error: Assert status code
--> c.hurl:2:6
|
| HEAD https://hurl.dev
2 | HTTP 300
| ^^^ actual value is <200>
|
--------------------------------------------------------------------------------
Executed files: 3
Executed requests: 3 (5.5/s)
Succeeded files: 2 (66.6%)
Failed files: 1 (33.3%)
Duration: 1200 ms Note: this option doesn't affect existing Example: if there are multiple errors in $ hurl --test --continue-on-error --fail-fast --jobs 1 *.hurl
a.hurl: Success (1 request(s) in 161 ms)
b.hurl: Success (1 request(s) in 163 ms)
error: Assert status code
--> c.hurl:2:6
|
| HEAD https://hurl.dev
2 | HTTP 300
| ^^^ actual value is <200>
|
error: HTTP connection
--> c.hurl:5:5
|
5 | GET https://goog.vom
| ^^^^^^^^^^^^^^^^ (6) Could not resolve host: goog.vom
|
c.hurl: Failure (1 request(s) in 197 ms)
--------------------------------------------------------------------------------
Executed files: 3
Executed requests: 3 (5.5/s)
Succeeded files: 2 (66.6%)
Failed files: 1 (33.3%)
Duration: 1200 ms Whereas without $ hurl --test --fail-fast --jobs 1 *.hurl
a.hurl: Success (1 request(s) in 161 ms)
b.hurl: Success (1 request(s) in 163 ms)
error: Assert status code
--> c.hurl:2:6
|
| HEAD https://hurl.dev
2 | HTTP 300
| ^^^ actual value is <200>
|
c.hurl: Failure (1 request(s) in 197 ms)
--------------------------------------------------------------------------------
Executed files: 3
Executed requests: 3 (5.5/s)
Succeeded files: 2 (66.6%)
Failed files: 1 (33.3%)
Duration: 1200 ms (I'm changing the issue title from |
Hi @jcamiel, thank you very much for the extensive explanation. I now understand that I was thinking about the errors in a wrong way. Hence I suggest that we should not use only the term error but the more explicit variants file error (which covers things like bad syntax, file not found, etc.) and execution error (errors that are only related to the execution of a file like a non-reachable URL, an assertion error, etc.) to avoid future misconception of the term error. We can also use other terms for the variants if you have a better suggestion for them, this is what I could think of right now. I have another question as you already brought up the flag Of course we would keep the |
Hi @krakenbite You're right about the distinction on errors. We use to speak about two types of errors:
We don't want to change the behavior of Hurl with syntax errors. As soon as there is a syntax error, Hurl exits and we don't want, for the moment, add any option to keep going. This is mainly to avoid us to deal with some edge cases: for instance, if there is a syntax error, we don't have to manage the display of broken Hurl files in HTML reports, where the color highlighting is only working on valid Hurl files. One can also see it as if there is a kind of pre-compilation pass of all the input files. There is also the case of the pub fn run(
content: &str,
filename: Option<&Input>,
runner_options: &RunnerOptions,
variables: &VariableSet,
logger_options: &LoggerOptions,
) -> Result<HurlResult, String> {
} This function fails only if Now, regarding What we have now is:
Actually we have , by default: I completely agree it's confusing. Myself, I've to refer to the docs (and sometimes check the code) to remember what's doing what. |
When a Hurl file is in error, we stop the tests run as soon as we can (the default is "fail fast")
For instance:
Given
b.hurl
is in error, executed tests will only bea.hurl
andb.hurl
.We have an option called
--continue-on-error
that, if one Hurl file is in error, will try to execute this file until the end.As the doc tells:
So we need another option to run all Hurl files, regardless of there are error or not =>
--no-fail-fast
.The text was updated successfully, but these errors were encountered: