Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
Test automation · Fundamentals & Architecture · Chapter 05 / 06

Test automation learning path

CI, parallelism & reporting

Pipeline shape, parallel execution, artifacts that explain failures, and gates people trust.

Pipeline shape and what should block a merge

Fast layers gate slow ones, cancel superseded runs, and gate only on things a team can fix today.

A pipeline should run cheapest first: lint, then the service layer, then browsers, then anything requiring a device. Ordering this way means a broken build is usually reported in under a minute instead of after eight minutes of browser time, and it costs nothing to arrange. Three settings matter more than the syntax of any particular CI system. Cancelling superseded runs when a new commit arrives saves machine time and stops stale failures from confusing reviewers. Disabling fail-fast in a browser matrix keeps one engine's failure from cancelling the others, which preserves exactly the information that tells you whether a problem is cross-browser — a matrix caught a real defect in this course's own framework, where a Chromium-only launch flag made every WebKit test fail. And a timeout on every job stops a hung browser from burning hours. On gating, the guiding principle is that a gate people cannot satisfy today gets disabled within a week, so ratchet thresholds down over time instead of starting at maximum strictness.

Key points

  • Order jobs cheapest first so a broken build is reported in seconds, not after browser time
  • Cancel superseded runs, disable fail-fast in a matrix, and set a timeout on every job
  • A gate people cannot satisfy today gets disabled within a week — ratchet thresholds down over time

Code

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true          # a new push makes the old run obsolete

jobs:
  services:
    needs: lint
    timeout-minutes: 10             # a hung job otherwise burns hours

  web:
    needs: services                 # do not spend browser minutes on a broken API
    strategy:
      fail-fast: false              # one engine failing must not cancel the others
      matrix:
        browser: [chromium, firefox, webkit]

  mobile:
    # Real devices are slow and cost money: nightly and on demand only.
    if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'

This exact matrix caught a Chromium-only launch flag that made every WebKit test fail.

See it in the framework

  • CI · CI pipeline: .github/workflows/ci.yml — live · reviewed

Reviewed against commit f9ada16 (2026-08-14).

Common pitfalls

  • Leaving fail-fast enabled in a browser matrix, which cancels the other engines and hides whether the issue is cross-browser
  • Gating on a metric that can be gamed, such as a coverage percentage, which changes behaviour without improving quality

Practice exercise

Review a pipeline you have access to for the three settings above. Add whichever are missing, then check how long it now takes to learn that a build is broken.

Making the suite fast

Parallelism, caching and API seeding compound; measure first, because setup is usually the real cost.

Speed is a feature of a test suite because it determines whether people wait for the result or merge without it. Once a suite passes ten minutes for the pull-request gate, engineers start treating it as advisory. The levers that actually move the number are parallel execution, which typically gives a three to five times improvement; caching browser binaries and dependencies, which saves a minute or two per job; ordering fast layers before slow ones so most broken builds fail early; and building preconditions through the API rather than the interface, which can be an order of magnitude on the affected tests. Shard by layer rather than by file, because layers have similar per-test costs and balance better. The important discipline is to measure before optimising. Reporting the slowest tests is built into the runner, and nine times out of ten a slow suite is slow because of setup — a login repeated hundreds of times, a fixture with too narrow a scope, a browser launched more often than necessary — rather than because the tests themselves are slow.

Key points

  • Parallel execution typically gives three to five times; caching and API seeding compound with it
  • Above ten minutes for the pull-request gate, people stop waiting and start merging blind
  • Measure before optimising — setup, not the tests themselves, is usually where the time goes

Code

# Measured on this course's own suite:
#   sequential                65 s
#   -n 4                      36 s
#   services layer alone      11 s   (no browsers installed at all)

- name: Cache Playwright browsers
  uses: actions/cache@v4
  with:
    path: ~/.cache/ms-playwright
    key: playwright-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}

- run: pytest tests/web --browser=${{ matrix.browser }} -n auto

# Built into the runner, and the first thing to look at:
#   pytest --durations=10

Parallelism only pays once data is isolated; otherwise it converts a slow suite into a flaky one.

See it in the framework

  • CI · CI pipeline: .github/workflows/ci.yml — live · reviewed
  • Used by · Root fixtures: conftest.py — live · reviewed

Reviewed against commit f9ada16 (2026-08-14).

Common pitfalls

  • Turning on parallelism before the data is isolated, which converts a slow suite into a flaky one
  • Optimising the tests when the profile shows the cost is in repeated logins and browser launches

Practice exercise

Profile a suite with the slowest-test report. Identify whether the time is in setup or in the tests, then apply the single change with the largest expected effect and measure again.

Artifacts that explain a failure

Capture screenshot, page state, console and request log on failure only — and redact secrets first.

The time between a failure appearing and somebody understanding it is a real metric, and it is determined by what the framework captured. Collecting artifacts for every test produces gigabytes of noise that nobody opens, so the policy should be to capture on failure only. Doing that requires knowing, during teardown, whether the test passed — which a fixture cannot tell on its own. The standard solution is a reporting hook that publishes each phase's result onto the test item, after which a fixture can check it in two lines. What to capture depends on the layer: a screenshot, a page snapshot and the browser console for the interface; the full request and response log for services; the page source and platform logs for mobile, captured before the session is closed rather than after. Two things must be true of everything you attach. Secrets must be redacted first, because reports are archived and shared. And the environment must be recorded, since the first question about any old failure is which build and configuration produced it.

Key points

  • Capture on failure only; artifacts for every test are noise nobody opens
  • A reporting hook publishes the phase result so a fixture can tell pass from fail during teardown
  • Redact secrets before attaching anything, and record which build and configuration produced the run

Code

@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item, call):
    """Publish each phase's result onto the item.

    Without this, a fixture's teardown cannot tell a pass from a failure, and
    you either capture artifacts for every test or for none.
    """
    outcome = yield
    report = outcome.get_result()
    setattr(item, f"rep_{report.when}", report)


@pytest.fixture(autouse=True)
def _capture_on_failure(request, page):
    yield
    report = getattr(request.node, "rep_call", None)
    if report is not None and report.failed:
        attach_png("failure-screenshot", page.screenshot(full_page=True))
        attach_text("dom-snapshot", page.content()[:100_000])
        attach_text("page-url", page.url)

Two hooks and one fixture turn "it failed on CI" into a report that explains itself.

See it in the framework

  • Implementation · Root fixtures (screenshot/log capture): conftest.py — live · reviewed
  • Used by · Web conftest: tests/web/conftest.py — live · reviewed
  • Implementation · Reporting helpers: framework/utils/reporting.py — live · reviewed

Reviewed against commit f9ada16 (2026-08-14).

Common pitfalls

  • Attaching raw request headers, which publishes a bearer token into an archived, shareable artifact
  • Recording video and traces for every test, which fills storage and makes the interesting artifact harder to find

Practice exercise

Break a UI test deliberately and time how long it takes a colleague to diagnose it from the pipeline artifacts alone, without running anything. Add whatever was missing and measure again.

Three audiences need three artifacts, and history is what turns a report into something you can manage by.

Reporting serves three different audiences and one artifact cannot serve them all. The engineer who broke something needs to know why within about thirty seconds, which means a rich report with steps, attachments and the request log. The reviewer needs to know whether anything broke at all, which is best delivered as machine-readable results turned into annotations on the change itself. The team lead needs to know whether things are improving, which requires history. That last one is the step teams skip and the one that changes the most, because without history every report is an isolated snapshot, whereas with it you get pass-rate trends, automatic detection of unstable tests and visibility of duration drift. Restoring previous results before generating a report is usually a few lines of pipeline configuration. Report steps also deserve attention: wrapping meaningful actions in named steps turns an opaque failure into one that says precisely which stage of the flow failed, which is often enough to skip reproduction entirely.

Key points

  • Three audiences: the engineer who broke it, the reviewer, and the lead tracking the trend
  • History turns a report into a dashboard: pass-rate trends, unstable-test detection and duration drift
  • Named steps make a failure say which stage of the flow broke, often removing the need to reproduce

Code

# The four lines teams skip. Without them every report is a snapshot.
- uses: actions/checkout@v4
  continue-on-error: true
  with: { ref: gh-pages, path: gh-pages }
- run: cp -r gh-pages/last-history all-results/history 2>/dev/null || true


# Steps turn "test_checkout failed" into "test_checkout failed at: Place order".
with step(f"API: add product {product_id} x{quantity} to cart"):
    response = self.client.post(f"{self.PATH}/items", json=payload, expect=201)


# Environment metadata, written once at startup. Six months from now the first
# question about a red run is "which build and configuration was this?"
#   Environment=stage
#   Browser=chromium
#   CI=true

Restoring history is a few lines and is the difference between a report and a dashboard.

See it in the framework

  • CI · CI pipeline (Allure/JUnit): .github/workflows/ci.yml — live · reviewed
  • Implementation · Reporting helpers: framework/utils/reporting.py — live · reviewed

Reviewed against commit f9ada16 (2026-08-14).

Common pitfalls

  • Generating a report without restoring history, so you have snapshots instead of trends
  • Notifying a chat channel on every successful run, which trains everyone to mute it before the first real failure

Practice exercise

Run a suite five times with reporting enabled, generate a report with history restored, and identify your three least stable tests from the data rather than from intuition.

Source registry

5 chapter references
GitHub Actions documentation

Job dependencies, matrices, concurrency control and artifacts

GitHub · Official documentation
Source ↗
qa-automation-python reference framework

The runnable framework and demo application every lesson in this path is drawn from

sergiiiavt · Reference implementation
Source ↗
pytest-xdist documentation

Parallel execution, worker identity and test distribution modes

pytest-dev · Official documentation
Source ↗
pytest hook reference

Collection, reporting and configuration hooks used to extend a framework

pytest-dev · Official reference
Source ↗
Allure Report documentation

Steps, attachments, environment metadata and historical trends

Qameta Software · Official documentation
Source ↗