Testing Android applications

How to test React Native and Flutter applications on Android

React Native and Flutter allow a large proportion of code to be shared between platforms, but they do not eliminate differences in the operating system, permissions or hardware. Automated testing therefore needs to understand the framework used while also verifying the behaviour experienced by a user on an Android device. Choose coverage according to the platform behaviour your product needs.

Where typical problems arise

Shared code can create the impression that testing one platform is enough. System dialogs, notifications, the keyboard, returning from the background and permission management are, however, governed by Android. A fault in this integration may not appear in a test of the component itself.

Another problem is the availability of elements to the automation tool. React Native renders components into the native interface, but a test needs stable identifiers and correctly configured accessibility properties. Flutter works with its own widget tree and provides information to system tools through the semantics tree. If important elements do not have meaningful semantic data, an external end-to-end test may not be able to find them reliably.

Changing text in locators, fixed waits and dependence on production data can cause instability. The application’s framework will not solve these problems by itself.

It is equally important to choose situations that matter to the specific product. The overview of mobile scenarios suitable for automation helps distinguish critical journeys from edge combinations.

How to divide tests into three layers

Unit and component tests verify business logic and individual parts of the interface quickly and without an entire device. React Native uses tools from the JavaScript ecosystem for this. Flutter includes unit and widget tests directly in its SDK.

Framework integration tests check how larger parts of the application work together. Flutter provides the integration_test package, which can run on both an emulator and a physical device. Its official documentation, however, points out that it cannot interact directly with native platform interfaces, such as permission dialogs or notifications. Such scenarios need a complementary approach.

External end-to-end tests launch the built application and control it from the user’s perspective. Depending on the requirements, Appium or Maestro is suitable for Android. We use them to cover a smaller number of critical journeys and interactions with the system, not every detail of the logic.

How to prepare the application for stable end-to-end tests

First, we inspect the element tree on representative screens. We add stable test identifiers, names and semantic roles to important controls. Identifiers help automation. Clear names and roles also matter for accessibility, although an automated test is not in itself an accessibility audit.

We then create a pilot that includes:

  1. the main scenario in the application,
  2. one native dialog or permission,
  3. the application returning from the background,
  4. verification of the outcome through the interface or API,
  5. a run on both an emulator and a selected physical device.

For Flutter, we first verify whether the system semantics tree provides enough information for a standard Android driver. If not, we consider a framework-specific approach. Community Appium drivers also need to be assessed according to their maintenance and compatibility. For Maestro, we verify the specific screens and commands in the same pilot.

The article Emulator or physical device explains the difference between a fast virtual run and physical hardware.

A passing component test has not yet tested Android

In React Native, you can test that a form responds to text input and calls the expected function. If the test runs only in a JavaScript environment with the native module replaced, it does not check that module’s actual behaviour on a phone. The official testing overview explicitly identifies this boundary.

In Flutter, a widget test checks the interface in a controlled environment, while an integration test runs a larger part of the application on a device. Handle system-dialog interaction separately. Flutter also documents the limitations of integration_test, which does not directly cover these native interactions.

For each scenario, record which layers were real and which were replaced. A passing test of the camera’s return value does not establish camera startup, a permission dialog or the usability of the captured image. Add a check for the missing boundary instead of more copies of the same form test.

Separate test identifiers from user-facing text

In React Native, testID locates a view in an end-to-end test. In Flutter, an internal widget key may not reach an external tool. Maestro explains the difference between Flutter Keys and semantics.

Flutter also provides SemanticsProperties.identifier, which exposes a technical identifier in the native hierarchy without displaying it to users. Check availability and behaviour with the project’s framework and tool versions. Adding an identifier alone does not establish that a particular driver will find it in the build under test.

Do not change a button’s name to a technical string simply for a test. Keep a clear name and role for users and assistive technology. The identifier helps find the correct element, while the assertion should check its visible behaviour. Check repeated list items and the correct parent element too, so the test does not press the first of several identical buttons.

An illustrative pilot: a form with product scanning

Consider an application that accepts a product code manually or through the camera and then saves a request with a quantity. The test product is TEST-A and the quantity is two. The illustrative requirement says that denying camera access must not clear the form and users can continue manually.

Situation What to check
Camera access allowed The scanned code maps to the correct product, and the quantity remains two.
Permission denied The application explains the limitation and allows manual entry without losing data.
Backgrounding and return The unfinished form is preserved according to the approved rule.
Interrupted submission with an uncertain outcome A status check or safe next attempt does not create a second request.

After a successful save, check one record with the correct product and quantity through the application or test API. A green message alone does not confirm persisted data. If scanning was replaced by a known response, record that camera operation was outside this check.

Distinguish returning from the background from process termination. The product may have different rules for restoring unfinished data in these situations. Define expectations before testing, and also check the response to a missing session after recovery. Preserving a form in one case does not prove recovery in every state.

Device coverage and build identity belong in the result

Choose supported Android versions and a representative physical device for the pilot according to product risks. A real device matters for a camera or other hardware. An emulator with controlled input can check part of a scenario, but cannot replace checking the actual hardware.

Record the application, framework, automation-tool and optional driver versions, build type, Android version, device and initial permissions. If a test grants every permission beforehand, it has not checked the denial branch. If the build or a plugin changes, check the affected integration again.

When a run fails, distinguish a missing element, incomplete device setup and an incorrect application result. Include the last step, available logs and test-data state. A broken phone connection is neither a passing nor a failing test of saving the request: that step remains unverified. The team can then expand the suite according to identified gaps and knows which results it can rely on for release.

What you gain

Each layer verifies what it is suited to. Most of the logic gains fast tests, while a smaller end-to-end suite confirms that important journeys and system interactions work in the built Android application.

Stable identifiers and semantics reduce the tests’ sensitivity to visual changes. The pilot also reveals early whether the chosen tool understands the specific React Native or Flutter implementation and what modifications the application needs.

Next step

Choose one critical screen and inspect its test identifiers, semantic roles and behaviour with a system dialog. Then create a pilot across all three layers and keep every detail in the fastest layer that can verify it reliably.

Related topics

You might also be interested in

We will verify the decisive scenarios on real devices

Automated testing of native and hybrid Android applications, with critical runs on physical or cloud devices.