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.
| Role | Purpose |
|---|---|
| Smoke | Quickly confirm that the critical system works overall |
| Regression | Preserve a specific defect that has already occurred |
| E2E | Walk 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.
- Reproduce the problem.
- Write a test that shows the incorrect behavior.
- Make the fix.
- Confirm that the same test passes.
- 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 instability | Control |
|---|---|
| Time and randomness | Fix the clock and seed |
| Network or external services | Isolate the dependency or use a controlled stub |
| Animations and slow responses | Reliable waits instead of sleep |
| Fragile selectors | Stable semantic selectors |
| Test order | Independent fixtures and state isolation |
Canonical lesson source · JavaRush
Open JavaRush material