Skip to content

Commit 4744223

Browse files
committed
- change failed and passed counting
1 parent ade5e40 commit 4744223

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

dist/index.js

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/testParser.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface ActualTestResult {
99
name: string
1010
totalCount: number
1111
skippedCount: number
12+
failedCount: number
13+
passedCount: number
1214
retriedCount: number
1315
annotations: Annotation[]
1416
globalAnnotations: Annotation[]
@@ -18,6 +20,8 @@ export interface ActualTestResult {
1820
interface TestCasesResult {
1921
totalCount: number
2022
skippedCount: number
23+
failedCount: number
24+
passedCount: number
2125
retriedCount: number
2226
annotations: Annotation[]
2327
}
@@ -283,6 +287,8 @@ async function parseSuite(
283287

284288
let totalCount = 0
285289
let skippedCount = 0
290+
let failedCount = 0
291+
let passedCount = 0
286292
let retriedCount = 0
287293
const annotations: Annotation[] = []
288294

@@ -314,6 +320,8 @@ async function parseSuite(
314320
// expand global annotations array
315321
totalCount += parsedTestCases.totalCount
316322
skippedCount += parsedTestCases.skippedCount
323+
failedCount += parsedTestCases.failedCount
324+
passedCount += parsedTestCases.passedCount
317325
retriedCount += parsedTestCases.retriedCount
318326
annotations.push(...parsedTestCases.annotations)
319327
globalAnnotations.push(...parsedTestCases.annotations)
@@ -324,6 +332,8 @@ async function parseSuite(
324332
name: suiteName,
325333
totalCount,
326334
skippedCount,
335+
failedCount,
336+
passedCount,
327337
retriedCount,
328338
annotations,
329339
globalAnnotations,
@@ -366,6 +376,8 @@ async function parseSuite(
366376
childSuiteResults.push(childSuiteResult)
367377
totalCount += childSuiteResult.totalCount
368378
skippedCount += childSuiteResult.skippedCount
379+
failedCount += childSuiteResult.failedCount
380+
passedCount += childSuiteResult.passedCount
369381
retriedCount += childSuiteResult.retriedCount
370382
}
371383

@@ -375,6 +387,8 @@ async function parseSuite(
375387
name: suiteName,
376388
totalCount,
377389
skippedCount,
390+
failedCount,
391+
passedCount,
378392
retriedCount,
379393
annotations,
380394
globalAnnotations,
@@ -387,6 +401,8 @@ async function parseSuite(
387401
name: suiteName,
388402
totalCount,
389403
skippedCount,
404+
failedCount,
405+
passedCount,
390406
retriedCount,
391407
annotations,
392408
globalAnnotations,
@@ -582,9 +598,13 @@ async function parseTestCases(
582598
if (limit >= 0 && annotations.length >= limit) break
583599
}
584600

601+
const failedCount = annotations.filter(a => a.annotation_level === 'failure').length
602+
const passedCount = totalCount - failedCount - skippedCount
585603
return {
586604
totalCount,
587605
skippedCount,
606+
failedCount,
607+
passedCount,
588608
retriedCount,
589609
annotations
590610
}
@@ -622,6 +642,8 @@ export async function parseTestReports(
622642
const testResults: ActualTestResult[] = []
623643
let totalCount = 0
624644
let skipped = 0
645+
let failed = 0
646+
let passed = 0
625647
let retried = 0
626648
let foundFiles = 0
627649
for await (const file of globber.globGenerator()) {
@@ -648,9 +670,11 @@ export async function parseTestReports(
648670
)
649671

650672
if (!testResult) continue
651-
const {totalCount: c, skippedCount: s, retriedCount: r} = testResult
673+
const {totalCount: c, skippedCount: s, failedCount: f, passedCount: p, retriedCount: r} = testResult
652674
totalCount += c
653675
skipped += s
676+
failed += f
677+
passed += p
654678
retried += r
655679
testResults.push(testResult)
656680

@@ -659,10 +683,6 @@ export async function parseTestReports(
659683
}
660684
}
661685

662-
// get the count of passed and failed tests.
663-
const failed = globalAnnotations.filter(a => a.annotation_level === 'failure').length
664-
const passed = totalCount - failed - skipped
665-
666686
return {
667687
checkName,
668688
summary,

test_results/multiple/test_11.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<testsuites failures="0" tests="8" time="1967986371">
2-
<testsuite name = "test">
2+
<testsuite>
33
<testcase name="Command Test: apt-get upgrade" time="999638317"></testcase>
44
<testcase name="File Existence Test: /home/app/app" time="0"></testcase>
55
<testcase name="Metadata Test" time="0">
6-
<failure message="failure"></failure>
6+
<failure message="AssertionError: assert">SackTrace</failure>
77
</testcase>
88
</testsuite>
99
</testsuites>

0 commit comments

Comments
 (0)