Difference between revisions of "Documentation/Nightly/Developers/FAQ/Testing"

From Slicer Wiki
Jump to: navigation, search
(Created page with "<noinclude>{{documentation/versioncheck}}</noinclude> <noinclude>__TOC__ ={{#titleparts: {{PAGENAME}} | | -1 }}=</noinclude><includeonly> ='''Developer FAQ: {{{1}}}'''= </incl...")
 
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
  
 
* <code>simple_test(testname)</code>:
 
* <code>simple_test(testname)</code>:
 +
** Usually called after configuring a test driver using <code>SlicerMacroConfigureModuleCxxTestDriver</code>.
 
** Accept the same arguments as <code>add_test</code>.
 
** Accept the same arguments as <code>add_test</code>.
 
** Conveniently call [https://cmake.org/cmake/help/latest/module/ExternalData.html#command:externaldata_add_test ExternalData_add_test] with the appropriate parameters.
 
** Conveniently call [https://cmake.org/cmake/help/latest/module/ExternalData.html#command:externaldata_add_test ExternalData_add_test] with the appropriate parameters.
Line 19: Line 20:
 
** Ideally, this macro should be renamed to <code>slicer_add_test</code>
 
** Ideally, this macro should be renamed to <code>slicer_add_test</code>
 
-->
 
-->
 +
 +
* <code>slicer_add_python_unittest(SCRIPT script [TESTNAME_PREFIX prefix] [SLICER_ARGS slicer_arg1 [slicer_arg2 [...]]])</code>:
 +
** Run unittests with Slicer using <code>--python-code "import slicer.testing\\; slicer.testing.runUnitTest(['${CMAKE_CURRENT_BINARY_DIR}', '${_script_source_dir}'], '${test_name}')"</code>.
 +
** Slicer arguments systematically passed are <code>--testing</code> and <code>--no-splash</code>.
 +
** Conveniently call [https://cmake.org/cmake/help/latest/module/ExternalData.html#command:externaldata_add_test ExternalData_add_test] with the appropriate parameters.
  
 
* <code>slicer_add_python_test(SCRIPT script [TESTNAME_PREFIX prefix] [SLICER_ARGS slicer_arg1 [slicer_arg2 [...]]] [SCRIPT_ARGS script_arg1 [script_arg2 [..]]])</code>:
 
* <code>slicer_add_python_test(SCRIPT script [TESTNAME_PREFIX prefix] [SLICER_ARGS slicer_arg1 [slicer_arg2 [...]]] [SCRIPT_ARGS script_arg1 [script_arg2 [..]]])</code>:
 +
** Useful to run a python test that can not be added as a unittest.
 
** Run Slicer with the given <code>script</code>.
 
** Run Slicer with the given <code>script</code>.
 
** Slicer arguments systematically passed are <code>--testing</code> and <code>--no-splash</code>.
 
** Slicer arguments systematically passed are <code>--testing</code> and <code>--no-splash</code>.
 
** Conveniently call [https://cmake.org/cmake/help/latest/module/ExternalData.html#command:externaldata_add_test ExternalData_add_test] with the appropriate parameters.
 
** Conveniently call [https://cmake.org/cmake/help/latest/module/ExternalData.html#command:externaldata_add_test ExternalData_add_test] with the appropriate parameters.
  
* <code>slicer_add_python_unittest(SCRIPT script [TESTNAME_PREFIX prefix] [SLICER_ARGS slicer_arg1 [slicer_arg2 [...]]])</code>:
+
== What is the meaning of prefix py_ in test name ? ==
** Run unittests with Slicer using <code>--python-code "import slicer.testing\\; slicer.testing.runUnitTest(['${CMAKE_CURRENT_BINARY_DIR}', '${_script_source_dir}'], '${test_name}')"</code>.
+
 
** Slicer arguments systematically passed are <code>--testing</code> and <code>--no-splash</code>.
+
It means that the test is implemented in python.
** Conveniently call [https://cmake.org/cmake/help/latest/module/ExternalData.html#command:externaldata_add_test ExternalData_add_test] with the appropriate parameters.
 

Latest revision as of 14:47, 11 July 2016

Home < Documentation < Nightly < Developers < FAQ < Testing


For the latest Slicer documentation, visit the read-the-docs.


Testing

What is the difference between add_test, simple_test, slicer_add_python_test, and slicer_add_python_unittest CMake macros/functions ?

  • add_test: provided by CMake and allows to add a test that can be executed using ctest.
  • simple_test(testname):
    • Usually called after configuring a test driver using SlicerMacroConfigureModuleCxxTestDriver.
    • Accept the same arguments as add_test.
    • Conveniently call ExternalData_add_test with the appropriate parameters.
    • Set the LABELS test property.
    • Invoke test driver using ${Slicer_LAUNCH_COMMAND}
  • slicer_add_python_unittest(SCRIPT script [TESTNAME_PREFIX prefix] [SLICER_ARGS slicer_arg1 [slicer_arg2 [...]]]):
    • Run unittests with Slicer using --python-code "import slicer.testing\\; slicer.testing.runUnitTest(['${CMAKE_CURRENT_BINARY_DIR}', '${_script_source_dir}'], '${test_name}')".
    • Slicer arguments systematically passed are --testing and --no-splash.
    • Conveniently call ExternalData_add_test with the appropriate parameters.
  • slicer_add_python_test(SCRIPT script [TESTNAME_PREFIX prefix] [SLICER_ARGS slicer_arg1 [slicer_arg2 [...]]] [SCRIPT_ARGS script_arg1 [script_arg2 [..]]]):
    • Useful to run a python test that can not be added as a unittest.
    • Run Slicer with the given script.
    • Slicer arguments systematically passed are --testing and --no-splash.
    • Conveniently call ExternalData_add_test with the appropriate parameters.

What is the meaning of prefix py_ in test name ?

It means that the test is implemented in python.