]> git.ipfire.org Git - thirdparty/dhcp.git/blob - tests/HOWTO-unit-test
-n [master]
[thirdparty/dhcp.git] / tests / HOWTO-unit-test
1 Introduction
2 ------------
3
4 That is only a brief overview of tests in ISC DHCP. For more thorough
5 description, see ISC DHCP Developer's Guide. You can generate it, by
6 having Doxygen installed and doing:
7
8 cd doc
9 make devel
10
11 and then opening doc/html/index.html
12
13 Tests Overview
14 --------------
15
16 In DHCP, a unit test exercises a particular piece of code in
17 isolation. There is a separate unit test per module or API. Each unit
18 test lives in a directory beneath the code it is designed to exercise.
19 So, we (will eventually) have:
20
21 server/tests/
22 client/tests/
23 common/tests/
24 dhcpctl/tests/
25
26 And so on.
27
28 We are using ATF (Automated Test Framework) as a framework to run our
29 unittests. See ISC DHCP Developer's Guide for much more thorough
30 description of unit-test and ATF framework in general.
31
32 Running Unit Tests
33 ------------------
34
35 In order to run the unit tests for DHCP, enable ATF support during configure:
36
37 $ ./configure --with-atf
38
39 And then use:
40
41 $ make check
42
43 This will run all of the unit tests. Make sure that ATF is actually
44 installed and that you have atf-run and atf-report tool in your PATH.
45
46 You can run a single test by going to the appropriate test directory
47 and invoking the test directly:
48
49 $ cd server/tests
50 $ atf-run | atf-report
51
52 There are also a number of options that you can use when running a
53 test. See atf-run and atf-report documentation.
54
55 Adding a New Unit Test
56 ----------------------
57
58 See ISC DHCP Developer's Guide.
59
60 Adding a New Unit Test Program
61 ------------------------------
62
63 See ISC DHCP Developer's Guide.