๐Ÿงช
๐Ÿงช Testing & Quality ยท TEST-101 ยท Session 1 of 5

Why Test? Confidence to Change

Testing isn't about proving you're a good programmer โ€” it's about being able to change your code without fear. That confidence is what lets software grow instead of rotting.

โฑ 8 min read๐Ÿ“… Updated 2026-08-03๐Ÿ“Š Tables, charts & examples

Testing has a reputation for being tedious box-ticking. It's the opposite: writing tests is one of the highest-leverage habits a developer has, because it buys you confidence to change your code. Without tests, every change risks silently breaking something, so you become afraid to touch working code - and software that can't be changed safely slowly rots. This session is about why testing is worth it, before we get into how.

๐Ÿ“Œ Worked example
The refactor that would have been terrifying. A developer needs to rewrite the messy core of a working app to make it cleaner - the kind of change that could break a dozen things in subtle ways. Because the app has a solid test suite, they rewrite fearlessly: after each change they run the tests, and the moment something breaks, a red test names exactly what and where. An hour later the core is clean, every test green, and they're confident nothing regressed. Without tests, that same refactor would have been a white-knuckle gamble - change something, hope, ship, and wait for users to find what broke. Tests turned a scary rewrite into a safe, routine improvement. That confidence to change is what testing really buys you.

Tests are code that checks your code

A test is simply a small piece of code that runs your code with a known input and checks it produces the expected output. That's the whole idea.

# your code
def add(a, b):
    return a + b

# a test: known input -> expected output
def test_add():
    assert add(2, 3) == 5
    assert add(-1, 1) == 0
๐ŸŽฏ
A test pins down what 'correct' means, forever. Once you've written assert add(2, 3) == 5, you've captured a fact about your code that a machine can re-check in a fraction of a second, any time. Change the code, run the tests: if you broke that fact, you know instantly. That's the magic - your knowledge of what the code should do becomes automated and permanent, instead of living only in your head or in slow, error-prone manual checking.

The real payoff: fearless change

The biggest benefit isn't catching bugs today - it's being able to improve your code tomorrow without breaking it.

Without testsWith tests
Afraid to change working codeChange freely - tests catch breakage
'Does it still work?' = manual checking'Does it still work?' = one command
Bugs found by users (or never)Bugs found the second you introduce them
Code rots - too risky to touchCode grows - safe to refactor and extend

This is why professionals test: not to prove the code works once, but to keep it working as it grows and changes. A well-tested codebase can be refactored, extended and fixed with confidence for years. An untested one becomes a fragile thing everyone's scared to touch.

The confidence habit

  • A test runs your code with a known input and checks the expected output.
  • Tests pin down 'correct' so a machine re-checks it instantly, forever.
  • The real payoff is fearless change - refactor and extend without breaking things.
  • Tested code grows; untested code rots because it's too risky to touch.

๐ŸŽฏ Key takeaways

  • A test is just code that runs your code with a known input and checks the expected output.
  • Tests pin down what 'correct' means so a machine can re-verify it instantly, any time.
  • The biggest payoff isn't catching bugs today - it's the confidence to change code tomorrow without breaking it.
  • Tested code can grow and be refactored safely; untested code rots because it's too risky to touch.

Frequently asked

Isn't writing tests just extra work that slows me down?

It feels like extra work up front, and it is a bit more typing in the moment - but it saves far more time than it costs on anything you'll keep working on, which is why experienced developers embrace it rather than resent it. Consider what tests replace: without them, every time you change your code you have to manually check that you didn't break anything, which is tedious, easy to do incompletely, and gets slower as the project grows. With tests, that check is a single command that runs in seconds and is thorough. So the small up-front cost of writing a test buys you fast, reliable re-checking forever after. The real time savings come from the bugs you don't ship and the debugging you avoid: catching a bug the instant you introduce it (because a test fails) is dramatically cheaper than discovering it later when it's tangled up with other changes, or worst of all when a user hits it in production. Tests also let you refactor and add features boldly instead of tiptoeing around fragile code, which keeps you fast over the life of a project rather than grinding to a halt as fear of breaking things accumulates. There's nuance: for a five-line throwaway script, tests may genuinely not be worth it, and you shouldn't test trivial glue code or aim for testing every last line. But for anything real that you'll maintain or grow, tests are a net time saver, not a time sink - they trade a little effort now for a lot of saved effort and avoided pain later. The mindset shift is seeing tests not as a chore that slows you down but as the thing that lets you go fast safely, especially over time. Start by testing the important logic of your projects, feel how much more confidently you can then change things, and you'll come to value them not as bureaucracy but as the tool that keeps you productive and your code trustworthy.

If I'm careful and my code works, do I still need tests?

Yes - because 'careful and it works right now' doesn't protect you from the two things tests actually guard against: subtle bugs you didn't notice, and future changes that break what currently works. Being careful is valuable and reduces bugs, but no one is careful enough to catch everything by manual checking, especially as code grows and interacts in complex ways; tests catch cases you'd overlook and edge cases you didn't think to try by hand. More importantly, 'it works now' is a snapshot, and code doesn't stay still - you'll fix things, add features, refactor, and each change risks silently breaking something that worked before. Without tests, you either re-check everything manually every time (slow and unreliable) or, more likely, you don't, and breakage sneaks in unnoticed until much later. Tests turn 'it works now' into 'it keeps working', by re-verifying all your captured expectations automatically on every change. There's also a subtler point: writing tests often reveals that your code doesn't work as well as you thought, because articulating exactly what it should do and checking edge cases surfaces bugs and unhandled cases your careful-but-informal checking missed. So even for code you're confident in, tests provide a safety net for the future and a rigorous check in the present that careful coding alone can't match. This doesn't mean test obsessively or distrust your care - being thoughtful while coding is great and complementary. It means recognising that human carefulness and automated testing catch different things and both matter: your care prevents many bugs, and tests catch the rest and protect against future breakage. For anything you'll keep and grow, that combination is what trustworthy software is built on. Careful coding plus tests, not careful coding instead of tests.

Session 1 of 5 complete

Next up: Writing Your First Tests

Continue to Session 2 โ†’

Related lessons

More in this course

Course home → · Browse all courses →