Tutorials » NUnit tutorials »

Manual Unit Testing

This chapter explains the manual unit testing process.

Assume you are writing a class to calculate the Factorial of a number. You may write a class called 'Calculator' with a method called 'Factorial()' taking one input parameter and returning the Factorial of the input.

public class Calculator
public int Factorial(int a)
int factorial = 1;
while ( a > 0 )
factorial *= a;


return factorial;

After you write the above class and method, you are done with your job. But before you deliver your code to your team leader, you must test the code to make sure this code works fine as expected for different cases.

Most of the programmers test the code by writing a small test application. You may create a new windows forms project and add some labels, a textbox and buttons etc to the form. In the above case, you need one textbox to input the number to find the Factorial. Also, you need a 'Calculate' button. When user inputs a value to the textbox and press the button, you will call the method and pass the user input value to the method. Then you will display the result as a messagebox. By seeing the result you will manually verify it to make sure that the code worked as expected.

The above process is called 'Manual Unit Testing'.

Next Chapter: Disadvantages of Manual Unit Testing
Previous Chapter: What is unit testing?
More Chapters: NUnit Tutorials
More Tutorials: Tutorial Index

Top Contributors
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India