Update tutorial's snippets.

This commit is contained in:
jcamiel 2022-08-23 18:36:47 +02:00
parent 651f3bd694
commit 22c14e4a0a
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
7 changed files with 96 additions and 97 deletions

View File

@ -24,37 +24,37 @@ test tool with an adapted output, you can use [`--test` option]:
```shell
$ hurl --test hello.hurl assert_json.hurl
hello.hurl: RUNNING [1/2]
hello.hurl: SUCCESS
assert_json.hurl: RUNNING [2/2]
assert_json.hurl: SUCCESS
hello.hurl: Running [1/2]
hello.hurl: Success (6 request(s) in 245 ms)
assert_json.hurl: Running [2/2]
assert_json.hurl: Success (8 request(s) in 308 ms)
--------------------------------------------------------------------------------
Executed: 2
Succeeded: 2 (100.0%)
Failed: 0 (0.0%)
Duration: 427ms
Executed files: 2
Succeeded files: 2 (100.0%)
Failed files: 0 (0.0%)
Duration: 561 ms
```
Or, in case of errors:
```shell
$ hurl --test hello.hurl error_assert_status.hurl
hello.hurl: RUNNING [1/2]
hello.hurl: SUCCESS
error_assert_status.hurl: RUNNING [2/2]
error: Assert Status
--> error_assert_status.hurl:2:10
|
2 | HTTP/1.0 200
| ^^^ actual value is <404>
|
hello.hurl: Running [1/2]
hello.hurl: Success (6 request(s) in 258 ms)
assert_json.hurl: Running [2/2]
error: Assert status code
--> assert_json.hurl:6:8
|
 6 | HTTP/* 200
| ^^^ actual value is <301>
|
error_assert_status.hurl: FAILURE
-------------------------------------------------------------
Executed: 2
Succeeded: 1 (50.0%)
Failed: 1 (50.0%)
Duration: 52ms
assert_json.hurl: Failure (5 request(s) in 230 ms)
--------------------------------------------------------------------------------
Executed files: 2
Succeeded files: 1 (50.0%)
Failed files: 1 (50.0%)
Duration: 499 ms
```
You can use [`--glob` option] to test files that match a given patten:

View File

@ -58,12 +58,12 @@ xpath "string(//head/title)" == "Welcome to Quiz!"
```shell
$ hurl --test basic.hurl
basic.hurl: Running [1/1]
basic.hurl: Success
basic.hurl: Success (1 request(s) in 11 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 11ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 11 ms
```
There is no error so everything is good!
@ -93,12 +93,12 @@ $ hurl --test basic.hurl
| expected: string <Welcome to Quaz!>
|
basic.hurl: Failure
basic.hurl: Failure (1 request(s) in 7 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 0 (0.0%)
Failed: 1 (100.0%)
Duration: 6ms
Executed files: 1
Succeeded files: 0 (0.0%)
Failed files: 1 (100.0%)
Duration: 6 ms
```
Hurl has failed now and provides information on which assert is not valid.
@ -152,12 +152,12 @@ xpath "string((//button)[2])" contains "Create"
```shell
$ hurl --test basic.hurl
basic.hurl: Running [1/1]
basic.hurl: Success
basic.hurl: Success (1 request(s) in 11 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 5ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 11 ms
```
@ -268,12 +268,12 @@ cookie "JSESSIONID[HttpOnly]" exists
```shell
$ hurl --test basic.hurl
basic.hurl: Running [1/1]
basic.hurl: Success
basic.hurl: Success (1 request(s) in 11 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 6ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 11 ms
```
## Performance Test

View File

@ -73,12 +73,12 @@ $ hurl --test create-quiz.hurl
| ^^^ actual value is <403>
|
create-quiz.hurl: Failure
create-quiz.hurl: Failure (1 request(s) in 5 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 0 (0.0%)
Failed: 1 (100.0%)
Duration: 5ms
Executed files: 1
Succeeded files: 0 (0.0%)
Failed files: 1 (100.0%)
Duration: 5 ms
```
This is unexpected! Our test is failing, we're not redirected to the new quiz detail page.
@ -169,12 +169,12 @@ HTTP/1.1 302
```shell
$ hurl --test create-quiz.hurl
create-quiz.hurl: Running [1/1]
create-quiz.hurl: Success
create-quiz.hurl: Success (2 request(s) in 10 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 10ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 10 ms
```
## Follow Redirections
@ -258,12 +258,12 @@ HTTP/1.1 200
```shell
$ hurl --test create-quiz.hurl
create-quiz.hurl: Running [1/1]
create-quiz.hurl: Success
create-quiz.hurl: Success (3 request(s) in 39 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 10ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 46 ms
```

View File

@ -72,12 +72,12 @@ description.
```shell
$ hurl --test basic.hurl
basic.hurl: Running [1/1]
basic.hurl: Success
basic.hurl: Success (2 request(s) in 12 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 12ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 12 ms
```
We can see that the test is still ok, now two requests are ran in chain, and each response can be
@ -258,12 +258,12 @@ jsonpath "$[0].title" == "What is a pennyroyal?"
```shell
$ hurl --test basic.hurl
basic.hurl: Running [1/1]
basic.hurl: Success
basic.hurl: Success (4 request(s) in 24 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 14ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 31 ms
```
## Recap

View File

@ -154,14 +154,14 @@ Wait 4s
Wait 5s
Running Hurl tests
integration/basic.hurl: Running [1/2]
integration/basic.hurl: Success
integration/basic.hurl: Success (4 request(s) in 18 ms)
integration/create-quiz.hurl: Running [2/2]
integration/create-quiz.hurl: Success
integration/create-quiz.hurl: Success (6 request(s) in 18 ms)
--------------------------------------------------------------------------------
Executed: 2
Succeeded: 2 (100.0%)
Failed: 0 (0.0%)
Duration: 43ms
Executed files: 2
Succeeded files: 2 (100.0%)
Failed files: 0 (0.0%)
Duration: 48 ms
Stopping Quiz instance
quiz
```

View File

@ -162,17 +162,16 @@ HTTP/1.1 403
> We're using [the exist predicate] to check labels in the DOM
4. Run `create-quiz.hurl` and verify everything is ok:
4. Run `create-quiz.hurl` and verify that everything is ok:
```shell
$ hurl --test create-quiz.hurl
create-quiz.hurl: Running [1/1]
create-quiz.hurl: Success
create-quiz.hurl: Success (6 request(s) in 33 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 15ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 41 ms
```
## Comments
@ -209,17 +208,17 @@ xpath "//comment" count == 0 # Check that we don't leak comments
```
2. Run `create-quiz.hurl` and verify everything is ok:
2. Run `create-quiz.hurl` and verify that everything is ok:
```shell
$ hurl --test create-quiz.hurl
create-quiz.hurl: Running [1/1]
create-quiz.hurl: Success
create-quiz.hurl: Success (6 request(s) in 33 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 15ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 41 ms
```
## Recap

View File

@ -161,12 +161,12 @@ test output:
```shell
$ hurl --test basic.hurl
basic.hurl: Running [1/1]
basic.hurl: Success
basic.hurl: Success (1 request(s) in 8 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 1 (100.0%)
Failed: 0 (0.0%)
Duration: 7ms
Executed files: 1
Succeeded files: 1 (100.0%)
Failed files: 0 (0.0%)
Duration: 7 ms
```
6. Modify `basic.hurl` to test a different HTTP response status code:
@ -189,12 +189,12 @@ $ hurl --test basic.hurl
| ^^^ actual value is <200>
|
basic.hurl: Failure
basic.hurl: Failure (1 request(s) in 8 ms)
--------------------------------------------------------------------------------
Executed: 1
Succeeded: 0 (0.0%)
Failed: 1 (100.0%)
Duration: 5ms
Executed files: 1
Succeeded files: 0 (0.0%)
Failed files: 1 (100.0%)
Duration: 13 ms
```
8. Revert your changes and finally add a comment at the beginning of the file: