Max Coverage, Minimum Time: An Efficient Android Development Testing Strategy

To manage our ongoing Android application development project effectively, my team is creating a testing strategy designed for maximum coverage with minimum time spent, particularly because we’re working with a small developer team and on a tight deadline.

Our plan involves focusing primarily on unit tests, supplemented by UI tests and a few end-to-end (e2e) tests. Unit tests are our priority because they’re faster to write and run, making them ideal for our limited time schedule.

1. Unit Tests (Most)

Most of our testing effort will revolve around unit tests. These tests are quicker to write, more reliable, and require less computational resources. The primary subjects of our unit tests will be:

ViewModels: The state and interaction logic of our pages.

Data Layers: Ensuring that data retrieval and storage processes are error-free.

Domain (useCases): These bridges between UI and data layers deserve attention because they contain crucial business logic.

2. Compose UI Tests (JVM – Robolectric)

Next, we’ll consider our UI tests. Instead of running these on a virtual emulator, we’re going to run them on the JVM using Robolectric. Doing so allows faster, more efficient testing. These tests will primarily cover interactions. We will test the response of the UI elements to user events, like the display of the error state or the functionality of clickable buttons.

3. Screenshot Tests (JVM – Robolectric)

Screenshot tests facilitate testing of larger page structures, allowing us to ensure that all UI components are placed and sized correctly. You can definitely do small composable-level screenshot tests with enough hands on deck. We’ll use Robolectric to run these tests on the JVM, addressing resource efficiency.

4. E2E UI Tests (Few, on Virtual Emulator)

Lastly, we’ll write e2e tests to cover user workflows. These tests simulate real user interactions from start to finish. For instance, a test might cover a user flow from login to completing an action. Despite running on a slower virtual emulator, these tests are indispensable for ensuring the seamless functionality of our app.

Overall, our strategy allows a broad coverage over the units, interface, and user flows, with efficient use of resources. Applying this comprehensive and efficient method, we can ensure a high-quality, reliable Android application. Feel free to adopt or adapt this strategy in your projects and share your experiences with us. Happy testing!

Conversation

Join the conversation

Your email address will not be published. Required fields are marked *