ug4
|
For the unit testing of ug4 the Boost Testing Library is used. The test are run by the Continuous Integration Service "Jenkins" (currently on cave1.gcsc.uni-frankfurt.de
) daily. If a test fails reporting email will be sent to the causing developers.
Unit Tests can be carried out in two ways:
For any questions, contact marti or n.sc herer @gcs c.uni -fra nkfur t.deandre. as.v ogel@ gcsc .uni- fran kfurt .de
In order to test the C++-Code directly one can write a piece of code, that is tested automatically. All unit test code should be placed in unit_tests/src/*.cpp
.
If you want to test your own code, add a *.cpp
file in that section and add your file in the CMakeList.txt
file.
Then start your own test suite as shown by this self-explanatory example:
In Detail:
A test suite is used to group several test together and all test suits will be detected and tested. BOOST_AUTO_TEST_SUITE
starts a new test suite, that is ended by BOOST_AUTO_TEST_SUITE_END
. The name of suite must be a valid C++-Name.
*NumProcsXX
, where XX
is the number of processes the suite should be run with (i.e. MPI-Processes).BOOST_AUTO_TEST_CASE
defines a test. There can be as many test cases in a suite as you like. Using the macros BOOST_REQUIRE_MESSAGE
, BOOST_CHECK_MESSAGE
you can now assert several conditions in your code.
In order to test Lua-Scripts you just have to add the script, that you want to test in the file unit_tests/data/script_tests/{script_test_param.xml, experimental_plugin.xml}
. The file name depends on whether you are testing a script which depends on a core or an experimental plugin.
See this example:
If you want to add your plugin to the Jenkins automated test procedure, add a line -DMyPlugin=ON to the cmake build step section of the Job "ug-build-plugins" and add a <script> ... </script>
section to the experimental_plugin.xml file. It is recommended to ensure your script file is able to be executed outside of UG4_ROOT (e.g grids should be not be loaded via absolute path or relative one relying to an unknown runtime location)
Now, two things are tested for each script configuration:
UGError/LuaError/...
reported) exception In your script use the functions test.require(cond, "message")
and test.check(cond,"message")
to ensure conditions during the run of the script. Please note, that this functions are available when ug_util.lua
is included in your script and that — if no Boost is available — the test functions are replaced by dummy methods (see scripts/util/test_utils.lua
). An example: