👋 Try our app |
---|
⬇ Download the FlowCrypt app on your device from the FlowCrypt Downloads page. |
This guide follows Google's recommendations for testing apps on Android. Every scenario described in this section has been tested on Ubuntu. There are JUnit and Instrumentation tests. To be able to run tests locally, you should set up your environment.
Please follow these steps to setup your virtual or physical device:
- Set up your test environment.
- Some of the tests use MockWebServer. We run a local mock web server via FlowCryptMockWebServerRule. It uses TestConstants.MOCK_WEB_SERVER_PORT as a port. Unfortunately, the Android system doesn't allow us to use the
HTTPS 433
port by default to run a web server on thelocalhost (127.0.0.1)
. That's why we have to run a mock web server on another port (for example,1212
) and route all traffic from127.0.0.1:433
to127.0.0.1:1212
. For that purpose, you can use the script/ci-wait-for-emulator.sh script. - Additionally, the test environment should handle all requests to
*.flowcrypt.test
. All traffic to*.flowcrypt.test
should be routed tolocalhost (127.0.0.1)
. You can use a DNS server to do this. For example, using these commands:
1. sudo apt install -y dnsmasq resolvconf
2. echo "#added by flowcrypt" | sudo tee -a /etc/dnsmasq.conf
3. echo "listen-address=127.0.0.1" | sudo tee -a /etc/dnsmasq.conf
4. echo "address=/flowcrypt.test/127.0.0.1" | sudo tee -a /etc/dnsmasq.conf
5. echo "address=/localhost/127.0.0.1" | sudo tee -a /etc/dnsmasq.conf
6. sudo systemctl restart dnsmasq
We have two types of tests:
- Independent tests that don't require any additional dependencies.
- Tests that depend on an email server. Such tests are marked with the
@DependsOnMailServer
annotation.
Additionally, we have separate tests for the consumer and enterprise versions. Enterprise tests are marked with the @EnterpriseTest
annotation. These tests use the Gmail API and are independent of the mail server.
We run tests on Semaphore CI for every commit. To run tests that depend on an email server, we use a custom Docker image, which extends docker-mailserver. This image has predefined settings for local testing. It has accounts and messages which we need for testing. You can investigate the docker-mailserver
folder to see more details. To be able to run tests that depend on an email server, please install docker-compose
following the official instructions.
⬇️ Please follow these steps to run the independent tests locally:
- Setup your device (virtual or physical) following the device setup instructions.
- Run
../script/ci-instrumentation-tests-without-mailserver.sh 1 0
(where1
is anumShards
and0
is ashardIndex
). You can find more details if you read the guide concerning AndroidX test libraries on sharding tests. It helps us run them in pieces on a few emulators at the same time to reduce runtime.
⬇️ Please follow these steps to run tests that depend on an email server locally:
- Setup your device (virtual or physical) following the device setup instructions.
- Run
./docker-mailserver/run_email_server.sh
and wait while the email server is started. - Run
../script/ci-instrumentation-tests-with-mailserver.sh
. - Run
./docker-mailserver/stop_email_server.sh
to stop the email server.
⬇️ Please follow these steps to run all tests locally:
- Setup your device (virtual or physical) following the device setup instructions.
- Run
./docker-mailserver/run_email_server.sh
and wait while the email server is started. - Run
./script/run-all-tests.sh
to execute all tests. - Run
./docker-mailserver/stop_email_server.sh
to stop the email server.
⬇️ Please follow these steps to run enterprise tests locally:
- Setup your device (virtual or physical) following the device setup instructions.
- Run
./script/ci-instrumentation-tests-enterprise.sh
to execute enterprise tests.
This section describes two main steps you need to accomplish to run the app in the emulaor:
Please follow these steps to be able to install and run the emulator:
1. Run AVD Manager from Tools ➜ AVD Manager or click on the highlighted icon:
2. Click on Create Virtual Device:
3. Select the hardware: Pixel 4 will be a good choice. After, click Next:
4. Download one of the latest available system images:
6. Select the downloaded image and click Next:
7. Once you click Next, you'll see the final screen where you should click Finish:
8. AVD Manager will show a new emulator. Click the green triangle to run the emulator:
9. Once running, you'll see the home screen of the emulator:
Please follow these steps to be able to build and run the app:
1. First of all, you should select the correct version of the build variants. Please use consumerDebug
:
2. Make sure that your emulator is selected:
3. Now, you can run the app via Run ➜ Run(Alt+Shift+F10) or click on the green Run button:
4. You'll see the app on the emulator in a few minutes (it depends on the hardware performance characteristics):