It was my understanding that if you called XCTFail()
in one of your unit tests it will fail that test instantly and not carry on and check the remaining assertions. However, this doesn't seem to be the case, at least not in my current project.
We even tried it on a very simple unit test that was passing. We added the XCTFail()
before the assertion which caused the unit test to fail but it still carries on and runs the assertion check after the XCTFail()
.
Is this just a misunderstanding on my part or is something going wrong here? If it is a misunderstanding, what is best practice to tell your unit test to not bother checking the other assertions as you already know they're going to fail?
It's a Swift unit test by the way using the XCTest framework. I've not given a code example as it seems to be the case on every one of our unit tests, no matter how simple they are.
Xcode Version 7.2.1 (7C1002)
You can set continuesAfterFailure
to false. Then the test runner stops when one test fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With