Atlas › Test

TestReadJUnitReport

Exact test identity: go.temporal.io/server/tools/testrunner/TestReadJUnitReport

Package
go.temporal.io/server/tools/testrunner
Suite / test hierarchy
TestReadJUnitReport
Test
TestReadJUnitReport
Introduced at
junit.go ×1 Frontier kind: Joint frontier
Covered ranges
9
Covered lines
26
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/testrunner/junit.go 26 covered LOC · 9 ranges

Open complete file

38 }
39
40 > func (j *junitReport) read() error { junit.go
41 > f, err := os.Open(j.path)
42 > if err != nil {
43 return fmt.Errorf("failed to open junit report file: %w", err)
44 }
45 > defer f.Close() junit.go
46 >
47 > decoder := xml.NewDecoder(f)
48 > if err = decoder.Decode(&j.Testsuites); err != nil {
49 return fmt.Errorf("failed to read junit report file: %w", err)
50 }
51 > return nil junit.go
52 }
53
225 }
226
227 > func (j *junitReport) collectTestCaseFailures() []string { junit.go
228 > var failures []string
229 > for _, suite := range j.Suites {
230 > if suite.Failures == 0 {
231 continue
232 }
233 > for _, tc := range suite.Testcases { junit.go
234 > if tc.Failure != nil {
235 > failures = append(failures, tc.Name)
236 > }
237 }
238 }
239
240 // Sort lexicographically
241 > slices.Sort(failures) junit.go
242 >
243 > // Find leaf failures using the simplified algorithm
244 > var leafFailures []string
245 > for i := 0; i < len(failures)-1; i++ {
246 > if !strings.HasPrefix(failures[i+1], failures[i]+"/") { junit.go
247 leafFailures = append(leafFailures, failures[i])
248 }
249 }
250 > if len(failures) > 0 { junit.go
251 > leafFailures = append(leafFailures, failures[len(failures)-1])
252 > }
253
254 > return leafFailures junit.go
255 }
256