Hello! Thanks for your question.
There doesn't seem to be an officially supported way to do this. That said, if you subclass XCTestCase
and add your own properties to it, you can create a workaround.
https://developer.apple.com/documentation/xctest/xctestcase/3546549-record
The record(_:)
method is called every time a test fails or an issue occurs. If you subclass XCTestCase
and override this method (making sure to call super.record(_:)
), you should be able to get the behavior you desire using any number of methods.
One way to go about this would be to add a boolean property to your XCTestCase
subclass that becomes true
if any single test has failed, then skips any additional tests from inside the setUpWithError()
method once that boolean has been set.
https://developer.apple.com/documentation/xctest/xctest/3521150-setupwitherror
https://developer.apple.com/documentation/xctest/methods_for_skipping_tests