Unit Testing

html5 and css3

Unit Testing

Unit testing is the test that verify the specific unit of the code. From the unit testing code coverage can be calculated to detect the code which is being delivered how much is actually tested by developer. As aim of unite testing is executing each line developed, Unit testing helps to detect the corner cases which in general will not be caught during the functional tests. There are various methods of unit testing automation for every language, to name a few Gtest/Gmock, junit, Cunit. In general unit test support comes along with programming language.

Unit testing is a software testing technique that focuses on verifying the individual units or components of a software application in isolation. A unit refers to the smallest testable part of the software, typically a function, method, or class. The purpose of unit testing is to ensure that each unit functions correctly and meets the expected behavior


  • Unit testing improves the quality of the code
  • Unit testing allows the programmer to refactor code or upgrade system libraries
  • Unit testing reduces defects in the newly developed features or reduces bugs when changing the existing functionality
  • Unit testing aims to isolate each unit under test from the rest of the system.
  • Unit testing helps reduce the cost of bug fixes
  • Unit tests should provide high coverage, meaning that they exercise different scenarios and edge cases within each unit.
  • Unit tests are usually automated using testing frameworks and tools specific to the programming language or development environment.
  • Various unit testing frameworks exist for different programming languages.
  • Unit testing often involves replacing dependencies on external systems or components with test doubles.
  • Unit testing is often a core practice in Test-Driven Development.
  • Unit tests include assertions, which are statements that check if a specific condition or behavior matches the expected result
  • Continuous Integration: Unit tests play a crucial role in continuous integration workflows.
  • Unit tests provide a safety net during refactoring activities.

Why Unit Testing?

Unit testing, especially test driven development, is a design or implementation activity, not a testing activity.