What's the difference between XCTAssert()
and assert()
in Swift?
XCTAssert
is one of a family of asserts for unit testing from the XCTest
framework, and should only be present in Unit Test Targets (i.e. not in your application code). If the assert fails, it does not terminate the execution of the test harness or hosting application, but records and reports the failure.
Unit test assertions are recorded and reported during the "Test" action (compare to "Run" and "Install" actions).
assert
is a debug-build-only swift assert for user code. This can be present in your application or framework target bundles. If the assert fails, the current application is stopped in a debuggable state, or terminated if not under the debugger. Equivalent to Objective-C's NSAssert
. In release builds, the assert is ignored.
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