Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include flakyFailures block in retry count #1118

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 54 additions & 28 deletions __tests__/testParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1025,34 +1025,60 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
])
})

describe('resolveFileAndLine', () => {
it('merge flaky tests, and include retry count', async () => {
const {totalCount, skipped, annotations} = await parseFile(
'test_results/junit-web-test/expectedRetries.xml',
'',
true,
true
)
const filtered = annotations.filter(annotation => annotation.retries > 0)

expect(totalCount).toBe(7)
expect(skipped).toBe(1)
expect(filtered).toStrictEqual([
{
path: 'packages/test-runner-junit-reporter/test/fixtures/multiple/simple-test.js',
start_line: 15,
end_line: 15,
retries: 1,
start_column: 0,
end_column: 0,
annotation_level: 'notice',
status: 'success',
title: 'packages/test-runner-junit-reporter/test/fixtures/multiple/simple-test.js.retried flaky test',
message: 'retried flaky test',
raw_details: ''
}
])
})
it('merge flaky tests, and include retry count', async () => {
const {totalCount, skipped, annotations} = await parseFile(
'test_results/junit-web-test/expectedRetries.xml',
'',
true,
true
)
const filtered = annotations.filter(annotation => annotation.retries > 0)

expect(totalCount).toBe(7)
expect(skipped).toBe(1)
expect(filtered).toStrictEqual([
{
path: 'packages/test-runner-junit-reporter/test/fixtures/multiple/simple-test.js',
start_line: 15,
end_line: 15,
retries: 1,
start_column: 0,
end_column: 0,
annotation_level: 'notice',
status: 'success',
title: 'packages/test-runner-junit-reporter/test/fixtures/multiple/simple-test.js.retried flaky test',
message: 'retried flaky test',
raw_details: ''
}
])
})

it('flaky tests, and include retry count', async () => {
const {totalCount, skipped, annotations} = await parseFile(
'test_results/junit_flaky_failure/marathon_junit_report.xml',
'',
true,
true
)
const filtered = annotations.filter(annotation => annotation.retries > 0)

expect(totalCount).toBe(1)
expect(skipped).toBe(0)
expect(filtered).toStrictEqual([
{
"annotation_level": "notice",
"end_column": 0,
"end_line": 1,
"message": "testFlakyFailure",
"path": "Class",
"raw_details": "",
"retries": 1,
"start_column": 0,
"start_line": 1,
"status": "success",
"title": "Class.testFlakyFailure"
}
])
})

it('should parse and transform perl results', async () => {
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ async function parseSuite(
// the action only supports 1 failure per testcase
const failure = failures ? failures[0] : undefined

// identify amount of flaky failures
const flakyFailuresCount = testcase.flakyFailure
? Array.isArray(testcase.flakyFailure)
? testcase.flakyFailure.length
: 1
: 0

const stackTrace: string = (
(failure && failure._cdata) ||
(failure && failure._text) ||
Expand Down Expand Up @@ -415,7 +422,7 @@ async function parseSuite(
end_line: pos.line,
start_column: 0,
end_column: 0,
retries: testcase.retries || 0,
retries: (testcase.retries || 0) + flakyFailuresCount,
annotation_level: annotationLevel,
status: skip ? 'skipped' : success ? 'success' : 'failure',
title: escapeEmoji(title),
Expand Down
12 changes: 12 additions & 0 deletions test_results/junit_flaky_failure/marathon_junit_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/jenkinsci/xunit-plugin/ae25da5089d4f94ac6c4669bf736e4d416cc4665/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="omni" tests="1" failures="0" errors="0" time="9.56"
skipped="0" timestamp="2024-01-21T08:17:32">
<testcase name="testFlakyFailure" time="1.86"
classname="com.mikepenz.Class">
<flakyFailure type="rerun exception">
<stackTrace><![CDATA[junit.framework.AssertionFailedError]]></stackTrace>
</flakyFailure>
</testcase>
</testsuite>
Loading