[bind10-dev] C++ unit test tool?
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Wed Oct 21 00:35:42 UTC 2009
At Tue, 20 Oct 2009 01:33:32 -0700,
JINMEI Tatuya <jinmei at isc.org> wrote:
> I've played with CxxTest and googletest, and committed the same set of
> test code for these three frameworks to a svn branch:
> http://bind10.isc.org/browser/branches/jinmei-cppunittests/src/lib/dns
Also tried Boost.Test:
http://bind10.isc.org/browser/branches/jinmei-cppunittests/src/lib/dns/name_boosttest.cc
Observations:
- It crashed after the test process with a message of
"malloc... pointer being freed was not allocated" on my laptop
environment (MacOS 10.6, boost 1.40 installed via macports). It
seems the bug is triggered if I add more than one test case in a
fixture environment, and it happened even with empty tests. So I
suspect it's a boost bug. It may also specific to the macports
environment (it only installs a "-mt" version of library): it didn't
happen with boost 1.37 on FreeBSD 7.0. But at least to me this is a
very negative result.
- Test cases can be as simple as gtest and cxxtest.
- ...but there was one counter-intuitive syntax issue: using
declarations do not seem to work in a TEST_CASE macro. This is not
a big deal once we learn it, but may raise a bar for new
contributors.
- I first thought using Boost.Test makes sense if we also use boost
for other purposes such as shared pointers, but I then found
Boost.Test basically requires to install library object files (on
the other hand we only need boost header files for many other boost
features). It seems we could still use the test framework only with
header files, but it is discouraged in the boost tutorial page
because it will increase build time. This may still be better than
having another dependency to a different tool, but I'm now not so
sure about it (and not all users need test tools, so we can make
dependency for tests optional, anyway).
Maybe I'm biased due to the (possibly rare) crash problem, but
considering these points, Boost.Test would not be my first choice.
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list