Difference between revisions of "Documentation/Nightly/Developers/QtTesting"
From Slicer Wiki
BenjaminLong (talk | contribs) |
BenjaminLong (talk | contribs) |
||
| Line 57: | Line 57: | ||
==Open bugs== | ==Open bugs== | ||
| + | |||
| + | [http://na-mic.org/Mantis/search.php?project_id=3&category=QtTesting&sticky_issues=off&sortby=last_updated&dir=DESC&hide_status_id=-2 Slicer issues] | ||
| + | |||
| + | [https://github.com/commontk/CTK/issues?labels=Testing&milestone=&page=1&state=open QtTesting issues] | ||
Revision as of 17:20, 24 May 2012
Home < Documentation < Nightly < Developers < QtTestingContents
Overview
Write a 3DSlicer 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
This Python test will start 3DSlicer and run your xml script previously recorded
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 to the directory ${Slicer_SOURCE_DIR}/Applications/SlicerApp/Testing/Python/
3/ Add the test in CMake
Edit the file Slicer4/Applications/SlicerApp/Testing/Python/CMakeLists.txt
Add your test at the end of the Slicer_USE_QTTESTING condition:
if(Slicer_USE_QTTESTING)
{
...
slicer_add_python_test(
SCRIPT pythonScriptName.py
SLICER_ARGS --launcher-no-splash --qt-testing)
}
Create custom translator/player
QTTesting provides us basic translator and player template.
You can use the following command to create those basic files.
cd Slicer_BINARY/CTK-build/QtTesting/Utilities/Scripts ./TranslatorPlayerWizard.py yourClassName cd ../yourClassName/
4 files should have been created !
| Those files are only the basic code. You now have to implement the function, according to your widget, to record the events |