@@ -119,15 +119,21 @@ func parseTestResults(filePaths []string) ([]reports.TestResult, error) {
119119 return nil , fmt .Errorf ("failed to parse json test output: %s, err: %w" , scanner .Text (), err )
120120 }
121121
122- // Skip processing if the test name is empty
123- if entry .Test == "" {
124- continue
122+ // Determine the key based on whether Test is empty
123+ var key string
124+ if entry .Test != "" {
125+ key = entry .Package + "/" + entry .Test
126+ } else {
127+ key = entry .Package // Package-level key
125128 }
126129
127- key := entry .Package + "/" + entry .Test // Create a unique key using package and test name
128130 if _ , exists := testDetails [key ]; ! exists {
131+ testName := entry .Test
132+ if testName == "" {
133+ testName = "Package Level"
134+ }
129135 testDetails [key ] = & reports.TestResult {
130- TestName : entry . Test ,
136+ TestName : testName ,
131137 TestPackage : entry .Package ,
132138 Runs : 0 ,
133139 PassRatio : 0 ,
@@ -136,18 +142,28 @@ func parseTestResults(filePaths []string) ([]reports.TestResult, error) {
136142 }
137143
138144 result := testDetails [key ]
145+
146+ // Collect test outputs
147+ if entry .Output != "" {
148+ result .Outputs = append (result .Outputs , entry .Output )
149+ }
150+
139151 switch entry .Action {
140152 case "run" :
141153 result .Runs ++
142154 case "pass" :
143155 result .PassRatio = (result .PassRatio * float64 (result .Runs - 1 ) + 1 ) / float64 (result .Runs )
144156 result .PassRatioPercentage = fmt .Sprintf ("%.0f%%" , result .PassRatio * 100 )
145157 result .Durations = append (result .Durations , entry .Elapsed )
158+ case "fail" :
159+ result .PassRatio = (result .PassRatio * float64 (result .Runs - 1 )) / float64 (result .Runs )
160+ result .PassRatioPercentage = fmt .Sprintf ("%.0f%%" , result .PassRatio * 100 )
161+ result .Durations = append (result .Durations , entry .Elapsed )
146162 case "output" :
147- result . Outputs = append ( result . Outputs , entry . Output )
163+ // Output already handled above
148164 if panicRe .MatchString (entry .Output ) {
149165 if entry .Test != "" {
150- // Test-level panic: treat it as a failing test
166+ // Test-level panic
151167 result .Panicked = true
152168 } else {
153169 // Package-level panic
@@ -157,10 +173,6 @@ func parseTestResults(filePaths []string) ([]reports.TestResult, error) {
157173 result .PassRatioPercentage = fmt .Sprintf ("%.0f%%" , result .PassRatio * 100 )
158174 result .Durations = append (result .Durations , entry .Elapsed )
159175 }
160- case "fail" :
161- result .PassRatio = (result .PassRatio * float64 (result .Runs - 1 )) / float64 (result .Runs )
162- result .PassRatioPercentage = fmt .Sprintf ("%.0f%%" , result .PassRatio * 100 )
163- result .Durations = append (result .Durations , entry .Elapsed )
164176 case "skip" :
165177 result .Skipped = true
166178 result .Runs ++
0 commit comments