Skip to main content

Testing the Crash Handler

TestFairy's crash handler is a robust feature that allows you to identify and analyze crashes occurring within your iOS mobile applications. By incorporating the TestFairy library, you can deliberately trigger controlled crashes in your app and gain insights into the stacktrace associated with each crash.

note

This feature is available starting from iOS SDK version 1.19.8.

What You'll Need

  • A working iOS app project.
  • The TestFairy library integrated into your iOS app project.
  • Basic knowledge of iOS development using either Objective-C or Swift.

Testing the Crash Handler Example

Here's an example of how you might implement the crash handler:

[TestFairy crash];
Example
#import "ViewController.h"
#import "TestFairy.h"

@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];

UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(50, 50, 100, 30);
[button setTitle:@"Crash" forState:UIControlStateNormal];
[button addTarget:self action:@selector(crashApp:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}

- (IBAction)crashApp:(id)sender {
[TestFairy crash];
}

@end