I’m in the process of creating a Python Unit Test Runner Extension.
This module provides (IMO) an efficient way to develop new Python based extensions and allows to do test driven development by having :
- A test runner module accessible directly from 3D Slicer to run tests in an independant 3D Slicer instance
- A decorator which allows to run tests directly in your favorite IDE
Here are a few screenshots of the extension in use :
test runner :
test decorator :
The module uses the following librairies for test run / discovery / reporting :
I plan to release the extension on the extension manager soon and I wanted to have the community’s feeback (especially @jcfr & @lassoan ).
Thanks in advance,
@Thibault_Pelletier Is this module something you created because you found that the “Self Tests” (Self Tests — 3D Slicer documentation) module did not provide all the functionality that you were hoping? Could the improvements you made here possibly be integrated for the existing Self Tests module?
Hi @jamesobutler, yes I developped this extension because the self test functionalities where too limited for my usage.
Basically when building bigger extensions or when wanting to split the implementation into packages, the self test becomes cumbersome to use and requires frequent restarts of the 3D Slicer UI to really test the content of the extension.
The extension can be integrated directly into the self test module or into 3D Slicer core directly (I don’t have any preferences). As it’s pulling PyTest and PyTest JSON Report, I wasn’t sure what was the best option and wanted to consult with the community.
I have just pushed the current version here :
I have only tested it on Windows, so I’ll have to have a look on Linux to check if it works as expected.
Edit: I did some justifications as to the why of the lib here : GitHub - KitwareMedical/SlicerPythonTestRunner: Python test runner extension for 3D Slicer based on PyTest and PyTest JSON Report
For information, I had a few bugs in the extension (in particular on Linux).
It should be usable now !