6 messages in com.perforce.jamming[jamming] Unit tests| From | Sent On | Attachments |
|---|---|---|
| Wallace, Richard | 07 Jan 2004 12:58 | |
| Paul Forgey | 07 Jan 2004 17:51 | |
| David Abrahams | 07 Jan 2004 19:06 | |
| Wallace, Richard | 08 Jan 2004 13:21 | |
| Alan Baljeu" <alanb@cornerstonemold.com (Alan Baljeu) | 08 Jan 2004 14:03 | |
| Wallace, Richard | 08 Jan 2004 14:25 |
| Subject: | [jamming] Unit tests![]() |
|---|---|
| From: | Wallace, Richard (Rich...@specastro.com) |
| Date: | 01/07/2004 12:58:30 PM |
| List: | com.perforce.jamming |
Hello all,
I'm happy to say that our build system is now running with jam and life is good.
Now I have to work in unit tests for our C++ classes. We haven't yet decided if
we're going to go with a unit testing framework like CppUnit or something
homegrown yet.
In the simplest case we'll just have a ClassTest.cpp for every Class.cpp which
contains a main and instantiates an instance and does a bunch of asserts. With
that in mind I came up with some rules that should make things easier.
# in Jamrules
NotFile test ; Depends test : first ;
# called as Test TestExecutable : TestSource.cpp : <list of libs> rule Test { local _testbin = $(1) ; local _testsrc = [ FGristSourceFiles $(2) ] ;
Main $(_testbin) : $(2) ; LinkLibraries $(_testbin) : $(3) ; LinkSystemLibraries $(_testbin) ;
RunTest $(_testbin) ; }
rule RunTest { local _bin = [ FAppendSuffix $(1) : $(SUFEXE) ] ; Depends test : $(_bin) ; TESTEXE on $(<) = $(SUBDIR)$(SLASH)$(_bin) ; }
actions RunTest { $(TESTEXE) }
This mostly works. Anychanges to Class.h or Class.cpp cause the ClassTest.cpp
to be recompiled and relinked. The only thing that is happening that I don't
really want is that the tests are being run EVERY time the test binary is
rebuilt. I would like it to only be run when the test target is run on jam (ie
'jam test').
Something else this is missing is a way to collect the number of tests being run
and the number of failures, where a failure is indicated by a non-zero return
value of one of the tests.
Anyone have any ideas how to accomplish these things? I'm also interested in
anyone elses opinions and approaches to doing unit tests and integrating them
with jam.
Thanks, Rich




