DELAPARRA
Index
Color
NL
Category: Core glossary

Unit test

Explained by Updated

What is Unit test?

Unit test: A test that verifies a single, isolated piece of functionality (a function, a method) in isolation from the rest of the system. The fastest and most granular type of test. A unit test checks a small piece of code, such as one function or method, in isolation from the rest of the system. It runs in milliseconds, without a database, network or file system.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Unit test

How is Unit test used in practice?

Unit tests are ideal for logic with clear inputs and outputs: price calculations, date rules, validation, formatting. They pinpoint exactly what broke, because each test covers so little.

What should you keep in mind with Unit test?

They work best combined with other kinds of tests. Feature or integration tests check that parts work together, such as a request reaching the database and returning the right page. In Laravel, both live side by side in PHPUnit or Pest. A good habit is to write a failing test before fixing a bug. It proves the fix works and prevents the same bug from quietly returning.

At a glance

CategoryCore glossary
Explained by
Updated

More Core glossary terms

All terms starting with U

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.