Knowledge · IT · Data · DX

Unit Testing

Unit Testing

📂IT · Data · DX⏱2-min read📊Practitioner🔗4 related

What is unit testing?

In one line
Tests that automatically verify the smallest pieces of code (such as functions) work as intended. The foundation of quality.
⚡ Summary in 3 lines
  • Automatically verify small pieces of code
  • Confirm a fix didn't break anything
  • Improve quickly, with confidence

What unit tests really change is not the code but how the team makes decisions. In a codebase without tests, improvement proposals keep getting shelved in meetings because 'we don’t know what will break if we touch that function.' So instead of removing outdated logic, people pile on one more conditional to work around it, and the file keeps growing every year. With tests in place, the standard shifts to 'just fix it and run the tests.' Even if a developer three months into the job touches a five-year-old payment module, a test that runs in seconds will flag any problem, and the change can be reverted on the spot.

In practice, tests are used in layers. A unit test isolates a single function and runs in milliseconds, without touching a database, external API, or file system. Once a database connection or API call is involved, it becomes an integration test; once a browser is launched to follow a user scenario, it is an E2E test. External dependencies are replaced with fake objects (mocks and stubs) to keep tests fast and reproducible. The usual structure is a thick base of fast, frequently run unit tests, with a thin top layer of slow E2E tests. For coverage, start with modules where money is at stake, such as payments and settlement. Where coverage lands matters far more than the overall average.

Things usually go wrong in three places. First, if you set 80% coverage as a KPI, you get more tests that call functions without any assertions just to fill the number. The metric stays green while incident counts stay the same. Second, tests tied to internal implementation. If they verify call order or even internal variables, dozens break with every refactor, and developers comment them out instead of fixing them. Third, a broken test left unfixed for more than a day is a dead test. Once a red build becomes routine, nobody looks at it. Also, unit tests do not replace QA or acceptance testing: every part can work fine and the assembly can still be wrong.

Courses that cover this term · AI & DX
Recommended courses · Recommended instructors · Quick quote
🧮 Mini quote · Based on instructor fees
About KRW 1.2 million (≈ US$900)2-hour talk · up to 20 people · Korean
Get a quote for these requirements →
💡 In plain English
Like testing each machine part one at a time: after a change, it automatically confirms that 'nothing broke.'
Why it matters in practice
With tests in place, you automatically confirm that a fix didn't break anything. You can improve your code quickly and with confidence.
Origin and sources

A verification technique in software engineering that became standard practice alongside the spread of test-driven development (TDD) and automation tools.

An example

Consider a hypothetical case: the development team at Company A, which runs a logistics SaaS with 240 employees. Each of its two regular monthly releases averaged three incidents, forcing repeated overnight rollbacks, and nobody wanted to touch the six-year-old settlement module. Tests existed, but overall coverage was only 8%.

  1. When Manager Kim, the development team lead, sorted the past year’s 47 incidents by module, half came from just two places: settlement and fee calculation. The team narrowed its scope to 'Don’t try to cover everything. Start here.'
  2. For the fee calculation function, the team turned the contents of real incident tickets directly into tests. They wrote 32 cases over two weeks, covering late-night surcharges, remote-island surcharges, return fees, and more.
  3. Calls to the external shipping carrier API were replaced with mock objects, cutting total run time from 11 minutes to 40 seconds, and the tests were set to run automatically in CI on every commit.
  4. After the build stayed broken for two days, Manager Kim made 'nobody goes home on a red build' a team rule, and the average time to fix a broken test dropped to under half a day.
  5. Six months later, coverage of the two modules reached 76%, incidents per release fell from 3 to 0.5, and overnight rollbacks dropped from 4 per quarter to 0. Improvements to the long-postponed settlement module were back on the schedule for the first time in three years.
Related terms
Training linked to this term
📚Building a Real-World Website with Claude CodeNanum Consulting corporate training · On-site/OnlineView Course →
Need in-house training on this topic?
Get a curriculum and quote tailored to your needs right away.
Ask About Training
Last updated 13 Sep 2026 · Reviewed by John Kim

FAQ

It takes longer at first, but catching bugs early and making changes safely saves time in the long run.
It’s actually even more useful. Verifying quickly written code with tests improves its stability.
It takes longer at first, but catching bugs early and making changes safely saves time in the long run.
It’s actually even more useful. Verifying quickly written code with tests improves its stability.