Page MenuHomePhabricator

[XL] Refine and modularize Espresso tests
Open, LowPublic

Description

The current state of instrumented smoke tests is good, but can become even better:

  • Currently the tests are still a bit flaky, because they depend on components appearing on the screen that might be scrolled slightly off-screen, e.g. Feed cards that are unexpectedly long, which push the next expected card out of visible range. The tests should be updated to handle such edge cases.
  • The current tests are basically a single giant script. It would be better to split it into multiple modules. This will make it easier to develop additional tests (since the developer doesn't need to wait for the whole script to run until any new logic is added). It will also make it easier to deploy only certain modules when ready to be run in CI. Some ideas for modularization include:
    • Separate modules for logged-out vs logged-in tests.
    • Separate modules per "screen" or "feature" of the app.
    • Separate modules per "persona" that characterizes a user's day-to-day usage of the app.

Event Timeline

The PR for this task implements the following

Test Architecture Modernization using Robot Pattern
This PR introduces a comprehensive architectural redesign of our Android test framework, addressing the current challenges with our single giant smoke test script. The new architecture implements the Robot Pattern, enabling modular, maintainable and efficient test management.

Current Challenges

  • Single, oversized smoke test script
  • Long execution times for minor changes
  • Poor maintainability and organization
  • Difficulty in managing test dependencies

Key Implementation

Robot Pattern Integration
The architecture introduces specialized Robot classes, each of which is responsible for specific testing domains.

  • Navigation Robot: Handles navigation related testing
  • System Robot: Manages system level operations (airplane mode, system dialog, etc)
  • ExploreFeed Robot: Test explore feed related functions
  • Login Robot: Manages authentication related testing

The architecture implements a hierarchical design where developers can create new specialized robots by extending BaseRobot class. This base robot serves as the parent class, providing a foundation of shared utilities and common functionality that all child robots inherit. This pattern ensure consistency while allowing for easy expansion of the test framework.

Structural Organization

Folder Structure

  • Implemented a clear folder hierarchy
  • Enhanced the code readability and accessibility
  • Simplified navigation through test components

State-Based Separation

  • Tests are categorized into two primary states:
  • Logged In State: Tests requiring authenticated user sessions
  • Logged Out State: Tests without authenticated user sessions

Test Suite Implementation

  • Introduced a centralized TestSuite class
  • Can select/deselect test to run easily
  • Facilitates targeted test runs

Benefits

  • Reduce execution time for individual test modifications
  • Enhanced test reliability with focused single test class
  • Improved code organization and maintainability
  • Enables seamless interaction between different robot components, allowing tests to utilize multiple robots to create comprehensive test scenarios
  • Simplified test management and execution
  • Separation of concerns through specialized robots

Future Scope

  • Addition of new robot classes
  • Integration of new test scenarios
  • Improving scroll to view function
  • Improving test coverage for specific features
Dbrant renamed this task from Refine and modularize Espresso tests to [XL] Refine and modularize Espresso tests.Dec 2 2024, 6:25 PM