XCTest - continueAfterFailure doesn't work for async tests

In an XCTest, setting continueAfterFailure to true in setUp should cause the test to stop executing as soon a failed assertion occurs. This works correctly unless the test is marked async.

In that case, what I've seen is that execution of the failed test continues, and another test starts to execute in parallel. You can see this by pausing execution and seeing two cooperative threads actively executing two different tests. This can cause weird problems due to XCTestCase classes often not being reentrant. It seems that tests are executed concurrently only if they are async, one of them fails and continueAfterFailure is set to false.

It almost seems like the "host" thread for the test is properly stopped, but the cooperative thread that runs the async test continues on, while the "host" thread moves on and starts the next async test, which results in two cooperative threads running tests in parallel.

I suspect that the async support and the continueAfterFailure support are duelling here. However, regardless of what’s causing it, it’s clearly broken and I’d appreciate you filing a bug about this. This should either work or there should be a clear trap that stops you from doing it.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Bug filed: https://feedbackassistant.apple.com/feedback/11358416

Thanks for the quick response!

Experiencing the same issue. Thanks!

Looks like the issue is partially resolved in the 15.3 beta 2, but it's still not perfect. The tests do fail, but when they initialize they continue testing where they left off.

We're facing this same issue. Also filed a bug report: https://feedbackassistant.apple.com/feedback/13956075

We have run into this issue in Xcode 15.1 and 15.4.

XCTest - continueAfterFailure doesn't work for async tests
 
 
Q