Skip to content

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Flaky failure #226

wants to merge 14 commits into from

Conversation

godrei
Copy link
Contributor

@godrei godrei commented Jun 25, 2025

Checklist

  • I've read and followed the Contribution Guidelines
  • step.yml and README.md is updated with the changes (if needed)

Version

Requires a MINOR version update

Context

This PR adds support for the JUnit report format described for Maven Surefire. The flakyFailure, flakyError, rerunFailure and rerunError elements are converted into a test case with failure preserving the order of test case runs.

@bitrise-coresteps-bot
Copy link
Contributor

Export test results to Test Reports add-on (multi_level_UI_tests) Test Results

🛑 3 out of 17 tests have failed!

testFailMe


XCTAssertTrue failed


testFailMe()


XCTAssertTrue failed


testFailMe2()


XCTAssertTrue failed


@bitrise-coresteps-bot
Copy link
Contributor

View build log

Base automatically changed from convert-junit-report-with-reruns-2 to master June 27, 2025 07:47
@bitrise-coresteps-bot
Copy link
Contributor

View build log

# Conflicts:
#	test/converters/converters_test.go
#	test/converters/junitxml/junitxml.go
#	test/converters/junitxml/junitxml_test.go
#	test/converters/junitxml/models.go
#	test/converters/xcresult3/action_invocation_record.go
#	test/junit/xml.go
#	test/test.go
#	test/testreport/test_report.go
@bitrise-coresteps-bot
Copy link
Contributor

Export test results to Test Reports add-on (multi_level_UI_tests) Test Results

🛑 3 out of 17 tests have failed!

testFailMe


XCTAssertTrue failed


testFailMe()


XCTAssertTrue failed


testFailMe2()


XCTAssertTrue failed


@bitrise-coresteps-bot
Copy link
Contributor

View build log

@bitrise-coresteps-bot
Copy link
Contributor

Export test results to Test Reports add-on (multi_level_UI_tests) Test Results

🛑 3 out of 17 tests have failed!

testFailMe


XCTAssertTrue failed


testFailMe()


XCTAssertTrue failed


testFailMe2()


XCTAssertTrue failed


@bitrise-coresteps-bot
Copy link
Contributor

View build log

@godrei godrei marked this pull request as ready for review June 27, 2025 09:01

for _, rerunError := range testCase.RerunErrors {
flattenedTestCase.Failure = convertRerunErrorToFailure(rerunError)
flattenedTestCases = append(flattenedTestCases, flattenedTestCase)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convertXXXToFailure is the same code 4x (insert rant about Go "interfaces").
Could we maybe replace them/delegate to something like convertToFailure(type, message, systemErr string)?

Failure: nil,
Skipped: nil,
Error: nil,
FlakyFailures: nil,
Copy link

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.

Comment on lines +124 to +129
Time: 0,
Failure: nil,
Skipped: nil,
Error: nil,
FlakyFailures: nil,
RerunFailures: nil,
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Comment on lines +156 to +262
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
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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 convertToFailure(itemType, failureMessage, systemErr string) *Failure {
	var message string
	if len(strings.TrimSpace(itemType)) > 0 {
		message = itemType
	}
	if len(strings.TrimSpace(failureMessage)) > 0 {
		if len(message) > 0 {
			message += ": "
		}
		message += failureMessage
	}

	if len(strings.TrimSpace(systemErr)) > 0 {
		if len(message) > 0 {
			message += "\n\n"
		}
		message += "System error:\n" + systemErr
	}

	if len(message) > 0 {
		return &Failure{
			Value: message,
		}
	}
	return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants