Difference between revisions of "Documentation/Nightly/Developers/QtTesting"
From Slicer Wiki
BenjaminLong (talk | contribs) |
BenjaminLong (talk | contribs) |
||
| Line 2: | Line 2: | ||
==Write a UnitTest with QtTesting== | ==Write a UnitTest with QtTesting== | ||
| + | |||
| + | === 1/ Create your XML script === | ||
| + | See [http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/SlicerApplication/QtTesting QtTesting User] | ||
| + | {{ambox | ||
| + | | type = content | ||
| + | |text = If your tutorial needs data, please first add the data to the Sample Data module, and use this module during the test. See instruction [[xxxx here]] | ||
| + | }} | ||
| + | === 2/ Create a Python script === | ||
| + | * Create a file with the following code : | ||
| + | |||
| + | import slicer | ||
| + | import slicer.testing | ||
| + | import slicer.util | ||
| + | filepath = os.environ['SLICER_HOME'] + 'path/to/your/script.xml' | ||
| + | testUtility = slicer.app.testingUtility() | ||
| + | success = testUtility.playTests(filepath) | ||
| + | if success : | ||
| + | slicer.util.exit(EXIT_SUCCESS) | ||
| + | else: | ||
| + | slicer.util.exit(EXIT_FAILURE) | ||
| + | |||
| + | * Save the python test to the directory ''Slicer-source-dir/Applications/SlicerApp/Testing/Python/'' | ||
| + | |||
| + | === 3/ Edit CMakeList === | ||
| + | |||
| + | slicer_add_python_test( | ||
| + | SCRIPT pythonScriptName.py | ||
| + | SLICER_ARGS --launcher-no-splash --qt-testing) | ||
==Create custom translator/player== | ==Create custom translator/player== | ||
==Open bugs== | ==Open bugs== | ||
Revision as of 14:20, 24 May 2012
Home < Documentation < Nightly < Developers < QtTestingContents
Overview
Write a UnitTest with QtTesting
1/ Create your XML script
See QtTesting User
| If your tutorial needs data, please first add the data to the Sample Data module, and use this module during the test. See instruction xxxx here |
2/ Create a Python script
- Create a file with the following code :
import slicer
import slicer.testing
import slicer.util
filepath = os.environ['SLICER_HOME'] + 'path/to/your/script.xml'
testUtility = slicer.app.testingUtility()
success = testUtility.playTests(filepath)
if success :
slicer.util.exit(EXIT_SUCCESS)
else:
slicer.util.exit(EXIT_FAILURE)
- Save the python test to the directory Slicer-source-dir/Applications/SlicerApp/Testing/Python/
3/ Edit CMakeList
slicer_add_python_test(
SCRIPT pythonScriptName.py
SLICER_ARGS --launcher-no-splash --qt-testing)