XCTestHTMLReport icon indicating copy to clipboard operation
XCTestHTMLReport copied to clipboard

Junit & HTML reports - Incorrect count for failed tests when `-retry-tests-on-failure` flag is passed

Open ssharma0312 opened this issue 4 years ago • 6 comments

With introduction of XCode 13, we can now re-run failed tests multiple times. This feature is very helpful for flaky tests.

Unlike .xcresult file, the test reports produced by XCTestHTMLReport counts re-tried tests x number of times (where x == no. of times a test is retried). This shows incorrect metrics.

In the following example I am passing flag -retry-tests-on-failure, so my failed test will re-run until they pass but for maxi 2 times (-test-iterations ) xcodebuild -workspace ABC.xcworkspace -scheme ABCTest -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11,OS=15.0' test -parallel-testing-enabled YES -parallel-testing-worker-count 5 -maximum-concurrent-test-simulator-destinations 5 -test-iterations 2 -retry-tests-on-failure -quiet -resultBundlePath TestResults

The .xcresult file produced, the "Failed" tab only shows 3 failed test because these 3 failed on both retries, the few tests that were failed on 1st attempt but succeed on 2nd retry are marked as Passed and counted only once, and showed under "Passed" tab. XCTestHTMLReport plugin should follow same pattern i.e. the tests that were passed on retry should not be counted as failed in HTML & Junit reports & should be counted only once.

.xcresult file image

.HTML Report produced by XCTestHTMLReport image

.HTML Report produced by XCTestHTMLReport image

ssharma0312 avatar Sep 30 '21 21:09 ssharma0312

@ssharma0312 Thank you for reporting this. I haven't reproduced this bug but since you provided all the screenshots and information I think this look like a valid bug (or a new feature in Xcode13 XCTestHTMLReport doesn't support yet and it looks like a bug).

nacho4d avatar Oct 01 '21 04:10 nacho4d

We are also seeing this. An awesome improvement in Xcode 13. Maybe follow .xcresult's pattern and show Mixed (xx) for tests that have failed, but succeeded on retry?

erik-agens avatar Oct 13 '21 06:10 erik-agens

Any update on this bug?

ssharma0312 avatar Nov 03 '21 19:11 ssharma0312

I am also seeing this issue on Xcode 13.1. Tests that passed on successive iterations are reported as failure. Very critical bug.

Husseinovich avatar Nov 17 '21 00:11 Husseinovich

Working on this bug, I will create a MR coming shortly with the fix.

ssharma0312 avatar Nov 18 '21 18:11 ssharma0312

Please feel free to test by pulling from #247

Or using mint: mint run tylervick/XCTestHTMLReport@tvick/mixed-test-status, though I don't encourage the practice of executing arbitrary git repos (even from myself 😬)..

tylervick avatar Dec 29 '21 01:12 tylervick