Implementing PyTest-qt

PyTest-qt summary:

The main usage is to use the qtbot fixture, responsible for handling qApp creation as needed and provides methods to simulate user interaction, like key presses and mouse clicks:

@jcfr @lassoan @pieper Do you have any thoughts about python testing of Slicer modules and their usage of simulated user interaction?

How does QtTesting fit into current recommendations?

Recording of macro using QtTesting should be considered experimental.
We suggest to implement workflow automation through Python scripts operating at a lower level by changing properties of MRML nodes and calling module logic functions

One of the above links has the above header. Does this mean it is not recommended to do this GUI level type of testing that uses simulated clicks and interactions? Slicer core appears to utilize some QtTesting in qMRMLCheckableNodeComboBoxEventTranslatorPlayerTest1.xml. I assume this is because it is a qMRML QObject rather than say a Slicer module.

Are Self-tests the Slicer recommended way for scripted loadable module python testing? Is the clickAndDrag method the recommended manner for synthetic input into Slicer modules, or is something like PyTest-qt as mentioned in the original post a possibility for Slicer scripted module testing?

1 Like