TestFairy requires that you call begin in order to start recording your sessions. However, developers have the option to override the build settings to determine what is enabled during a session recording.

Here are some commonly used options:

Crash Reporting

TestFairy provides a means of capturing and recording stack traces if your application crashes. Stack traces can be vital to understanding any underlying bugs in your app. However, some apps may want to disable TestFairy's crash handling. Invoke enableCrashHandler or disableCrashHandler before calling begin.

Note that once the TestFairy crash handler has been enabled, it cannot be disabled unless the app is restarted.

Syntax

TestFairy.enableCrashHandler();
TestFairy.disableCrashHandler();

Code Example

In the following example, the TestFairy crash handler will be disabled.

import com.testfairy.TestFairy;

public class MainActivity extends Activity {
    @Override
    public void onCreate() {
        super.onCreate();

        TestFairy.disableCrashHandler();
        TestFairy.begin(this, "<app token>");
    }
}
            

Syntax

[TestFairy enableCrashHandler];
[TestFairy disableCrashHandler];

Code Example

In the following example, the TestFairy crash handler will be disabled.

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [TestFairy disableCrashHandler];
    [TestFairy begin:@"<app token>"];
}
            

Your app token is available from your account preferences once logged in.

Video Recording

TestFairy provides an option to enable or disable video recording, and to control the parameters of the recording. Invoke disableVideo, or enableVideo before begin.

Syntax

TestFairy.disableVideo();
TestFairy.enableVideo("<policy>", "<quality>", <frames per second>);

Refer to the Class Reference for more information on values for policy and quality.

Code Example

In the following example, video will only be recorded when wifi is available. A high quality video will be recorded every half second.

import com.testfairy.TestFairy;

public class MainActivity extends Activity {
    @Override
    public void onCreate() {
        super.onCreate();

        TestFairy.enableVideo("wifi", "high", 2.0);
        TestFairy.begin(this, "<app token>");
    }
}
            

Syntax

[TestFairy disableVideo];
[TestFairy enableVideo:@"<policy>" quality:@"<quality>" framesPerSecond:<frames per second>];

Refer to the Class Reference for more information on values for policy and quality.

Code Example

In the following example, video will only be recorded when wifi is available. A high quality video will be recorded every half second.

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [TestFairy enableVideo:@"wifi" quality:@"high" framesPerSecond:2.0];
    [TestFairy begin: @"<app token>"];
}
            

Your app token is available from your account preferences once logged in.

Recorded Metrics

TestFairy can collect a number of different metrics from your app. Developers can choosed to override the metrics defined in their app's build settings.

Developers can call enableMetric or disableMetric before invoking begin with the metric they wish to enable or disable recording.

Note that any metric that is enabled or disabled will override the settings set in your app's build settings

Syntax

TestFairy.enableMetric("<metric>");
TestFairy.disableMetric("<metric>");

Refer to the Class Reference for more information on which metric can be passed.

Code Example

In the following snippet, the CPU metric will be recorded, and the Memory metric wil not be recorded, regarless of what's set in the build settings.

import com.testfairy.TestFairy;

public class MainActivity extends Activity {
    @Override
    public void onCreate() {
        super.onCreate();

        TestFairy.enableMetric("cpu");
        TestFairy.disableMetric("memory");
        TestFairy.begin(this, "<app token>");
    }
}
            

Syntax

[TestFairy enableMetric:@"<metric>"];
[TestFairy disableMetric:@"<metric>"];

Refer to the Class Reference for more information on which metric can be passed.

Code Example

In the following snippet, the CPU metric will be recorded, and the Memory metric wil not be recorded, regardless of what's set in the build settings.

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [TestFairy enableMetric:@"cpu"];
    [TestFairy disableMetric:@"memory"];
    [TestFairy begin: @"<app token>"];
    // ...
}
            

Your app token is available from your account preferences once logged in.

Max Session Length

TestFairy only records for a fixed period of time. Developers can override the maximum recording period by calling setMaxSessionLength before calling begin.

Note that the value passed into this method must be less than or equal to the value defined in the build settings. A value larger than the one in the build settings will be ignored.

Syntax

TestFairy.setMaxSessionLength(<session length in seconds>);

Code Example

import com.testfairy.TestFairy;

public class MainActivity extends Activity {
    @Override
    public void onCreate() {
        super.onCreate();

        TestFairy.setMaxSessionLength(10 * 60); // Record for 10 minutes
        TestFairy.begin(this, "<app token>");
    }
}
            

Syntax

[TestFairy setMaxSessionLength:<session length in seconds>];

Code Example

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [TestFairy setMaxSessionLength:(10 * 60)]; // Record for 10 minutes
    [TestFairy begin:@"<app token>"];
}
            

Your app token is available from your account preferences once logged in.