Skip to content

Commit b0ab9a0

Browse files
author
A-5ingh
committed
fix: improve test summary reporting by adjusting cleanup order
Signed-off-by: A-5ingh <[email protected]>
1 parent b110d9b commit b0ab9a0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/runner/runner.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,6 @@ func (r *runner) run(ctx context.Context, m mainstart, nsOptions v1alpha2.Namesp
114114
if test.Test.Spec.Concurrent == nil || *test.Test.Spec.Concurrent {
115115
t.Parallel()
116116
}
117-
// setup summary
118-
defer func() {
119-
if t.Skipped() {
120-
tc.IncSkipped()
121-
} else if t.Failed() {
122-
tc.IncFailed()
123-
} else {
124-
tc.IncPassed()
125-
}
126-
}()
127117
// setup reporting
128118
report := &model.TestReport{
129119
BasePath: test.BasePath,
@@ -136,6 +126,16 @@ func (r *runner) run(ctx context.Context, m mainstart, nsOptions v1alpha2.Namesp
136126
report.Skipped = t.Skipped()
137127
tc.Add(report)
138128
}()
129+
// setup summary - must run after all other cleanup (registered first to run last in LIFO order)
130+
t.Cleanup(func() {
131+
if t.Skipped() {
132+
tc.IncSkipped()
133+
} else if t.Failed() {
134+
tc.IncFailed()
135+
} else {
136+
tc.IncPassed()
137+
}
138+
})
139139
// skip check
140140
if test.Test.Spec.Skip != nil && *test.Test.Spec.Skip {
141141
t.SkipNow()

0 commit comments

Comments
 (0)