Only one function XCTAssertUnrecoverable is provided.
import XCTest
import XCTAssertUnrecoverable
class ExampleTests: XCTestCase {
func testExample() {
XCTAssertUnrecoverable {
// some program that will crash.
}
}
}
Important: Please disable a debugger.
lldb traps some signals such as SIGILL, SIGABRT so you cannot use this library with debugger.
Important: Be careful with build configuration, and optimization level.
For instance, assert works only in -Onone builds. So it may not crash in other optimization level.
-Onone
-O
-Osize
-Ounchecked
fatalError
✅
✅
✅
✅
precondition
✅
✅
✅
❌
assert
✅
❌
❌
❌
Note: Multithreading is not supported yet.
// NG
XCTAssertUnrecoverable {
DispatchQueue.global().async {
fatalError("fatal error!")
}
}
XCTAssertUnrecoverable
This library makes it possible to test that universal error / logic failure occurs, even if you use
fatalError
,preconditionFailure
and so on.Installation
XCTAssertUnrecoverable
depends on johnno1962/Fortify, but it is included in this library directly to support CocoaPods, Carthage for now.CocoaPods
Carthage
Add this to
Cartfile.private
.Swift Package Manager
Usage
Only one function
XCTAssertUnrecoverable
is provided.Important: Please disable a debugger.
lldb
traps some signals such asSIGILL
,SIGABRT
so you cannot use this library with debugger.Important: Be careful with build configuration, and optimization level.
For instance,
assert
works only in-Onone
builds.So it may not crash in other optimization level.
Note: Multithreading is not supported yet.
Requirements
Swift 4.1