public class Detox
Static class.
To start Detox tests, call runTests() from a JUnit test. This test must use AndroidJUnitRunner or a subclass of it, as Detox uses Espresso internally. All non-standard async code must be wrapped in an Espresso IdlingResource.
Example usage@runWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@Rule
//The Activity that controls React Native.
public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class);
@Before
public void setUpCustomEspressoIdlingResources() {
// set up your own custom Espresso resources here
}
@Test
public void runDetoxTests() {
Detox.runTests();
}
} Two required parameters are detoxServer and detoxSessionId. These must be provided either by Gradle.
android {
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments = [
'detoxServer': 'ws://10.0.2.2:8001',
'detoxSessionId': '1'
]
}
}
Or through command line, e.g adb shell am instrument -w -e detoxServer ws://localhost:8001 -e detoxSessionId 1 com.example/android.support.test.runner.AndroidJUnitRunner These are automatically set using,
detox test If not set, then Detox tests are no ops. So it's safe to mix it with other tests.
| Modifier and Type | Class and Description |
|---|---|
static class |
Detox.DetoxIdlePolicyConfig
Specification of values to use for Espresso's
IdlingPolicies timeouts. Overrides Espresso's defaults as they tend to be too short (e.g. when running a heavy-load app on suboptimal CI machines). |
| Modifier and Type | Method and Description |
|---|---|
static void |
launchMainActivity() |
static void |
runTests(androidx.test.rule.ActivityTestRule activityTestRule)
Call this method from a JUnit test to invoke detox tests.
|
static void |
runTests(androidx.test.rule.ActivityTestRule activityTestRule,
DetoxConfig detoxConfig)
Same as the default
method, but allows for the explicit specification of various configurations. Note: review for defaults. |
static void |
runTests(androidx.test.rule.ActivityTestRule activityTestRule,
Detox.DetoxIdlePolicyConfig idlePolicyConfig)
Same as the default
method, but allows for the explicit specification of a custom idle-policy configuration. Note: review for defaults. |
static void |
runTests(androidx.test.rule.ActivityTestRule activityTestRule,
android.content.Context context)
Use this method only if you have a React Native application and it doesn't implement ReactApplication; Otherwise use
. |
static void |
runTests(androidx.test.rule.ActivityTestRule activityTestRule,
android.content.Context context,
Detox.DetoxIdlePolicyConfig idlePolicyConfig)
Same as
, but allows for the explicit specification of a custom idle-policy configuration. Note: review for defaults. |
static void |
runTests(androidx.test.rule.ActivityTestRule activityTestRule,
android.content.Context context,
DetoxConfig detoxConfig)
Same as
, but allows for the explicit specification of various configurations. Note: review for defaults. |
static void |
startActivityFromNotification(java.lang.String dataFilePath) |
static void |
startActivityFromUrl(java.lang.String url) |
public static void runTests(androidx.test.rule.ActivityTestRule activityTestRule)
Call this method from a JUnit test to invoke detox tests.
In case you have a non-standard React Native application, consider using }. com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule,android.content.Context)
activityTestRule - org.jetbrains.dokka.NodeRenderContent@61ed032e: the activityTestRulecom.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule,android.content.Context)public static void runTests(androidx.test.rule.ActivityTestRule activityTestRule,
DetoxConfig detoxConfig)
Same as the default method, but allows for the explicit specification of various configurations. Note: review com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule) for defaults.class DetoxConfig
detoxConfig - org.jetbrains.dokka.NodeRenderContent@52d31f9e: The configurations to apply.com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule),
class DetoxConfigpublic static void runTests(androidx.test.rule.ActivityTestRule activityTestRule,
Detox.DetoxIdlePolicyConfig idlePolicyConfig)
Same as the default method, but allows for the explicit specification of a custom idle-policy configuration. Note: review com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule) for defaults.class Detox.DetoxIdlePolicyConfig
idlePolicyConfig - org.jetbrains.dokka.NodeRenderContent@2181969: The custom idle-policy configuration to pass in; Will be applied into Espresso via the IdlingPolicies API.com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule),
class Detox.DetoxIdlePolicyConfigpublic static void runTests(androidx.test.rule.ActivityTestRule activityTestRule,
@NonNull
android.content.Context context)
Use this method only if you have a React Native application and it doesn't implement ReactApplication; Otherwise use . com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule)
The only requirement is that the passed in object must have a method with the signature
ReactNativeHost getReactNativeHost(); activityTestRule - org.jetbrains.dokka.NodeRenderContent@3d4e3f5d: the activityTestRulecontext - org.jetbrains.dokka.NodeRenderContent@3433bfa9: an object that has a getReactNativeHost() methodcom.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule)public static void runTests(androidx.test.rule.ActivityTestRule activityTestRule,
@NonNull
android.content.Context context,
Detox.DetoxIdlePolicyConfig idlePolicyConfig)
Same as , but allows for the explicit specification of a custom idle-policy configuration. Note: review com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule,android.content.Context) for defaults.class Detox.DetoxIdlePolicyConfig
idlePolicyConfig - org.jetbrains.dokka.NodeRenderContent@1489391b: The custom idle-policy configuration to pass in; Will be applied into Espresso via the IdlingPolicies API.com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule,android.content.Context),
class Detox.DetoxIdlePolicyConfigpublic static void runTests(androidx.test.rule.ActivityTestRule activityTestRule,
@NonNull
android.content.Context context,
DetoxConfig detoxConfig)
Same as , but allows for the explicit specification of various configurations. Note: review com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule,android.content.Context) for defaults.class DetoxConfig
detoxConfig - org.jetbrains.dokka.NodeRenderContent@1768ddb2: The configurations to apply.com.wix.detox.Detox$runTests(androidx.test.rule.ActivityTestRule,android.content.Context),
class DetoxConfigpublic static void launchMainActivity()
public static void startActivityFromUrl(java.lang.String url)
public static void startActivityFromNotification(java.lang.String dataFilePath)