Difference between revisions of "Documentation/Nightly/Developers/QtTesting"

From Slicer Wiki
Jump to: navigation, search
Line 27: Line 27:
 
'''''Save to the directory ''''' <code>${Slicer_SOURCE_DIR}/Applications/SlicerApp/Testing/Python/ </code>
 
'''''Save to the directory ''''' <code>${Slicer_SOURCE_DIR}/Applications/SlicerApp/Testing/Python/ </code>
  
=== 3/ Edit CMakeList ===
+
=== 3/ Edit CMakeLists ===
  
<code> gedit ${Slicer_SOURCE_DIR}/Applications/SlicerApp/Testing/Python/CMakeList.txt</code>
+
<code> gedit ${Slicer_SOURCE_DIR}/Applications/SlicerApp/Testing/Python/CMakeLists.txt</code><br>
 +
In the ''if'' Condition <code>if(Slicer_USE_QTTESTING)</code><br>
 +
Add :
 
     slicer_add_python_test(
 
     slicer_add_python_test(
 
       SCRIPT pythonScriptName.py
 
       SCRIPT pythonScriptName.py

Revision as of 14:35, 24 May 2012

Home < Documentation < Nightly < Developers < QtTesting

Overview

Write a 3DSlicer UnitTest with QtTesting

1/ Create your XML script

See QtTesting User

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/ Edit CMakeLists

gedit ${Slicer_SOURCE_DIR}/Applications/SlicerApp/Testing/Python/CMakeLists.txt
In the if Condition if(Slicer_USE_QTTESTING)
Add :

   slicer_add_python_test(
     SCRIPT pythonScriptName.py
     SLICER_ARGS --launcher-no-splash --qt-testing)

Create custom translator/player

Open bugs