Why Testing Matters
Testing is how you find out whether software does what it should, before your users do. It ranges from checking a change by hand to suites of automated tests that run on every commit.
What testing gives you
- Quality: bugs are found while they are cheap to fix, on your machine or in a pull request, instead of in production.
- Confidence: a green test run tells you a change did not break existing behaviour, which makes it safe to ship small changes often.
- Maintainability: tests describe what the code is supposed to do, and they let you refactor without fear. Code without tests is often called legacy code for exactly this reason.
Kinds of tests
You will meet these names often:
| Kind | Checks |
|---|---|
| Unit test | One small piece in isolation |
| Integration test | Several components working together |
| End-to-end test | A complete user flow through the system |
| Regression test | That a fixed bug stays fixed |
A common rule of thumb is to have many fast, small tests and few slow, broad ones. This is often drawn as a “test pyramid”.
Common misunderstandings
- Tests do not prove the absence of bugs. They show that the cases you thought of work.
- Coverage numbers measure which lines ran, not whether the checks are meaningful.
- Not everything should be automated. See Test Automation Principles.
Where it fits
Automated tests usually run in a CI/CD pipeline on every push, and reviewers expect them in a pull request. The topics that follow cover unit tests, integration tests, manual testing and reporting defects.
Try it
Pick a small piece of code you wrote or know well. List five ways it could fail: normal input, empty input, a boundary value, invalid input and a failing dependency. Check each by hand, and note which checks you would be happy to see run automatically on every change.
Common mistakes
- Believing passing tests prove there are no bugs.
- Treating a coverage number as a measure of quality.
- Trying to automate everything.
- Finding out about regressions from users instead of from tests.
Check yourself
- What are the benefits of testing named on this page?
- How do a unit test and an integration test differ?
- Why does a coverage number not prove the tests are good?