Tutorials
TestingIn this tutorial you will learn about unit testing, various levels of testing, various types of testing based upon the intent of testing, How does Unit Testing fit into the Software Development Life Cycle? Unit Testing Tasks and Steps, What is a Unit Test Plan? What is a Test Case? and Test Case Sample, Steps to Effective Unit Testing.
There are various levels of testing:
There are various types of testing based upon the intent of testing such as:
Based on the testing Techniques testing can be classified as:
This is the first and the most important level of testing. As soon as the programmer develops a unit of code the unit is tested for various scenarios. As the application is built it is much more economical to find and eliminate the bugs early on. Hence Unit Testing is the most important of all the testing levels. As the software project progresses ahead it becomes more and more costly to find and fix the bugs.
In most cases it is the developer’s responsibility to deliver Unit Tested Code.
Unit Testing Tasks and Steps:
Step 1: Create a Test Plan
Step 2: Create Test Cases and Test Data
Step 3: If applicable create scripts to run test cases
Step 4: Once the code is ready execute the test cases
Step 5: Fix the bugs if any and re test the code
Step 6: Repeat the test cycle until the “unit” is free of all bugs
This document describes the Test Plan in other words how the tests will be carried out.
This will typically include the list of things to be Tested, Roles and Responsibilities, prerequisites to begin Testing, Test Environment, Assumptions, what to do after a test is successfully carried out, what to do if test fails, Glossary and so on
Simply put, a Test Case describes exactly how the test should be carried out.
For example the test case may describe a test as follows:
Step 1: Type 10 characters in the Name Field
Step 2: Click on Submit
Test Cases clubbed together form a Test Suite
Test Case Sample
|
Test Case ID |
Test Case Description |
Input Data |
Expected Result |
Actual Result |
Pass/Fail |
Remarks |
|
|
|
|
|
|
|
|
Additionally the following information may also be captured:
a) Unit Name and Version Being tested
b) Tested By
c) Date
d) Test Iteration (One or more iterations of unit testing may be performed)
1) Documentation: Early on document all the Test Cases needed to test your code. A lot of times this task is not given due importance. Document the Test Cases, actual Results when executing the Test Cases, Response Time of the code for each test case. There are several important advantages if the test cases and the actual execution of test cases are well documented.
a. Documenting Test Cases prevents oversight.
b. Documentation clearly indicates the quality of test cases
c. If the code needs to be retested we can be sure that we did not miss anything
d. It provides a level of transparency of what was really tested during unit testing. This is one of the most important aspects.
e. It helps in knowledge transfer in case of employee attrition
f. Sometimes Unit Test Cases can be used to develop test cases for other levels of testing
2) What should be tested when Unit Testing: A lot depends on the type of program or unit that is being created. It could be a screen or a component or a web service. Broadly the following aspects should be considered:
a. For a UI screen include test cases to verify all the screen elements that need to appear on the screens
b. For a UI screen include Test cases to verify the spelling/font/size of all the “labels” or text that appears on the screen
c. Create Test Cases such that every line of code in the unit is tested at least once in a test cycle
d. Create Test Cases such that every condition in case of “conditional statements” is tested once
e. Create Test Cases to test the minimum/maximum range of data that can be entered. For example what is the maximum “amount” that can be entered or the max length of string that can be entered or passed in as a parameter
f. Create Test Cases to verify how various errors are handled
g. Create Test Cases to verify if all the validations are being performed
3) Automate where Necessary: Time pressures/Pressure to get the job done may result in developers cutting corners in unit testing. Sometimes it helps to write scripts, which automate a part of unit testing. This may help ensure that the necessary tests were done and may result in saving time required to perform the tests.
“Unit Testing” is the first level of testing and the most important one. Detecting and fixing bugs early on in the Software Lifecycle helps reduce costly fixes later on. An Effective Unit Testing Process can and should be developed to increase the Software Reliability and credibility of the developer. The Above article explains how Unit Testing should be done and the important points that should be considered when doing Unit Testing.
Many new developers take the unit testing tasks lightly and realize the importance of Unit Testing further down the road if they are still part of the project. This article serves as a starting point for laying out an effective (Unit) Testing Strategy.
| This aritcle is very nice. It provides more brief on Unit testing and How unit testing fits in Software Development life cyclie |
| Thax for this article today i learn about unit testing. The way you present this article is excellent. |
| it would be great if you can provide with an working example |
| This article is really nice . It gives a good knowledge about the Unit testing |
| Its a good Site For The Basic understanding Abt The Testing and unit Testing with Sample Test Case. |

| I am very much impressed with this article with respect to the importance of Unit Testing which has been explained. I have been involved in this process very many a times. But, the importance which has been explained here will make sure no tester will regret later on in further levels of testing. |
| This is very simple and easy to understand the Unit Test Plan and Test Cases. Thanks... |
| GOOD.ITS NICE TO UNDERSTAND |
|
with best my regards........ Dear sir / madam I am very much impressed with this article with respect to the importance of Unit Testing ....... |
| very much usefull....thanks a lot... |
| I referred to many sites.But the way i understood the topics here is very good and i thank who has provided these contents. |
| very much usefull................................hks,alot.......................... |
|
Dear Sir/Madam, I am very impressed with this materials its very good and i thank for everyone.....................thanks a lot........... |
| This article is easy to understand. |
| Hi in this for every concept good explanation is provided |
|
dear Sir/Madam thank for all these information , please continue to provide these information onse again thanks |

|
Article is very nice and usefull to everyone.language is very easy to undestand. nice explanation. thanks a lot |
|
Please provide more details in Simple language to understand the concepts in Depth. Thanks |
| Try to give more examples to Understand the con cepts in depth. |
| it is easy to understand and easily help for the person who come newly for testing. |
| very useful article... thanks a lot |
| Nice information and documents to understand the s/w testing in a proper way. They way you all gave the information its really very good. Thanks |
| done unit testing for java this article is gr8 help for any who wana know about unit testing.Tanks al lot!!! |
| A nice article.It provides more brief on Unit testing and How unit testing fits in Software Development life cyclie |
| this is very much useful for manual testers.pls contiue this |
| This article with respect to the importance of Unit Testing |
|
This article with respect to the importance of Unit Testing, but sample test cases have bug. Please review sample test case - Test Case ID ,Test Case Description, Input Data, Expected Result, Actual Result,Pass/Fail and Remarks- Its very wrong. The following test case template is correct Test Case ID ,Test Case Description,Test Steps, Input Data, Expected Result, Actual Result,Pass/Fail and Remarks. if its not correct means Please explain me : mailtodk@aol.com |
| When I read the article, I assumed the test steps should be included in the Test Description area of the Test Case Sample, but mailtodk is correct to point out that it would be best to explicitly include the test steps in a separate field. |
| This aritcle is very nice. It provides more brief on Unit testing and How unit testing fits in Software Development life cycle i have also seen he reviewer review comments but all comments are open if possible please update the valde comment and publish.it give us true value.can you provide more information about unit testing in vast. |
| After researching numerous websites I found yours to be the most informative and very easy to understand. Thanks. |
|
I really appreciate the way this article is written .It makes it very easy to understand the concept for a non-IT persons because the vocablury used is easier .THNKS .........keep writing |
| Are u referring the Test case with respect to the unit testing.......or is it for the black box testing |
|
Dear Author, As the above comments say, the article gives a clear picture of Unit testing. Thanks a lot for your effort. I'd like to get clarified on the following queries. Kindly clarify. 1) When does the test case document need to be prepared? Before coding? or after coding? 2) What's the input for preparing the Unit test case document? Is it the low level design document? 3) Is it really possible to find all the program modules(say, functions) in the design phase itself? 4) If the unit test case document should be prepared before coding, can the came be updated after coding is completed and just before starting the Unit testing? so that we can identify all the functions in the program clearly. Kindly clarify. Thanks in advance, Saravanan AR |
|
Dear Author, As the above comments say, the article gives a clear picture of Unit testing. Thanks a lot for your effort. I'd like to get clarified on the following queries. Kindly clarify. 1) When does the test case document need to be prepared? Before coding? or after coding? 2) What's the input for preparing the Unit test case document? Is it the low level design document? 3) Is it really possible to find all the program modules(say, functions) in the design phase itself? 4) If the unit test case document should be prepared before coding, can the came be updated after coding is completed and just before starting the Unit testing? so that we can identify all the functions in the program clearly. Kindly clarify. |
| This document is really a good one.. It gives all the basics in very brief manner .. but still clear and simple .. good work |
| This article realy helpful to me |
|
i'm not a programmer but i want to have an idea what a unit testing document looks like. Format and what should be included in the document. I'm a BA and wanted to help our developers create a unit testing document. appreciate your help |
| I am a black box tester. and trying to implement a genral test case for UNit testing and this articale is too good and help me alot in understandung the concept. Good work done |