Unit testing

Unit testing image
Unit Testing is a level of software testing that focuses on checking the smallest testable parts of an application, often referred to as 'units', in isolation from the rest of the code. Think of a unit as the tiniest bit of code that makes sense to test on its own, like an individual function, method, or class. 

The whole point of unit testing is to ensure that each individual 'unit' of code works exactly as it is expected to. These tests are typically written by the developers, often at the same time as the code they are creating. They are automated, can run for every code commit, and tend to run very quickly. They provide immediate feedback on whether a recent change or addition to the codebase has introduced a bug into that specific small piece of code. It is important to understand that unit tests have a binary outcome. The unit either does precisely what it is expected to do, or it does not. There is no grey area. 

Unit tests are designed to be precise. If needed, the test can isolate the unit from its dependencies using techniques like mocking or stubbing. This means if a unit test fails, you know precisely which tiny bit of code is causing the trouble, making it much easier and quicker to find and fix bugs. It is about identifying problems as early as possible in the development cycle, building confidence in the foundational blocks of software before they are combined into larger, more complex systems. Unit tests are a key part of building quality from the ground up.
Reduce flakiness. Try Squish for free. image
Enhance test coverage, and streamline automation. Take a tour!
Explore MoT
Leading with Quality image
Tue, 30 Sep
A one-day educational experience to for quality engineering leaders
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
Leading with Quality
A one-day educational experience to help business lead with expanding quality engineering and testing practices.
This Week in Testing image
Debrief the week in Testing via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.