Skip to content

Commit

Permalink
Bump the major version; Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
d4vidi committed Jan 8, 2019
1 parent 0ccf03e commit 6e79f94
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 19 deletions.
2 changes: 1 addition & 1 deletion detox/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "detox",
"description": "E2E tests and automation for mobile",
"version": "9.1.2",
"version": "10.0.0",
"bin": {
"detox": "local-cli/detox.js"
},
Expand Down
76 changes: 58 additions & 18 deletions docs/Introduction.Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,41 @@ title: Detox for Android

**Detox for Android currently has several compatibility issues with React Native >= 0.50.** See [#608](https://github.com/wix/detox/issues/608) for details.

## Setup
Detox 7 was updated to support Android gradle plugin 3.0.0. This is a breaking change that makes it impossible to support previous Android gradle plugin versions.
## Breaking Changes :warning:

https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
* **In version 10, we've made [Kotlin](https://kotlinlang.org/) mandatory for integrating Detox into your Android project.** In the very least, you must include the Kotlin gradle plugin in your project, as we shall see later on. Nevertheless, this is a breaking change so bear that in mind when upgrading. In any case, worry not of the impact on your app, as - unless you effectively use Kotlin in your own native code, **there will be no impact on the final APK**, in terms of size and methods count.

For older Android gradle plugin support use `detox@6.x.x` instead ([previous setup guide here](https://github.com/wix/detox/blob/97654071573053def90e8207be8eba011408f977/docs/Introduction.Android.md)).<br>
**Detox 6 will not continue to be updated, to continue getting updates and features, update your Android gradle config and migrate to Detox 7.**
* **As of version 7** we require Android gradle plugin 3.0.0 or newer. This is a breaking change that makes it impossible to support previous Android gradle plugin versions.

### 1. Do the initial setup described in the Getting Started Guide
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

For older Android gradle plugin support use `detox@6.x.x` instead ([previous setup guide here](https://github.com/wix/detox/blob/97654071573053def90e8207be8eba011408f977/docs/Introduction.Android.md)).<br>





**Note: As a rule of thumb, we consider all old major versions discontinued; We only support the latest Detox major version.**



## Setup :gear:
### 1. Run through the initial _Getting Started_ Guide

- [Getting Started](Introduction.GettingStarted.md)

### 2. Add Detox dependency to an Android project

In `android/settings.gradle` add:

```gradle
```groovy
include ':detox'
project(':detox').projectDir = new File(rootProject.projectDir, '../node_modules/detox/android/detox')
```

In `android/app/build.gradle` add this to `defaultConfig` section:

```gradle
```groovy
defaultConfig {
...
testBuildType System.getProperty('testBuildType', 'debug') //this will later be used to control the test apk build type
Expand All @@ -49,34 +60,63 @@ Please be aware that the `minSdkVersion` needs to be at least 18.

In `android/app/build.gradle` add this in `dependencies` section:

```gradle
```groovy
dependencies {
...
// ...
androidTestImplementation(project(path: ":detox"))
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
...
}
```

And in `android/build.gradle` you need to add this under `allprojects > repositories`:

```gradle
```groovy
buildscript {
repositories {
...
// ...
google()
...
}
}
```

### 3. Create Android Test class
### 3. Add Kotlin

If your project does not already use Kotlin, add the Kotlin Gradle-plugin to your classpath in `android/build.gradle`:

```groovy
buildscript {
// ...
ext.kotlinVersion = '1.3.0'
dependencies: {
// ...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
```

_Note: most guides advise for defining a global `kotlinVersion` constant - as in this example, but that is not mandatory._



**IMPORTANT:** Detox aims at a playing fair with your app, and so it allows you to explicitly define the kotlin version for it to use - so as to align it with your own; Please do so - in your root `android/build.gradle` configuration file:

```groovy
buildscript {
ext.kotlinVersion = '1.3.0' // Your app's version
ext.detoxKotlinVersion = ext.kotlinVersion // Detox' version: should be 1.1.0 or higher!
}
```

***Note that Detox has been tested for version 1.1.0 of Kotlin, and higher!***

### 4. Create Android Test class

You need to add the file `android/app/src/androidTest/java/com/[your.package]/DetoxTest.java` and fill it like [this](../detox/test/android/app/src/androidTest/java/com/example/DetoxTest.java), except that you need to change the package to your projects name.

### 4. Add Android configuration
### 5. Add Android configuration

Add this part to your `package.json`:

Expand Down Expand Up @@ -110,7 +150,7 @@ Following device types could be used to control Android devices:
`android.attached`. Connect to already-attached android device. The device should be listed in the output of `adb devices` command under provided `name`.
Use this type to connect to Genymotion emulator.

### 5. Run the tests
### 6. Run the tests

Using the `android.emu.debug` configuration from above, you can invoke it in the standard way.

Expand All @@ -131,7 +171,7 @@ Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

You need to add this to the `android` section of your `android/app/build.gradle`:

```gradle
```groovy
packagingOptions {
exclude 'META-INF/LICENSE'
}
Expand Down
4 changes: 4 additions & 0 deletions docs/Introduction.GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ id: Introduction.GettingStarted
title: Getting Started
---

**This guide is focused on iOS. For installing Detox for Android, be sure to also go over the [Android guide](Introduction.Android.md)**.



This is a step-by-step guide for adding Detox to your React Native project.

> TIP: You can also check out this [awesome tutorial](https://medium.com/@bogomolnyelad/how-to-test-your-react-native-app-like-a-real-user-ecfc72e9b6bc) on Medium with video by [@bogomolnyelad](https://medium.com/@bogomolnyelad)
Expand Down

0 comments on commit 6e79f94

Please sign in to comment.