Unit Testing in Software Testing

What do you mean by unit testing?

Unit testing is a type of testing where an individual unit of the software is being tested rather than the software as a whole. A unit is the smallest testable entity of a software. The unit testing is performed on individual module of the software so that the software is tested thoroughly and to ensure each unit works as per the specifications given by the user. Unit testing enables a developer to determine if a particular unit is fit to be used further in the software code and is not redundant.

Below mentioned tests are performed while doing Unit testing:

1) Basis Path testing: Each and every control flow in the lines of code is tested to determine the set of linearly independent paths. Basis on these set of linear paths test cases are generated. Test cases ensure that each of the identified paths have been executed at least once.

2) Boundary testing: Many software fail at the boundary value e.g. extreme values of the "for loop". By determining the boundary values of the unit of the software, we check whether the module fails or passes the test and how it behaves at these extreme values.

3) Data flow testing: In this, the correctness of the data flow logic in the module is tested. Points where variable receive values and how they use it is checked during this type of unit testing.

4) Local data structure: In this, we check the integrity of local variables stored in the code and they are not altered in-evidently.

5) Error handling path: Tests are performed in the module to check whether proper handling is done in the modules or not.
white box testing, softwaretestinghelp
Different types of Unit testing

When is Unit testing performed ?

Unit testing is performed at the initial level of testing phase. The smallest part of a software is known as a Unit. So before testing the whole software at once, it is crucial to test a single module properly. Hence, we can minimize errors while integrating different small modules.

wiki software testing types
Different stages of software testing

Who performs Unit Testing?

Unit testing is performed by the software developer who has developed the software or his/her peers. Sometimes on rare occasions it can be performed by the testers.

How Unit Testing is performed ?

Unit testing is performed with help of Stub and drivers. Before understanding how unit testing is performed let us understand what a Stub and Driver is. As we all know that individual modules cannot function independently and it is difficult to test them individually also. So we have the concept of Stub and Driver. For each of the modules tester develops stub and driver.

Driver: Driver is the main program that invokes modules to be tested.
Stub: Stub is the module that is called by the module to be tested.

Let us understand this with help of diagram.
Drivers and Stubs Example, testing driver stub, module testing
Driver and stub in unit testing

Driver is the program through which the module (whose unit testing is being performed) is invoked or called .Test cases’ data is passed to the modules through the driver.
Stubs are the programs which are called by the module being tested, the test data are passed to the stubs with the help of the module and once the data are processed through the stub, the program control goes back to the module and result is returned to the module.
Next we will discuss the benefits of unit testing.

You may also like to read:
Testing v/s Debugging
What is Exhaustive Testing In Software Testing?
Advantages and Disadvantages of Outsourcing Testing Activity
What is Software Bug ? Defect Life Cycle Explained

Copyright © ianswer4u.com

0 Reactions:

Post a Comment