added tech note about writing unit tests
[wxWidgets.git] / docs / tech / tn0017.txt
1                     How to write unit tests for wxWindows
2                     =====================================
3
4  Unit tests for wxWindows are written using small cppunit framework. To compile
5 (but not to run) them you need to have it installed. Hence the first part of
6 this note exlpains how to do it while the second one explains how to write the
7 test.
8
9 I. CppUnit Installation
10 -----------------------
11
12 1. Get it from http://www.sourceforge.net/projects/cppunit
13    (latest version as of the time of this writing is 1.8.0)
14
15 2. Build the library:
16  a) Under Windows using VC++ (both versions 6 and 7 work):
17     - build everything in CppUnitLibraries.dsw work space
18     - add include and lib subdirectories of the directory
19       where you installed cppunit to the compiler search path
20       using "Tools|Options" menu in VC IDEA
21
22  b) Under Unix: run configure && make && make install as usual
23
24
25 II. Writing tests with CppUnit
26 ------------------------------
27
28 1. Create a new directory tests/foo
29
30 2. Write the main.cpp file for the test program copying, if you want,
31    from one of the existing tests. The things to look for:
32  a) #include "wx/cppunit.h" instead of directly including CppUnit headers
33  b) don't put too many things in one test case nor in one method of a test
34     case as it makes understanding what exactly failed harder later
35
36    Read CppUnit documentation for more.
37
38 3. Write a bakefile for the new test (again, copy an existing one...)
39
40 === EOF ===
41
42 Author:  VZ
43 Version: $Id$