Brewing Up Reliability: Espresso Test Generation for Android Apps


The Espresso testing framework for Android has gained popularity among developers as it allows to write concise and reliable UI tests. State-of-the-art tools for automatically testing Android apps, however, tend to produce crash reports rather than human-readable tests, and even if they produce tests these (1) rarely use the Espresso format; (2) are often unreliable due to the volatile nature of widget identifiers; and (3) usually contain no test assertions to serve as regression oracles. While the lack of Espresso support of test generation tools has been addressed by reverse engineering Espresso tests, the other problems remain even with this workaround. In this paper, we therefore introduce a novel Espresso-based representation that allows test generators to generate Espresso test cases directly that (1) can reliably identify widgets using clear and concise Espresso selectors, and (2) can check test executions using Espresso assertions. Experiments on 1,035 Android apps demonstrate that the proposed approach generates Espresso tests that are significantly more reliable than reverse engineered tests, and the Espresso assertions of the generated tests are effective at detecting faults in Android apps.

17th IEEE International Conference on Software Testing, Verification and Validation (ICST) 2024