-
Notifications
You must be signed in to change notification settings - Fork 40
Flaky failure #226
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
base: master
Are you sure you want to change the base?
Flaky failure #226
Changes from all commits
b57a151
aead19e
ab4fdd2
6dff639
8bad384
6da23c0
cb0799a
1b7435d
04f157c
31dff82
9905244
674e950
e9b9e34
52c7020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,22 +76,191 @@ func convertTestReport(report TestReport) testreport.TestReport { | |
|
||
func convertTestSuite(testSuite TestSuite) testreport.TestSuite { | ||
convertedTestSuite := testreport.TestSuite{ | ||
XMLName: testSuite.XMLName, | ||
Name: testSuite.Name, | ||
Tests: testSuite.Tests, | ||
Failures: testSuite.Failures + testSuite.Errors, | ||
Skipped: testSuite.Skipped, | ||
Time: testSuite.Time, | ||
XMLName: testSuite.XMLName, | ||
Name: testSuite.Name, | ||
Time: testSuite.Time, | ||
} | ||
|
||
for _, testCase := range testSuite.TestCases { | ||
tests := 0 | ||
failures := 0 | ||
skipped := 0 | ||
|
||
flattenedTestCases := flattenGroupedTestCases(testSuite.TestCases) | ||
for _, testCase := range flattenedTestCases { | ||
convertedTestCase := convertTestCase(testCase) | ||
convertedTestSuite.TestCases = append(convertedTestSuite.TestCases, convertedTestCase) | ||
|
||
if convertedTestCase.Failure != nil { | ||
failures++ | ||
} | ||
if convertedTestCase.Skipped != nil { | ||
skipped++ | ||
} | ||
tests++ | ||
} | ||
|
||
convertedTestSuite.Tests = tests | ||
convertedTestSuite.Failures = failures | ||
convertedTestSuite.Skipped = skipped | ||
|
||
return convertedTestSuite | ||
} | ||
|
||
func flattenGroupedTestCases(testCases []TestCase) []TestCase { | ||
var flattenedTestCases []TestCase | ||
for _, testCase := range testCases { | ||
flattenedTestCases = append(flattenedTestCases, testCase) | ||
|
||
if len(testCase.FlakyFailures) == 0 && len(testCase.FlakyErrors) == 0 && | ||
len(testCase.RerunFailures) == 0 && len(testCase.RerunErrors) == 0 { | ||
continue | ||
} | ||
|
||
flattenedTestCase := TestCase{ | ||
XMLName: testCase.XMLName, | ||
ConfigurationHash: testCase.ConfigurationHash, | ||
Name: testCase.Name, | ||
ClassName: testCase.ClassName, | ||
Time: 0, | ||
Failure: nil, | ||
Skipped: nil, | ||
Error: nil, | ||
FlakyFailures: nil, | ||
RerunFailures: nil, | ||
Comment on lines
+124
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you do not need to explicitly set these and omit them because they will be initialised to their default value which are what you just described here. |
||
} | ||
|
||
for _, flakyFailure := range testCase.FlakyFailures { | ||
flattenedTestCase.Failure = convertFlakyFailureToFailure(flakyFailure) | ||
flattenedTestCases = append(flattenedTestCases, flattenedTestCase) | ||
} | ||
|
||
for _, flakyError := range testCase.FlakyErrors { | ||
flattenedTestCase.Failure = convertFlakyErrorToFailure(flakyError) | ||
flattenedTestCases = append(flattenedTestCases, flattenedTestCase) | ||
} | ||
|
||
for _, rerunfailure := range testCase.RerunFailures { | ||
flattenedTestCase.Failure = convertRerunFailureToFailure(rerunfailure) | ||
flattenedTestCases = append(flattenedTestCases, flattenedTestCase) | ||
} | ||
|
||
for _, rerunError := range testCase.RerunErrors { | ||
flattenedTestCase.Failure = convertRerunErrorToFailure(rerunError) | ||
flattenedTestCases = append(flattenedTestCases, flattenedTestCase) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
} | ||
return flattenedTestCases | ||
} | ||
|
||
func convertFlakyFailureToFailure(flakyFailure FlakyFailure) *Failure { | ||
var message string | ||
if len(strings.TrimSpace(flakyFailure.Type)) > 0 { | ||
message = flakyFailure.Type | ||
} | ||
if len(strings.TrimSpace(flakyFailure.Message)) > 0 { | ||
if len(message) > 0 { | ||
message += ": " | ||
} | ||
message += flakyFailure.Message | ||
} | ||
|
||
if len(strings.TrimSpace(flakyFailure.SystemErr)) > 0 { | ||
if len(message) > 0 { | ||
message += "\n\n" | ||
} | ||
message += "System error:\n" + flakyFailure.SystemErr | ||
} | ||
|
||
if len(message) > 0 { | ||
return &Failure{ | ||
Value: message, | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func convertFlakyErrorToFailure(flakyError FlakyError) *Failure { | ||
var message string | ||
if len(strings.TrimSpace(flakyError.Type)) > 0 { | ||
message = flakyError.Type | ||
} | ||
if len(strings.TrimSpace(flakyError.Message)) > 0 { | ||
if len(message) > 0 { | ||
message += ": " | ||
} | ||
message += flakyError.Message | ||
} | ||
|
||
if len(strings.TrimSpace(flakyError.SystemErr)) > 0 { | ||
if len(message) > 0 { | ||
message += "\n\n" | ||
} | ||
message += "System error:\n" + flakyError.SystemErr | ||
} | ||
|
||
if len(message) > 0 { | ||
return &Failure{ | ||
Value: message, | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func convertRerunFailureToFailure(rerunFailure RerunFailure) *Failure { | ||
var message string | ||
if len(strings.TrimSpace(rerunFailure.Type)) > 0 { | ||
message = rerunFailure.Type | ||
} | ||
if len(strings.TrimSpace(rerunFailure.Message)) > 0 { | ||
if len(message) > 0 { | ||
message += ": " | ||
} | ||
message += rerunFailure.Message | ||
} | ||
|
||
if len(strings.TrimSpace(rerunFailure.SystemErr)) > 0 { | ||
if len(message) > 0 { | ||
message += "\n\n" | ||
} | ||
message += "System error:\n" + rerunFailure.SystemErr | ||
} | ||
|
||
if len(message) > 0 { | ||
return &Failure{ | ||
Value: message, | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func convertRerunErrorToFailure(rerunError RerunError) *Failure { | ||
var message string | ||
if len(strings.TrimSpace(rerunError.Type)) > 0 { | ||
message = rerunError.Type | ||
} | ||
if len(strings.TrimSpace(rerunError.Message)) > 0 { | ||
if len(message) > 0 { | ||
message += ": " | ||
} | ||
message += rerunError.Message | ||
} | ||
|
||
if len(strings.TrimSpace(rerunError.SystemErr)) > 0 { | ||
if len(message) > 0 { | ||
message += "\n\n" | ||
} | ||
message += "System error:\n" + rerunError.SystemErr | ||
} | ||
|
||
if len(message) > 0 { | ||
return &Failure{ | ||
Value: message, | ||
} | ||
} | ||
return nil | ||
} | ||
Comment on lines
+156
to
+262
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are identical functions with different parameter type but the used variables are the same on that given type. We could simplify this by receiving the actual variables as parameters:
|
||
|
||
func convertTestCase(testCase TestCase) testreport.TestCase { | ||
convertedTestCase := testreport.TestCase{ | ||
XMLName: testCase.XMLName, | ||
|
@@ -141,7 +310,8 @@ func convertErrorsToFailure(failure *Failure, error *Error, systemErr string) *t | |
|
||
if len(messages) > 0 { | ||
return &testreport.Failure{ | ||
Value: strings.Join(messages, "\n\n"), | ||
XMLName: xml.Name{Local: "failure"}, | ||
Value: strings.Join(messages, "\n\n"), | ||
} | ||
} | ||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to be explicit about leaving these empty, also add FlakyErrors and RetryErrors.
Or just leave them all out.