ScaleAdvice Consulting Inc.
Right people. Right solutions.
ScaleAdvice offers wide range of IT services, and tailored business solutions. Find out more about Scalable Services from ScaleAdvice.
Follow ScaleAdvice on twitter at http://twitter.com/scaleadvice
Email us at
sales@scaleadvice.com
Scalable Unit Test Suites
The primary goal of unit testing is to take the smallest piece of testable software in the application, isolate it from the remainder of the code, and determine whether it behaves exactly as you expect. Each unit is tested separately before integrating them into modules to test the interfaces between modules. Unit testing has proven its value in that a large percentage of defects are identified during its use.
The most common approach to unit testing requires drivers and stubs to be written. The driver simulates a calling unit and the stub simulates a called unit. The investment of developer time in this activity sometimes results in demoting unit testing to a lower level of priority and that is almost always a mistake. Even though the drivers and stubs cost time and money, unit testing provides some undeniable advantages. It allows for automation of the testing process, reduces difficulties of discovering errors contained in more complex pieces of the application, and test coverage is often enhanced because attention is given to each unit.
Benifits
Facilitates change
Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly (i.e. regression testing). The procedure is to write test cases for all functions and methods so that whenever a change causes a fault, it can be quickly identified and fixed.
Readily-available unit tests make it easy for the programmer to check whether a piece of code is still working properly.
In continuous unit testing environments, through the inherent practice of sustained maintenance, unit tests will continue to accurately reflect the intended use of the executable and code in the face of any change. Depending upon established development practices and unit test coverage, up-to-the-second accuracy can be maintained.
Simplifies integrationUnit testing may reduce uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration testingbecomes much easier.
A programmer who creates an elaborate hierarchy of unit tests might be intending to have achieved integration testing. This result would not be achieved since integration testing evaluates many other objectives that can only be proven through the human factor. Unit testing, which is testing from a perspective of understanding of the implementation of the software, can be combined with integration testing which is testing from the perspective of the system as a whole.
DocumentationUnit testing provides a sort of living documentation of the system. Developers looking to learn what functionality is provided by a unit and how to use it can look at the unit tests to gain a basic understanding of the unit API.
Unit test cases embody characteristics that are critical to the success of the unit. These characteristics can indicate appropriate/inappropriate use of a unit as well as negative behaviors that are to be trapped by the unit. A unit test case, in and of itself, documents these critical characteristics, although many software development environments do not rely solely upon code to document the product in development.
On the other hand, ordinary narrative documentation is more susceptible to drifting from the implementation of the program and will thus become outdated (e. g. design changes, feature creep, relaxed practices in keeping documents up-to-date).
DesignWhen software is developed using a test-driven approach, the unit test may take the place of formal design. Each unit test can be seen as a design element specifying classes, methods, and observable behaviour.