TWiki has a range of unit tests that are designed to isolate and test specific blocks of TWiki code.
The tests are kept in the test/unit directory. They are not shipped with a normal release.
TestCasesTutorial describes how two write, and how to run, unit testcases.