Skip to content

Commit

Permalink
Add failed test in HTML/JUnit/TAP reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Oct 27, 2023
1 parent 20982f4 commit 23a1eb1
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 25 deletions.
2 changes: 2 additions & 0 deletions integration/tests_ok/html.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'

# Some tests are failing but we want to continue until the end
$ErrorActionPreference = "Continue"
hurl --test `
--report-html build\tmp\ `
--glob "tests_ok\test.*.hurl"
Expand Down
2 changes: 2 additions & 0 deletions integration/tests_ok/html.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -Eeuo pipefail

# Some tests are failing but we want to continue until the end
set +euo pipefail
hurl --test \
--report-html build/ \
--glob "tests_ok/test.*.hurl"
Expand Down
25 changes: 16 additions & 9 deletions integration/tests_ok/junit.err.pattern
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
tests_ok~test.1.hurl: Running [1/2]
tests_ok~test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok~test.2.hurl: Running [2/2]
tests_ok~test.2.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.1.hurl: Running [1/2]
tests_ok/test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.2.hurl: Running [2/2]
error: Assert body value
--> tests_ok/test.2.hurl:8:1
|
8 | `Goodbye World!`
| ^^^^^^^^^^^^^^^^ actual value is <Hello World!>
|

tests_ok/test.2.hurl: Failure (2 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 2
Succeeded files: 2 (100.0%)
Failed files: 0 (0.0%)
Duration: ~ ms
Succeeded files: 1 (50.0%)
Failed files: 1 (50.0%)
Duration: ~~~ ms

tests_ok~test.3.hurl: Running [1/1]
tests_ok~test.3.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.3.hurl: Running [1/1]
tests_ok/test.3.hurl: Success (1 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 1
Succeeded files: 1 (100.0%)
Expand Down
7 changes: 6 additions & 1 deletion integration/tests_ok/junit.out.pattern
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite tests="2" errors="0" failures="0"><testcase id="tests_ok/test.1.hurl" name="tests_ok/test.1.hurl" time="~~~" /><testcase id="tests_ok/test.2.hurl" name="tests_ok/test.2.hurl" time="~~~" /></testsuite><testsuite tests="1" errors="0" failures="0"><testcase id="tests_ok/test.3.hurl" name="tests_ok/test.3.hurl" time="~~~" /></testsuite></testsuites>
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite tests="2" errors="0" failures="1"><testcase id="tests_ok/test.1.hurl" name="tests_ok/test.1.hurl" time="~~~" /><testcase id="tests_ok/test.2.hurl" name="tests_ok/test.2.hurl" time="~~~"><failure>Assert body value
--> tests_ok/test.2.hurl:8:1
|
8 | `Goodbye World!`
| ^^^^^^^^^^^^^^^^ actual value is &lt;Hello World!>
|</failure></testcase></testsuite><testsuite tests="1" errors="0" failures="0"><testcase id="tests_ok/test.3.hurl" name="tests_ok/test.3.hurl" time="~~~" /></testsuite></testsuites>
5 changes: 5 additions & 0 deletions integration/tests_ok/junit.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
rm -f build/result.xml

# test.2.hurl is KO but we don't the script ton continue until the end
set +eo pipefail
hurl --test --report-junit build/result.xml tests_ok/test.1.hurl tests_ok/test.2.hurl
hurl --test --report-junit build/result.xml tests_ok/test.3.hurl
set -Eeuo pipefail

cat build/result.xml
2 changes: 1 addition & 1 deletion integration/tests_ok/tap.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TAP version 13
1..3
ok 1 - tests_ok/test.1.hurl
ok 2 - tests_ok/test.2.hurl
not ok 2 - tests_ok/test.2.hurl
ok 3 - tests_ok/test.3.hurl
5 changes: 5 additions & 0 deletions integration/tests_ok/tap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ $ErrorActionPreference = 'Stop'
if (Test-Path build/result.tap) {
Remove-Item build/result.tap
}

# test.2.hurl is KO but we don't the script ton continue until the end
$ErrorActionPreference = 'Continue'
hurl --test --report-tap build/result.tap tests_ok/test.1.hurl tests_ok/test.2.hurl
hurl --test --report-tap build/result.tap tests_ok/test.3.hurl
$ErrorActionPreference = 'Stop'

Write-Host (Get-Content build/result.tap -Raw) -NoNewLine
5 changes: 5 additions & 0 deletions integration/tests_ok/tap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
rm -f build/result.tap

# test.2.hurl is KO but we don't the script ton continue until the end
set +eo pipefail
hurl --test --report-tap build/result.tap tests_ok/test.1.hurl tests_ok/test.2.hurl
hurl --test --report-tap build/result.tap tests_ok/test.3.hurl
set -Eeuo pipefail

cat build/result.tap
8 changes: 6 additions & 2 deletions integration/tests_ok/test.2.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
</span><span class="response"><span class="line"></span>
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">`Hello World!`</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">`Goodbye World!`</span></span>
</span></span></code></pre>
6 changes: 5 additions & 1 deletion integration/tests_ok/test.2.hurl
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
GET http://localhost:8000/hello

HTTP 200
`Hello World!`


GET http://localhost:8000/hello
HTTP 200
`Goodbye World!`
2 changes: 1 addition & 1 deletion integration/tests_ok/test.2.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Goodbye World!"}}}]}
23 changes: 15 additions & 8 deletions integration/tests_ok/test.err.pattern
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
tests_ok~test.1.hurl: Running [1/3]
tests_ok~test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok~test.2.hurl: Running [2/3]
tests_ok~test.2.hurl: Success (1 request(s) in ~~~ ms)
tests_ok~test.3.hurl: Running [3/3]
tests_ok~test.3.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.1.hurl: Running [1/3]
tests_ok/test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.2.hurl: Running [2/3]
error: Assert body value
--> tests_ok/test.2.hurl:8:1
|
8 | `Goodbye World!`
| ^^^^^^^^^^^^^^^^ actual value is <Hello World!>
|

tests_ok/test.2.hurl: Failure (2 request(s) in ~~~ ms)
tests_ok/test.3.hurl: Running [3/3]
tests_ok/test.3.hurl: Success (1 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 3
Succeeded files: 3 (100.0%)
Failed files: 0 (0.0%)
Succeeded files: 2 (66.7%)
Failed files: 1 (33.3%)
Duration: ~~~ ms

1 change: 1 addition & 0 deletions integration/tests_ok/test.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
4 changes: 2 additions & 2 deletions packages/hurl/src/report/tap/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ mod tests {
let s = r#"1..3
ok 1 - tests_ok/test.1.hurl
ok 2 -tests_ok/test.2.hurl
nok 3 - tests_ok/test.3.hurl
not ok 3 - tests_ok/test.3.hurl
"#;
assert_eq!(
Expand Down Expand Up @@ -177,7 +177,7 @@ nok 3 - tests_ok/test.3.hurl
1..3
ok 1 - tests_ok/test.1.hurl
ok 2 -tests_ok/test.2.hurl
nok 3 - tests_ok/test.3.hurl
not ok 3 - tests_ok/test.3.hurl
"#;
assert_eq!(
Expand Down

0 comments on commit 23a1eb1

Please sign in to comment.