Dallonses logo

Unit testing

What is unit testing?

A unit test is an automated test that checks the smallest testable piece of code on its own. Usually a single function, method, or class. It exercises one thing, one scenario, with nothing else attached: no database, no network, no file system. Anything the unit normally pulls from the outside world gets swapped for a controlled stand-in called a mock or a stub.

Each test gives the unit a specific input, runs it, and asserts that the output matches what was expected. Because the unit runs in isolation, a failing test points straight at the code that broke rather than somewhere three systems away. A pricing function that should apply a 10 percent discount can be pinned down with a handful of tests covering the normal case, the zero case, and the edge where the discount would push the total negative. Unit tests are fast, easy to automate, and give immediate feedback the moment a change breaks existing behaviour, which is why a codebase with strong coverage is so much safer to refactor and maintain.

They sit at the base of any serious testing strategy, beneath integration and end-to-end tests. They are also the foundation of test-driven development, where the tests get written before the code they are meant to verify.

Unit testing at Dallonses

Unit tests are part of how we write code, not a chore bolted on at the end. If the logic touches money, permissions, or anything a user depends on, it ships with tests that prove it works and keep proving it. That coverage is what lets us change a system months later without holding our breath.

For clients this is the quiet half of software quality assurance that pays for itself over time. Automated unit testing catches regressions in seconds instead of in a support ticket, and a well-tested codebase stays cheap to extend. We treat the test suite as part of the product we hand over, because it is.

Inherited a codebase you're afraid to touch? Tests are where we'd start.

Talk to us about testing

Related services


Ready to work together?

Book a meeting
Aymón holding a Tools magazine in front of their facem
Ari working on a laptop outdoors surrounded by plants
Top-down view of a wooden desk with a keyboard, mouse, and headphones
Hand-drawn illustration of a hand snapping fingers
Nico leaning against a water cooler next to a fire extinguishe
Close-up of an open computer with circuit board and components on a wooden desk
Bernat and Andreu collaborating at a desk with monitors and a laptop
Hand-drawn illustration of an open hand waving
Aymón holding a Tools magazine in front of their facem
Ari working on a laptop outdoors surrounded by plants
Top-down view of a wooden desk with a keyboard, mouse, and headphones
Hand-drawn illustration of a hand snapping fingers
Nico leaning against a water cooler next to a fire extinguishe
Close-up of an open computer with circuit board and components on a wooden desk
Bernat and Andreu collaborating at a desk with monitors and a laptop
Hand-drawn illustration of an open hand waving