# android/testing-samples architecture

> Architecture diagram of the GitHub repository android/testing-samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/android/testing-samples
- Repository: https://github.com/android/testing-samples

## Overview

##### Project type and purpose
- This is a mono-repository of Android testing sample apps. It demonstrates various automated testing frameworks and techniques (Espresso, UiAutomator, AndroidJUnitRunner, JUnit4 Rules, ServiceTestRule) and supports two build systems: Gradle (for local/IDE development) and Bazel (for CI headless testing).
- The README confirms the samples’ goal: show best practices for writing and running Android tests using AndroidX Test, Bazel, and continuous integration.

##### File‐structure analysis
- Top‐level:
- CI & build configs (​.github/workflows, bazelci/, .bazelrc, WORKSPACE, BUILD.bazel, top‐level Gradle scripts)
- Directory groups:
– integration/ServiceTestRuleSample
– runner/AndroidJunitRunnerSample, AndroidTestOrchestratorSample…
– ui/espresso/… (many Espresso samples), ui/uiautomator/BasicSample, ui/PreviewScreenshot (Compose)
– unit/… (unit test samples in Kotlin/Java, native C++ sample)
- Each sample is a standalone Android app module: contains its own build.gradle or BUILD.bazel, src/main, src/androidTest, src/test, AndroidManifest, resources, Gradle wrapper.
- Patterns:
- Multi‐module monorepo with separation by testing category.
- Dual‐build‐system support (Gradle vs. Bazel) for flexibility between local and CI builds.
- Shared definitions: common_defs.bzl, projects.conf, top‐level build.gradle to coordinate dependencies.

##### Insights from README
- Confirms build commands:
- Gradle: `./gradlew assemble`, `connectedAndroidTest`, `test`
- Bazel: `bazel test //... --config=...`
- Enumerates samples and testing frameworks.
- CI integration via GitHub Actions and Buildkite (bazelci).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Source
    Repo["Source Repository"]:::repo
    click Repo "https://github.com/android/testing-samples/blob/main//README.md"

    %% CI Layer
    subgraph "CI Pipelines"
        direction TB
        Actions["GitHub Actions"]:::ci
        click Actions "https://github.com/android/testing-samples/tree/main//.github/workflows/"
        Buildkite["Buildkite (Bazel CI)"]:::ci
        click Buildkite "https://github.com/android/testing-samples/blob/main//bazelci/buildkite-pipeline.yml"
    end

    %% Build Orchestrator Layer
    subgraph "Build Orchestrator"
        direction TB
        Gradle["Gradle (Local/IDE)"]:::build
        click Gradle "https://github.com/android/testing-samples/blob/main//build.gradle"
        Bazel["Bazel (CI)"]:::build
        click Bazel "https://github.com/android/testing-samples/tree/main//WORKSPACE"
    end

    %% Module Groups
    subgraph "Modules"
        direction TB
        subgraph "integration (Green)"
            direction TB
            ServiceTestRuleSample["ServiceTestRuleSample"]:::module
            click ServiceTestRuleSample "https://github.com/android/testing-samples/tree/main/integration/ServiceTestRuleSample/"
        end
        subgraph "runner (Green)"
            direction TB
            AndroidJunitRunnerSample["AndroidJunitRunnerSample"]:::module
            click AndroidJunitRunnerSample "https://github.com/android/testing-samples/tree/main/runner/AndroidJunitRunnerSample/"
            AndroidTestOrchestratorSample["AndroidTestOrchestratorSample"]:::module
            click AndroidTestOrchestratorSample "https://github.com/android/testing-samples/tree/main/runner/AndroidTestOrchestratorSample/"
            AndroidTestOrchestratorWithTestCoverageSample["AndroidTestOrchestratorWithTestCoverageSample"]:::module
            click AndroidTestOrchestratorWithTestCoverageSample "https://github.com/android/testing-samples/tree/main/runner/AndroidTestOrchestratorWithTestCoverageSample/"
        end
        subgraph "ui (Green)"
            direction TB
            subgraph "espresso"
                direction TB
                BasicSample["BasicSample"]:::module
                click BasicSample "https://github.com/android/testing-samples/tree/main/ui/espresso/BasicSample"
                AccessibilitySample["AccessibilitySample"]:::module
                click AccessibilitySample "https://github.com/android/testing-samples/tree/main/ui/espresso/AccessibilitySample"
                CustomMatcherSample["CustomMatcherSample"]:::module
                click CustomMatcherSample "https://github.com/android/testing-samples/tree/main/ui/espresso/CustomMatcherSample"
                DataAdapterSample["DataAdapterSample"]:::module
                click DataAdapterSample "https://github.com/android/testing-samples/tree/main/ui/espresso/DataAdapterSample"
                EspressoDeviceSample["EspressoDeviceSample"]:::module
                click EspressoDeviceSample "https://github.com/android/testing-samples/tree/main/ui/espresso/EspressoDeviceSample"
                FragmentScenarioSample["FragmentScenarioSample"]:::module
                click FragmentScenarioSample "https://github.com/android/testing-samples/tree/main/ui/espresso/FragmentScenarioSample"
                IdlingResourceSample["IdlingResourceSample"]:::module
                click IdlingResourceSample "https://github.com/android/testing-samples/tree/main/ui/espresso/IdlingResourceSample"
                IntentsBasicSample["IntentsBasicSample"]:::module
                click IntentsBasicSample "https://github.com/android/testing-samples/tree/main/ui/espresso/IntentsBasicSample"
                IntentsAdvancedSample["IntentsAdvancedSample"]:::module
                click IntentsAdvancedSample "https://github.com/android/testing-samples/tree/main/ui/espresso/IntentsAdvancedSample"
                MultiProcessSample["MultiProcessSample"]:::module
                click MultiProcessSample "https://github.com/android/testing-samples/tree/main/ui/espresso/MultiProcessSample"
                MultiWindowSample["MultiWindowSample"]:::module
                click MultiWindowSample "https://github.com/android/testing-samples/tree/main/ui/espresso/MultiWindowSample"
                RecyclerViewSample["RecyclerViewSample"]:::module
                click RecyclerViewSample "https://github.com/android/testing-samples/tree/main/ui/espresso/RecyclerViewSample"
                ScreenshotSample["ScreenshotSample"]:::module
                click ScreenshotSample "https://github.com/android/testing-samples/tree/main/ui/espresso/ScreenshotSample"
                WebBasicSample["WebBasicSample"]:::module
                click WebBasicSample "https://github.com/android/testing-samples/tree/main/ui/espresso/WebBasicSample"
            end
            UiAutomatorBasicSample["UiAutomator BasicSample"]:::module
            click UiAutomatorBasicSample "https://github.com/android/testing-samples/tree/main/ui/uiautomator/BasicSample"
            PreviewScreenshot["Compose PreviewScreenshot"]:::module
            click PreviewScreenshot "https://github.com/android/testing-samples/tree/main/ui/PreviewScreenshot/"
        end
        subgraph "unit (Green)"
            direction TB
            UnitBasicSample["BasicSample (unit)"]:::module
            click UnitBasicSample "https://github.com/android/testing-samples/tree/main/unit/BasicSample/"
            KotlinAppBasicSample["BasicSample-kotlinApp"]:::module
            click KotlinAppBasicSample "https://github.com/android/testing-samples/tree/main/unit/BasicSample-kotlinApp/"
            NativeBasicAndroidTest["BasicNativeAndroidTest"]:::module
            click NativeBasicAndroidTest "https://github.com/android/testing-samples/tree/main/unit/BasicNativeAndroidTest/"
            UnitAndroidTest["BasicUnitAndroidTest"]:::module
            click UnitAndroidTest "https://github.com/android/testing-samples/tree/main/unit/BasicUnitAndroidTest/"
        end
    end

    %% External Dependencies
    SDK["Android SDK & AndroidX Libraries"]:::external

    %% Connections
    Repo --> Actions
    Repo --> Buildkite
    Actions --> Gradle
    Actions --> Bazel
    Buildkite --> Bazel
    Gradle --> ServiceTestRuleSample
    Gradle --> AndroidJunitRunnerSample
    Gradle --> UiAutomatorBasicSample
    Bazel --> ServiceTestRuleSample
    Bazel --> AndroidTestOrchestratorSample
    Bazel --> PreviewScreenshot
    Bazel --> UnitAndroidTest
    ServiceTestRuleSample --> SDK
    AndroidJunitRunnerSample --> SDK
    AndroidTestOrchestratorSample --> SDK
    AndroidTestOrchestratorWithTestCoverageSample --> SDK
    BasicSample --> SDK
    AccessibilitySample --> SDK
    CustomMatcherSample --> SDK
    UiAutomatorBasicSample --> SDK
    PreviewScreenshot --> SDK
    UnitBasicSample --> SDK
    NativeBasicAndroidTest --> SDK

    %% Styles
    classDef repo fill:#f9f,stroke:#333,stroke-width:1px
    classDef ci fill:#bbf,stroke:#333,stroke-width:1px
    classDef build fill:#f96,stroke:#333,stroke-width:1px
    classDef module fill:#9f6,stroke:#333,stroke-width:1px
    classDef external fill:#ccc,stroke:#333,stroke-width:1px
```
