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:
public void TestFactorialMethod()
// Instantiate the calculator class.
Calculator calc = new Calculator();
// Call the Factorial method to calculate the factorial of 5.
int result = calc.Factorial(5);
// We know that the factorial of 5 is 120. The job of the test method is
// to compare the result from the factorial method with the expected value
// and make sure it is same as the expected value/
if ( result != 120 )
MessageBox.Show("Expected value is 120, but actual value is '" + result + "'.");
The above method calls the Factorial method and compares the result. If the result is same as the expected result, then … Click here to continue…..
Some of the issues of manual unit testing are: You will write test applications and throw away after doing your testing. After few weeks you may make some modifications to your code and at that time you may not find your old test application. So, you will have to write another test application. Large projects will have hundreds of classes and several class libraries. It is very difficult to write separate test applications for each of the classes in the project and save all of them for repeated testing in future. Test applications require a human person to test. You … Click here to continue…..
After writing any code, every programmer will do some kind of testing to make sure the code works as expected. This testing is called ‘unit testing’. Unit testing is done in different ways. Some programmers write simple test applications to test their own code. Some others simply debug the code and change the values during debugging to make sure the code works fine for different cases. Some facts about unit testing: Unit testing is done by developers. Quality department does different tests, they are not unit tests. Every programmer must do unit testing after finishing development or during development itself. … Click here to continue…..
Configuration management is a detailed recording and updating information for hardware and software components. When we say components it does not only mean source code. It can be tracking of changes for software documents like requirement, design, test cases etc. When changes are done in ADHOC and uncontrolled manner more chaotic situations arise and more defects are injected. So whenever changes are done it should be done in a controlled fashion and with proper versioning. At any moment of time we should be able to revert back to the old version. The main intension of Configuration management is that we can track our changes back if we … Click here to continue…..
Coverage is a measure used in software testing to describe to the degree to which the source code is tested. There are three basic types of the coverage techniques as shown in the below figure:- Statement coverage: – This coverage ensures that each line of source code has been executed and tested. Decision coverage: – This coverage ensures that every decision (true/ false) in the source code has been executed and tested. Path coverage: – In this coverage we ensure that every possible route through a given part of code is executed and tested. Coverage techniques