mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-09-11 05:35:53 +03:00
Update tutorial's snippets.
This commit is contained in:
parent
651f3bd694
commit
22c14e4a0a
@ -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
|
||||
[1mhello.hurl[0m: [1;36mRunning[0m [1/2]
|
||||
[1mhello.hurl[0m: [1;32mSuccess[0m (6 request(s) in 245 ms)
|
||||
[1massert_json.hurl[0m: [1;36mRunning[0m [2/2]
|
||||
[1massert_json.hurl[0m: [1;32mSuccess[0m (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>
|
||||
|
|
||||
[1mhello.hurl[0m: [1;36mRunning[0m [1/2]
|
||||
[1mhello.hurl[0m: [1;32mSuccess[0m (6 request(s) in 258 ms)
|
||||
[1massert_json.hurl[0m: [1;36mRunning[0m [2/2]
|
||||
[1;31merror[0m: [1mAssert status code[0m
|
||||
[1;34m-->[0m assert_json.hurl:6:8
|
||||
[1;34m|[0m
|
||||
[1;34m 6[0m [1;34m|[0m HTTP/* 200
|
||||
[1;34m|[0m [1;31m^^^[0m [1;31mactual value is <301>[0m
|
||||
[1;34m|[0m
|
||||
|
||||
error_assert_status.hurl: FAILURE
|
||||
-------------------------------------------------------------
|
||||
Executed: 2
|
||||
Succeeded: 1 (50.0%)
|
||||
Failed: 1 (50.0%)
|
||||
Duration: 52ms
|
||||
[1massert_json.hurl[0m: [1;31mFailure[0m (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:
|
||||
|
@ -58,12 +58,12 @@ xpath "string(//head/title)" == "Welcome to Quiz!"
|
||||
```shell
|
||||
$ hurl --test basic.hurl
|
||||
[1mbasic.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m (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
|
||||
[1;34m|[0m [1;31mexpected: string <Welcome to Quaz!>[0m
|
||||
[1;34m|[0m
|
||||
|
||||
[1mbasic.hurl[0m: [1;31mFailure[0m
|
||||
[1mbasic.hurl[0m: [1;31mFailure[0m (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
|
||||
[1mbasic.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m (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
|
||||
[1mbasic.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m (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
|
||||
|
@ -73,12 +73,12 @@ $ hurl --test create-quiz.hurl
|
||||
[1;34m|[0m [1;31m^^^[0m [1;31mactual value is <403>[0m
|
||||
[1;34m|[0m
|
||||
|
||||
[1mcreate-quiz.hurl[0m: [1;31mFailure[0m
|
||||
[1mcreate-quiz.hurl[0m: [1;31mFailure[0m (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
|
||||
[1mcreate-quiz.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m (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
|
||||
[1mcreate-quiz.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m (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
|
||||
```
|
||||
|
||||
|
||||
|
@ -72,12 +72,12 @@ description.
|
||||
```shell
|
||||
$ hurl --test basic.hurl
|
||||
[1mbasic.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m (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
|
||||
[1mbasic.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m (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
|
||||
|
@ -154,14 +154,14 @@ Wait 4s
|
||||
Wait 5s
|
||||
Running Hurl tests
|
||||
[1mintegration/basic.hurl[0m: [1;36mRunning[0m [1/2]
|
||||
[1mintegration/basic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mintegration/basic.hurl[0m: [1;32mSuccess[0m (4 request(s) in 18 ms)
|
||||
[1mintegration/create-quiz.hurl[0m: [1;36mRunning[0m [2/2]
|
||||
[1mintegration/create-quiz.hurl[0m: [1;32mSuccess[0m
|
||||
[1mintegration/create-quiz.hurl[0m: [1;32mSuccess[0m (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
|
||||
```
|
||||
|
@ -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
|
||||
[1mcreate-quiz.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m (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
|
||||
[1mcreate-quiz.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m
|
||||
[1mcreate-quiz.hurl[0m: [1;32mSuccess[0m (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
|
||||
|
@ -161,12 +161,12 @@ test output:
|
||||
```shell
|
||||
$ hurl --test basic.hurl
|
||||
[1mbasic.hurl[0m: [1;36mRunning[0m [1/1]
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m
|
||||
[1mbasic.hurl[0m: [1;32mSuccess[0m (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
|
||||
[1;34m|[0m [1;31m^^^[0m [1;31mactual value is <200>[0m
|
||||
[1;34m|[0m
|
||||
|
||||
[1mbasic.hurl[0m: [1;31mFailure[0m
|
||||
[1mbasic.hurl[0m: [1;31mFailure[0m (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:
|
||||
|
Loading…
Reference in New Issue
Block a user