What is Unit Testing?

Unit Testing is the testing of individual software components or modules. It is the foremost level of software testing and is commonly performed prior to integration testing.
Unit testing performed in the implementation phase can result in significant gains in software quality. If unit testing is done properly, testing phases done later on will be more successful. Unit testing is considered the job of developers only and test engineers need not know about Unit testing. But this is not the case, Unit testing is as important for test engineers as it is for developers.

Developers generally write the unit test cases but it is also important for the testers to understand them. Tester’s understanding of the framework and unit testing can certainly help him/her in designing the flow for unit test cases, generating test data and making good reports. All these activities will ultimately help a tester in the long run as product quality will increase significantly because of the efforts a tester put in on the unit testing.

Advantage/Benefits of Unit Testing

  • Unit Testing plays a major role in the total testing efforts.
  • It allows being able to test parts of a project with out waiting for the other parts to be available.
  • Achieve parallelism in testing by being able to test and fix problems simultaneously by many engineers.
  • Be able to detect and remove defects at a much less cost compared to other later stages of testing.
  • Be able to take advantage of a number of formal testing techniques available for unit testing.
  • Simplify debugging by limiting to a small unit the possible code areas in which to search for bugs.
  • Be able to test internal conditions that are not easily reached by external inputs in the larger integrated systems (for example, exception conditions not easily reached in normal operation).
  • Be able to achieve a high level of structural coverage of the code.
  • Avoid lengthy compile-build-debug cycles when debugging difficult problems.
  • Unit testing is more cost effective compared to the other stages of testing.

Demerits of Unit Testing:-

  • Testing can be monotonous, boring and repetitive at this level.
  • Poor Documentation of Test cases may be there.
  • Coding Drivers and Stubs.
  • Informal testing process.
  • Poor Regression Testing.
  • Lack of Complete Testing tools.