Wrox Home  
Adam Kolawa - Co-Founder and CEO of Parasoft
Adam Kolawa is the co-founder and CEO of Parasoft. Kolawa, co-author of Bullet-
proofing Web Applications
(Wiley, 2001), has contributed to and written hundreds of commentary pieces and technical articles for publications, such as The Wall Street Journal, CIO, Computerworld, Dr. Dobb's Journal, and IEEE Computer. He has also authored numerous scientific papers on physics and parallel processing.

Articles by Adam Kolawa

White Box Unit Testing

By Adam Kolawa, Co-Founder of Parasoft

The practice of unit testing, when applied as a regular element of the software development process, has been proven to significantly improve application quality, reliability, and performance and to enhance the overall productivity and predictability of a software development effort. Testing each individual application class and/or method during development (that is, performing unit testing) ensures that these individual application building blocks are structurally sound and robust, and function properly before they are integrated into an application, thus improving the quality of the entire application.

Despite its well-perceived value, unit testing is not practiced by the majority of software development organizations. Even where it is practiced, it is typically applied inconsistently or incorrectly. The lack of general knowledge about how to write and apply unit test cases; compressed and over-committed development schedules; the absence of good automated and integrated unit testing tools; and the absence of appropriate guidance in how to apply them are all contributors to the slow adoption of the practice. Software development organizations trying to implement a unit testing practice without availing themselves of automated tools or the expertise in implementation and deployment most often fail.

Having individual test cases for each unit of a code base allows for quick identification, isolation, and resolution of errors. Unit testing allows problems to be identified and resolved as soon as they are introduced. The traditional practice of relying on QA to find and report errors at the end of the development cycle results in many unproductive man hours of development time spent sifting through large, complex code bases trying to find the source of those errors - all before a fix for the error can even be contemplated. Finding and fixing a unit-level error immediately after coding has proven to be 10 to 100 times less costly than finding and fixing the same error later in the development process. A practice of unit testing is key to achieving automated software error prevention.

The first step in the implementation of unit testing should be white box unit testing. With the support of automated tools and proper implementation, white box testing can quickly generate a baseline of test cases that frame an application and create an initial test environment for validating core code behavior and identifying software errors. The auto-generated test cases become the foundation for a regression testing practice and regular, repeatable verification of the code base. White box unit testing checks the structure of each class and method (that is, unit) and validates that code properly executes and satisfies expected outcomes as well as handles unexpected runtime conditions (such as out-of-boundary conditions, undefined data types, null pointers, and memory allocation/de-allocation) without crashing or corrupting the application.

To achieve effective white box unit testing, you must not only have a defined practice for its use, but that practice must be implemented and integrated into your software development lifecycle so that it is used consistently and regularly across your software development team. Monitoring the practice and its results is necessary to control your software project, ensure its success, and improve the effectiveness of your team.