Skip to content

Commit 6f5a9c9

Browse files
authored
fix: user executor failures missing from JUnit/XML/JSON/HTML reports (#907)
Signed-off-by: Ivan Velasco <ivan.velasco@socotra.com>
1 parent 087050d commit 6f5a9c9

6 files changed

Lines changed: 71 additions & 7 deletions

process_testcase.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,7 @@ func (v *Venom) setTestStepName(ts *TestStepResult, e ExecutorRunner, step TestS
419419
// Print a single step result (if verbosity is enabled)
420420
func (v *Venom) printTestStepResult(tc *TestCase, ts *TestStepResult, tsIn *TestStepResult, stepNumber int, mustAssertionFailed bool) {
421421
fromUserExecutor := tsIn != nil
422-
if fromUserExecutor {
423-
// move back up user executor errors to parent test step for later logging
424-
tsIn.Errors = append(tsIn.Errors, ts.Errors...)
425-
426-
// move back up user executor logs to parent test step for later logging
427-
tsIn.ComputedInfo = append(tsIn.ComputedInfo, ts.ComputedInfo...)
428-
} else if v.Verbose >= 1 {
422+
if !fromUserExecutor && v.Verbose >= 1 {
429423
if len(ts.Errors) > 0 {
430424
v.Println(" %s", Red(StatusFail))
431425
for _, i := range ts.ComputedInfo {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
executor: nested_fail_inner
2+
input:
3+
message: "default_inner"
4+
steps:
5+
- type: exec
6+
script: echo '{{.input.message}}'
7+
assertions:
8+
- result.code ShouldEqual 0
9+
- type: exec
10+
script: echo 'this assertion will fail'
11+
assertions:
12+
- result.systemout ShouldEqual "this will never match"
13+
output:
14+
result: "{{.result.systemout}}"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
executor: nested_fail_outer
2+
input:
3+
greeting: "hello"
4+
steps:
5+
- type: exec
6+
script: echo 'outer step 1 ok'
7+
assertions:
8+
- result.code ShouldEqual 0
9+
- type: nested_fail_inner
10+
message: '{{.input.greeting}}_from_outer'
11+
output:
12+
result: "{{.result.systemout}}"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
executor: user_executor_with_failure
2+
input:
3+
expected_result: "success"
4+
5+
steps:
6+
- type: exec
7+
script: echo "this step succeeds"
8+
assertions:
9+
- result.code ShouldEqual 0
10+
11+
- type: exec
12+
script: echo "failing step"
13+
assertions:
14+
- result.code ShouldEqual 1
15+
16+
output:
17+
result: "{{.result.systemout}}"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: user executor failure propagation
2+
testcases:
3+
- name: simple user executor failure
4+
steps:
5+
- type: user_executor_with_failure
6+
7+
- name: nested user executor failure (outer calls inner which fails)
8+
steps:
9+
- type: nested_fail_outer
10+
greeting: "world"

types_executor.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,23 @@ func (v *Venom) RunUserExecutor(ctx context.Context, runner ExecutorRunner, tcIn
285285

286286
v.runTestSteps(ctx, tc, tsIn)
287287

288+
// Merge inner step results into the parent test step result so they
289+
// appear in JUnit XML, JSON, HTML, and other report outputs.
290+
for _, innerResult := range tc.TestStepResults {
291+
if len(innerResult.Errors) > 0 {
292+
tsIn.Errors = append(tsIn.Errors, innerResult.Errors...)
293+
}
294+
if len(innerResult.ComputedInfo) > 0 {
295+
tsIn.ComputedInfo = append(tsIn.ComputedInfo, innerResult.ComputedInfo...)
296+
}
297+
if strings.TrimSpace(innerResult.Systemout) != "" {
298+
tsIn.Systemout += innerResult.Systemout
299+
}
300+
if strings.TrimSpace(innerResult.Systemerr) != "" {
301+
tsIn.Systemerr += innerResult.Systemerr
302+
}
303+
}
304+
288305
computedVars, err := DumpString(tc.computedVars)
289306
if err != nil {
290307
return nil, errors.Wrapf(err, "unable to dump testcase computedVars")

0 commit comments

Comments
 (0)