NovaProva, a new generation unit test framework for C programs
This talk will introduce NovaProva, a new generation unit test framework for C programs.
I wrote NovaProva because I was sick of writing unit tests using the venerable but clunky CUnit library. CUnit looked easy when I started writing unit tests but I soon discovered it's limitations and ended up screaming in frustration. Meanwhile over 18 months the Cyrus IMAP server project has gone from 0 unit tests to 461, of which 277 are written in C with CUnit. So that's a big itch!
NovaProva starts with the same basic xUnit paradigm for testing, but extends some concepts in new directions (for example, NovaProva organises tests into trees rather than xUnit's two-level "suite and test" approach). Most importantly, NovaProva is designed using real world experience and modern technologies to make it much easier to write tests, and much easier to discover subtle bugs in the System Under Test, bugs that unit other test frameworks miss. Ideally NovaProva should make testing C code as easy as possible.
To make writing tests easy, I had to do some things in NovaProva which were so hard they seemed impossible. As a result NovaProva now does six things which I believe make it unique amongst C/C++ unit test frameworks:
- NovaProva is a library which Valgrinds the program which calls it
- NovaProva implements true reflection in C/C++ (not using magic macros)
- NovaProva discovers test functions automatically, no configuration needed, just by test function name
- NovaProva lets the test writer do fully dynamic function interception (mocking, in xUnit speak) at runtime and on a per-test basis (i.e. not using linker tricks)
- NovaProva provides good reporting and isolation for the many ugly ways C code can fail: memory overruns, uninitialised variables, memory leaks, deadlocks and loops, SEGV, calling exit(), calling syslog().
- NovaProva's project name is neither silly nor dangerous
The talk will cover some of the features of NovaProva, how to use NovaProva in your projects, and describe in technical detail how the impossible was accomplished. The audience is anyone who works on C programs for a living, whether willingly or not.
Greg has been working as a UNIX & Linux software developer in Melbourne for nearly twenty years, including several years as a Linux kernel developer working on NFS for Silicon Graphics. He now works for Opera Software Australia (previously Fastmail) where his duties comprise dragging the Cyrus IMAP server into the 21st century.