madhavrao… » Unit Testing

Unit Testing

What is Unit Testing?
Unit testing is a procedure, to validate the individual unit of source code are working properly. A unit is the smallest testable part of the application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method; which may belong to a base/super class, abstract class or derived/child class.
Each Unit test case is independent of others, mock objects and test harness can be used to assist testing in isolation.

What are benefits of Unit Testing?
Benefits of Unit Testing are as follows:

  • It allows isolating and testing each part of the system independently.
  • It allows the programmer to refractor the code later, and make sure module still works correctly.
  • It helps to eliminate uncertainty in the units.
  • It provides a sort of living documentation of the system

What is Mock Objects?
Mock Objects are simulated objects that mimic the behavior of real objects in a controlled way. In a unit test, mock objects can simulate the behavior of the complex, real (non-mock) objects and are therefore useful when a real object is difficult or incorporate into a unit test. Mock Objects makes it possible to test a unit of code, even before dependent code is developed.

When to use a Mock Object?
Mock Objects should be used in following scenarios:

  • Original object supplies non-deterministic results.
  • Original object has states that are difficult to create or reproduce
  • Original object is slow
  • Original object does not yet exist.

What are Benefits of using Mock Objects?
Benefits of using Mock Objects are as follows:

  • It allows unit testing a code, even before dependent  code is developed.
  • It allows to concentrate on code under unit test, rather than integration issues of dependent objects
  • It also helps in defining functionality of the original objects to some extent.

What is Test harness?
A test harness or automated test framework is a collection of software and test data configured to test a program unit by running it under varying conditions and monitor its behavior and output.
It has two main parts

  • Test execution engine
  • Test script repository

What are benefits of Test harness?
Benefits of Test harness are as follows:

  •    Increase productivity due to automation of testing process
  •    Increased probability that regression test will occur
  •    Increased quality of software components and application

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>