Learn Everything

Paths/Backend Engineer/Testing Backend Code / The Test Layers

Guided Taskbeginnerubuntu:24.04Ask AI

Define the Test Layers

Unit, integration and end-to-end tests answer different questions and cost different amounts. Write what each layer covers in your service.

Validator

⏱ 0:00

IDLE — checks run live as you type commands; submit when done

01Requirements

live checks
  • Directory ~/tests exists○
  • File ~/tests/strategy.md exists○
  • The document describes all three layers○
  • The document states the proportion rule○

02Walkthrough

4 steps
  1. 01

    Create the tests directory

    The test strategy is a document the team argues about once, not on every pull request.

    mkdir -p ~/tests
  2. 02

    Write the three layers

    Unit tests cover the logic, integration tests cover the wiring to real dependencies, end-to-end tests cover the paths users actually take.

    echo '# Test strategy\n\n## The layers\n\n- unit - pure logic, no network, no database, milliseconds\n- integration - the service wired to a real database and a real queue\n- end-to-end - the deployed system, exercised through the API' > ~/tests/strategy.md
  3. 03

    State the proportion rule

    A wide base of unit tests and a thin spike of end-to-end tests. The ratio is what keeps the suite fast enough to run on every save.

    echo '\n## The ratio\n\nKeep the ratio at roughly 70 percent unit, 20 percent integration and 10 percent end-to-end, and the suite stays under ten minutes.' >> ~/tests/strategy.md
  4. 04

    Verify and submit

    cat the strategy, then submit for validation.

    cat ~/tests/strategy.md

03Stuck?

0 of 3 revealed

Take a hint without losing the lab — each one points at the thing to look at, not at the answer.

04AI Tutor

guides, never solves

Tell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?

04Notebook

saved locally in this browser

learner@lab — ubuntu:24.04

↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list