Docker-Android-Detox is a docker image based on the Docker-Android https://github.com/budtmo/docker-android .
However this image includes the configuration of the tool wix/Detox https://github.com/wix/Detox to allow the to test react-native apps on Android devices using detox
For now there are just one Docker image for just one device which is: Nexus 5 - API 23 - Android 6.0.1
Emulator - Nexus Device |
---|
![]() |
- Run UI tests for React-native apps with detox
- noVNC to see what happen inside docker container
- Ability to test react-native apps
- First docker image that allows to run detox react-native tests
- Ability to connect to Selenium Grid
- Ability to control emulator from outside container by using adb connect
- Support real devices with screen mirroring
- Ability to record video during test execution for debugging
- Integrated with other cloud solutions, e.g. Genymotion Cloud
- Open source with more features coming
OS | Android | API | Browser | Browser version | Chromedriver | Image | Device name |
---|---|---|---|---|---|---|---|
Linux | 6.0.1 | 23 | browser | 44.0 | 2.18 | detox12-reactnative-nexus5-android6-api-23 | nexus_5_6.0.1 |
Type | Device Name |
---|---|
Phone | Nexus 5 |
Docker is installed in your system.
-
Run Docker-Android
```bash docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e --name android-container ralves20/detox12-reactnative-nexus5-android6-api-23 ```
-
Verify the ip address of docker host.
-
For OSX, you can find out by using following command:
docker-machine ip default
-
For different OS, localhost should work.
-
-
Open http://docker-host-ip-address:6080 from web browser.
Pre-requirements:
- You need to have docker-compose configurated on your computer.
-
There is a docker-compose as an example on example/sample-compose-android.yml, you can use it as a basis for your usage.
-
You are going to need to create an supervisord.conf file and using it as a volume for the supervisord inside the container, this is necessary because you need to modify supervisord section detox to run your detox tests. There is also an supervisord.conf example in example/sample-supervisord.conf.
-
Modify your detox-test section on the bash command to execute the command that you need to run your tests.
Example:
[program:detox-test]
command=bash -c "yes | sdkmanager --licenses && cd /tmp/test && yarn detox:start & cd /tmp/test && yarn detox:build-android && cd /tmp/teste && yarn detox:test-android"
autorestart=false
stdout_logfile=/tmp/detox/detox.log
stderr_logfile=/tmp/detox/detox_err.log
priority=5
- Now in your project you need to modify your package.json in the detox section and set the device name as the name of the device you choose before.
Example:
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
"build": "cd android && RN_SRC_EXT=e2e.js E2E=true ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
"type": "android.emulator",
"name": "nexus_5_6.0.1" //Here is the place where you need to set the device name
}
- After generated the docker-compose file and generating your supervisord.conf, you can run your detox tests.
This document contains custom configurations of Docker-Android that you might need, e.g. Proxy, Changing language on fly, etc.
Docker-Android can be used for building Android project and executing its unit test. This following steps will illustrate how to build Android project:
-
Clone this sample test project.
git clone git@github.com:googlesamples/android-testing.git
-
Build the project
docker run -it --rm -v $PWD/android-testing/ui/espresso/BasicSample:/root/tmp budtmo/docker-android-x86-8.1 tmp/gradlew build
-
Create a docker container with this command
$ docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 --name android-container-detox budtmo/docker-android-real-device
-
Open noVNC http://localhost:6080
-
Open terminal by clicking right on noVNC window >> Terminal emulator
-
To connect to host's adb (make sure your host have adb and connected to the device.)
$ adb -H host.docker.internal devices
To specify port, just add
-P port_number
$ adb -H host.docker.internal -P 5037 devices
-
Now your container can access your host devices. But, you need to add
remoteAdbHost
andadbPort
desired capabilities to make detox can recognise those devices.
adb connect <docker-machine-ip-address>:5555
Note: You need to have Android Debug Bridge (adb) installed in your host machine.
-
Using telnet
- Find the auth_token and copy it.
docker exec -it android-container cat /root/.emulator_console_auth_token
- Access emulator using telnet and login with auth_token
telnet <docker-machine-ip-address> 5554
- Login with given auth_token from 1.step
auth <auth_token>
- Send the sms
sms send <phone_number> <message>
-
Using adb
docker exec -it android-container adb emu sms send <phone_number> <message>
-
You can also integrate it inside project using adb library.
Docker-Android contains Google Play Service (v12.8.74) and Google Play Store (v11.0.50). Both applications are downloaded from apklinker, so please be aware of it in case you use private/company account to that applications.
This document gives you information about custom plugin that supports Docker-Android.
This document shows you how to configure Virtual Machine on VMWARE to be able to run Docker-Android.
This document contains information about deploying Docker-Android on cloud services.
For you who do not have ressources to maintain the simulator or to buy machines or need different device profiles, you need to give a try to Genymotion Cloud. Docker-Android is integrated with Genymotion on different cloud services, e.g. Genymotion Cloud, AWS, GCP, Alibaba Cloud. Please follow this document or this blog for more detail.
All logs inside container are stored under folder /var/log/supervisor. you can print out log file by using docker exec. Example:
docker exec -it android-container tail -f /var/log/supervisor/docker-android.stdout.log
The Emulator skins are taken from Android Studio IDE and Samsung Developer Website
All docker images are protected by Polyverse by scrambling the Linux packages. For more information please read this
- Budi Utomo for creating this great docker android image
- Gian Christanto for creating a great logo!
- Otoniel Isidoro for giving some ideas on how to adapt the code to use Detox
See License