Test level and test role are different classifications

Unit, integration, API, and E2E describe the verification level. Smoke and regression describe the role in the suite. Therefore, E2E can be smoke, and a regression test can exist at unit, integration, API, or E2E level.

RolePurpose
SmokeQuickly confirm that the critical system works overall
RegressionPreserve a specific defect that has already occurred
E2EWalk through the complete user path across the system

Smoke tests should be short and stable

  • Check a minimal set of critical signals.
  • You can start with a health endpoint and the first orders page.
  • Do not turn smoke into the entire product functionality.
  • A short stable suite is more useful than a long fragile scenario.
  • After changes, check that the main service is available.

Regression preserves the memory of a defect

If a double refund created two records, the regression test should repeat the operation and check that one record remains in storage. The test level is determined by where the problem appears.

  1. Reproduce the problem.
  2. Write a test that shows the incorrect behavior.
  3. Make the fix.
  4. Confirm that the same test passes.
  5. Keep the test in the repository for future runs.

E2E is needed for high business risk

E2E follows a user path through the UI, backend, and related components. It is appropriate for checkout, an operator confirming a refund, or entry to an administration panel when the defect appears only in the full flow.

Not every UI detail needs E2E. Excessive E2E increases run time, fragility, and diagnosis complexity.

Do not hide flaky tests with reruns

Cause of instabilityControl
Time and randomnessFix the clock and seed
Network or external servicesIsolate the dependency or use a controlled stub
Animations and slow responsesReliable waits instead of sleep
Fragile selectorsStable semantic selectors
Test orderIndependent fixtures and state isolation

Canonical lesson source · JavaRush

Open JavaRush material