Skip to main content

Begin with Options

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

Some commonly used options:

  • Crash Reporting
  • Video Recording
  • Recorded Metrics
  • Max Session Length
  • Feedback Form

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.Once you enable the TestFairy crash handler, 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 MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

TestFairy.disableCrashHandler();
TestFairy.begin(this, "<app token>");
}
}
Once logged in, your app token is available from your account preferences.

Video Recording

TestFairy provides an option to enable or disable video recording and control the recording parameters. 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 policy and quality values.

Code Example

In the following example, video only records when wifi is available. A high-quality video is recorded every 2 seconds.
import com.testfairy.TestFairy;

public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

TestFairy.enableVideo("wifi", "high", 2.0);
TestFairy.begin(this, "<app token>");
}
}
Once logged in, your app token is available from your account preferences.

Recorded Metrics

TestFairy can collect several different metrics from your app. Developers can 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

Any metric that is enabled or disabled 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 will not be recorded, regardless of what's set in the build settings.
import com.testfairy.TestFairy;

public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

TestFairy.enableMetric("cpu");
TestFairy.disableMetric("memory");
TestFairy.begin(this, "<app token>");
}
}
Once logged in, your app token is available from your account preferences.

Max Session Length

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

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 MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

TestFairy.setMaxSessionLength(10 * 60); // Record for 10 minutes
TestFairy.begin(this, "<app token>");
}
}
Once logged in, your app token is available from your account preferences.

Feedback Form

TestFairy provides an option to enable or disable feedback collection. Invoke disableFeedbackForm or enableFeedbackForm before begin.

Syntax

TestFairy.disableFeedbackForm();
TestFairy.enableFeedbackForm("<method>");
Refer to the Class Reference for more information on values for method.

Code Example

In the following example, feedback will be enabled when the device is shaken.
import com.testfairy.TestFairy;

public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

TestFairy.enableFeedbackForm("shake");
TestFairy.begin(this, "<app token>");
}
}
Once logged in, your app token is available from your account preferences.