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

Update xctest test result parsing for Xcode 16 #431

Merged
merged 21 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use errors instead of failures in JUnit reports
priitlatt committed Oct 15, 2024
commit a81273fc43e96940335ec8f8297dfd7b9ca99b0f
4 changes: 3 additions & 1 deletion src/codemagic/models/junit/definitions.py
Original file line number Diff line number Diff line change
@@ -37,8 +37,10 @@ def errors(self) -> Optional[int]:
return sum(suite.errors for suite in self.test_suites if suite.errors)

@property
def failures(self) -> int:
def failures(self) -> Optional[int]:
"""Total number of failed tests from all testsuites."""
if all(suite.failures is None for suite in self.test_suites):
return None
return sum(suite.failures for suite in self.test_suites if suite.failures)

@property
4 changes: 2 additions & 2 deletions src/codemagic/models/xctests/converter.py
Original file line number Diff line number Diff line change
@@ -272,8 +272,8 @@ def _get_test_suite(cls, xc_test_suite: XcTestSuite, xc_test_result_summary: XcT
name=cls._get_test_suite_name(xc_test_suite),
tests=len(xc_test_suite.test_cases),
disabled=sum(xc_test_case.is_disabled() for xc_test_case in xc_test_suite.test_cases),
errors=None, # Xcode doesn't differentiate errors from failures
failures=sum(xc_test_case.is_failed() for xc_test_case in xc_test_suite.test_cases),
errors=sum(xc_test_case.is_failed() for xc_test_case in xc_test_suite.test_cases),
failures=None, # Xcode doesn't differentiate errors from failures, consider everything as error
package=xc_test_suite.name,
skipped=sum(xc_test_case.is_skipped() for xc_test_case in xc_test_suite.test_cases),
time=sum(xc_test_case.get_duration() for xc_test_case in xc_test_suite.test_cases),
15 changes: 8 additions & 7 deletions src/codemagic/tools/xcode_project.py
Original file line number Diff line number Diff line change
@@ -512,13 +512,14 @@ def run_test(
test_suites = None
self.logger.error(Colors.RED(f"Parsing test results failed\n{e}\n{e.stderr}"))
else:
if test_suites.errors is not None:
failures_message = f"{test_suites.failures} failures and {test_suites.errors} errors"
else:
failures_message = f"{test_suites.failures} failures"

message = f"Executed {test_suites.tests} tests with {failures_message} in {test_suites.time:.2f} seconds.\n"
self.echo(Colors.BLUE(message))
message = f"Executed {test_suites.tests} tests"
if test_suites.errors is not None and test_suites.failures is not None:
message = f"{message} with {test_suites.failures} failures and {test_suites.errors} errors"
elif test_suites.errors is not None:
message = f"{message} with {test_suites.errors} errors"
elif test_suites.failures is not None:
message = f"{message} with {test_suites.errors} failures"
self.echo(Colors.BLUE(f"{message} in {test_suites.time:.2f} seconds.\n"))
TestSuitePrinter(self.echo).print_test_suites(test_suites)
self._save_test_suite(xcresult, test_suites, output_dir, output_extension)

12 changes: 6 additions & 6 deletions tests/models/xctests/converter/test_xcode_16_converter.py
Original file line number Diff line number Diff line change
@@ -240,17 +240,17 @@ def test_converter(mock_datetime, expected_properties):

assert test_suites.name == "Test - banaan"
assert test_suites.disabled == 0
assert test_suites.errors is None
assert test_suites.failures == 3
assert test_suites.errors == 3
assert test_suites.failures is None
assert test_suites.skipped == 1
assert test_suites.tests == 8
assert test_suites.time == 5.46875
assert len(test_suites.test_suites) == 2

ts = test_suites.test_suites[0] # Unit tests testsuite assertions
assert ts.disabled == 0
assert ts.errors is None
assert ts.failures == 2
assert ts.errors == 2
assert ts.failures is None
assert ts.name == "banaanTests [iOS 18.0 iPhone SE (3rd generation)]"
assert ts.package == "banaanTests"
assert ts.skipped == 1
@@ -301,8 +301,8 @@ def test_converter(mock_datetime, expected_properties):

ts = test_suites.test_suites[1] # UI tests testsuite assertions
assert ts.disabled == 0
assert ts.errors is None
assert ts.failures == 1
assert ts.errors == 1
assert ts.failures is None
assert ts.name == "banaanUITests [iOS 18.0 iPhone SE (3rd generation)]"
assert ts.package == "banaanUITests"
assert ts.skipped == 0