Using DUnit
by Yong Yoon Kit
020606 yky Created
020607 yky Modified UML diagram, added some Questions
020610 yky Modified changed example to TCounter from TPDObject added UML diag.
Abstract
This document will briefly introduce one aspect of eXtreme Programming (XP)
which we will use in our development cycle, the DUnit. It will describe how to Use
Test Harnesses to test the code we have written and demonstrate its advantages
in refactoring, optimizations, peace of mind and the quality of our software.
Introduction
DUnit orgininates from an eXtreme Programming module which tests the
developers code and confirms that the code or module does what it should.
The concept is simple: write your test harness first and expect your code to fail
before implementation. After implementation, ALL tests should pass. If you can
think of different scenarios, write the test cases, testing for the correct results. And
remember, when a bug is found, the developer will only test that bug once
manually because he MUST write a test case to keep testing for that bug in the
future.
On unit tests, please refer to this page:
http://www.extremeprogramming.org/rules/unittests.html
SUnit, JUnit, CUnit, etc...
DUnit is a member of the *Unit family for all the different programming languages.
It is developed as an Open Source project in sourceforge (dunit.sourceforge.net)
and can be freely downloaded and used.
Refactoring
It is also important that when we review (clean up ugly code, make things more
readable) and optimize (make things faster) we do not break the software. If we
have written complete test harnesses, then ALL tests should pass as before. This
gives us a lot of opportunity to modify (for the better) existing code but ensuring
that the process does not affect the end result.
Refactoring is this process of going back into old code, improving it, and ensuring
that the results are the same if not better.
This is especially important for the case of OO Programming where changes in
the Base class may have dire consequences to the inherited classes. So if we