Unit Testing introduction

Go to previous article – Acceptance Testing introduction

What is Unit Testing?

Unit testing is a method of software testing in which source code, sets of computer program modules, usage procedures, and operating procedures are tested to see if they work as expected.

Tunit-testinghe main goal of this method is to isolate individual parts of a program to show that they are either correct or incorrect– hopefully correct. In order to pass as correct it must behave correctly and also it must pass a strict set of code standards.

Unit testing is important for one reason because it forms the basis for component testing as the fragments of code created by programmers/ white-box testing during the development process are used.

Unit tests are usually written and then run by software developers to make sure the code meets a certain design and behavior criteria.

 

Each test case is run independently from the other and for this we may use stubs or drivers to simulate other parts of the system that we are not currently testing; however, sometimes one test case can mix into another if there are references to other classes.

One example of this is when a class depends on a database so the code has to interact with a database. If this does happen, (which it is oftentimes not recommended) then unit testing becomes a different type of testing called integration. If a failure occurs in the test case at this point a clear indication of the problem is not possible.

The execution of Unit Testing –

As far as the execution of unit testing, it is most often automated but may still be executed manually by a software tester or programmer. Unit testing’s objective is to isolate one single unit to validate how correct it is. By taking the manual testing approach a step-by-step set of instructions has to be followed.

This being said, an automation testing approach can do all that the manual approach can and is just as efficient; if not planned carefully, simple mistakes can be easily made in the manual method. To fully utilize the automated method, the individual units are tested under a framework outside of its normal environment.

The Benefits:

  • There are many advantages to unit testing as the code is tested very strictly. One benefit is the ability to find problems early in the development process; this includes bugs and flaws in the specific unit and in the programmer’s implementation.
  • Unit testing forces developers to better structure functions. This method of testing also helps facilitate change; unit testing lets the programmer update the libraries of a system at a later time and make sure it all works correctly.
  • When a test case is written for every method and function and a change in the case causes a fault, it can quickly be identified.

The Disadvantages:

While there are many benefits there are also a few disadvantages of unit testing, one of those being the inability to catch every error in the program. Unit testing cannot evaluate every path of execution and it only tests the functions of the units by themselves; it cannot catch integration errors.

 

Go to next article –User-Acceptance testing

Share This Post

Post Comment

Show Buttons
Hide Buttons