This is the test suite of Sofa. It contains base classes to ease the development of tests, such as sofa::Sofa_test , sofa::Mapping_test, etc. The actual tests are implemented in sub-directories of the modules and plugins. For instance, SofaRigid/SofaRigid_test/RigidMapping_test.cpp.
The tests are optional. They are activated using the SOFA-MISC_TESTS flag of the cmake configuration. This generates a set of executables, each of them running the test suite of the module. For instance, from the debug build directory, run:
To run all the tests, run command
Motivation and detail about activation is given in http://wiki.sofa-framework.org/wiki/UnitTesting
The tests are based on the googletest framework http://code.google.com/p/googletest/wiki/Documentation
Some tests require to open data files. These are typically located in the same directory as the test code. The path to the current directory can be defined in the CMakeLists.txt, and passed by the compiler as a predefined symbol. For instance, if you set the following line in CMakeLists.txt:
AddCompilerDefinitions("THIS_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"")
then the following instruction creates a complete, absolute path to fileName:
std::string fileName = std::string(THIS_DIR) + "/" + fileName;
See e.g. SofaTest_test/CMakeLists.txt and SofaTest_test/LoadScene_test.cpp
This is a the starting page of the plugin documentation, defined in file doc.h in the plugin directory.