What is Automated Unit Testing?

Automated unit testing is the process of testing software using test scripts.

A unit test is a piece of code that executes another piece of code and compare the actual result with expected result.

In one of the previous chapters, you saw how to write a small class to calculate the Factorial of a number. Now let us try to write a small test script to test the Factorial() method. A simple test script will look like this:

The above method calls the Factorial method and compares the result. If the result is same as the expected result, then you know that the test is success. This indicates your Factorial method is working as expected.

In the above case, the test script calls the Factorial method with one input (5). In real development environment, you have to write several test scripts to test each method, with various input values and make sure the result is correct.

The above test script is not perfect. It displays a messagebox when the test fails. This requires someone has to manually look for the messageboxes.

Automated Unit Test Frameworks like NUnit solves this problem.

Tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.