1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
7 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
13 <h2 id=
"unittestingframework">Unit Testing Framework
</h2>
17 I just figured this out, so, here
's how it works, and I
'll formalize this page later.
21 pcb uses the glib testing framework for unit tests: https:
<em>developer.gnome.org/glib/stable/glib-Testing.html
23 Look at main-test.c for examples.
25 In the actual code, you can wrap the unit test stuff in:
29 #endif /* PCB_UNIT_TEST */
32 so that it doesn
't bog things down when not testing. Does it really bog things down when not testing??
34 You need a
"<x
>_register_tests
" function, and then how ever many functions you
're going to use to execute your tests. Put prototypes in the header file. Include the header file in main-test.c, and add a call to the
"<x
>_register_tests
" function in main.
36 In the register function, make a call to g_test_add_func to add whatever testing functions you want to call. It uses a /x/y naming convention, where x is the test module, and y are the individual tests.
38 You have to add the source file to the list of files to be compiled for testing in Makefile.am. Look for the TEST_SRCS variable, and add your files there, in addition to adding them wherever else you need so that pcb compiles them.
40 Finally, you can rerun configure (to regen the makefiles), and execute
"make check
" from the build directory. This will build and execute the tests without necessarily building all of pcb. I
'm not sure if this runs the pcb level tests or not.