Project

General

Profile

Unit tests » History » Revision 2

Revision 1 (Rogers, Chris, 12 April 2011 12:16) → Revision 2/18 (Rogers, Chris, 12 April 2011 12:16)

h1. Unit Tests 

 The idea behind unit tests is "does this function do what I think it's doing". We want to check that, when we write a function, we haven't put any subtle (or not so subtle) errors in the code. Also we want to check that when we change some other function, it doesn't break existing code. So for each function (or maybe pair of functions) we write a test function. These are known as "unit tests". 

 h2. C++ unit tests 

 In C++ we use the google testing framework which has some convenience functions for e.g. equality testing in the presence of floating point errors, setting up common test data, etc. The google test framework should have been installed during the third party libraries. The C++ tests are found at <pre>${MAUS_ROOT_DIR}/tests/cpp_unit</pre> <pre>${MAUS_ROOT_DIR}/tests/cpp_unit</pre>. Sconstruct builds a unit test application in build/test_cpp_unit. 

 Go ahead and edit the tests if you need to. We should have one source file for each header file in the main body of the code. Each directory in MICESRC should be a directory in MICETESTS. If you want to add a new cc file, just add the code to the cvs repository and add an extra #include directive in $MICETESTS/gUnit/mgr/G4MICEUnitTest.cc 

 "Google tests documentation":http://code.google.com/p/googletest/w/list 

 h2. Python Unit Tests 

 h2. A Bit More on Unit Test Concept