Enhancing Software Quality in 3D Slicer: Introducing the SlicerPythonTestRunner Extension

In the realm of medical software development, ensuring high-quality code is paramount. The stakes are high: software misbehavior can lead to costly errors or, in critical cases, endanger lives. Enter the SlicerPythonTestRunner extension – a powerful tool designed to enhance software quality within the 3D Slicer ecosystem.

Why Software Quality Matters in Medical Applications

As systems become more and more automated, high Software quality is becoming a recurrent problem in all industries. For medical applications, high software quality is particularly important. Applications can be used at different levels, either by clinicians and doctors during preliminary analysis, or for guided surgical operations.

In this context, software errors can have a dramatic impact, from misdiagnoses to potential patient deaths. Medical applications need to be subjected to rigorous testing to minimize these risks.

To guarantee high software quality, regulatory bodies require robust software quality assurance. Medical applications need to comply with standards such as the Medical Device Regulation (MDR) and In vitro Diagnostic Regulation (IVDR) for market approval.

Finally, software quality is essential to user confidence, clinicians, researchers, and patients alike. Trust in the software’s accuracy and reliability is essential for software adoption.

Automated Testing for High Software Quality

Automated tests are essential to achieve high software quality. They guarantee that developed features will work as intended and that introducing new features to an application will not add unwanted regression to existing features.

Aside from improving software quality, automated tests provide quick feedback for developers. Continuous integration and deployment pipelines rely on running these tests to provide information on software quality when adding features to the application. Test execution is done on every platform the application is meant to run and provide an early warning if the execution fails. 3D Slicer provides these continuous integration reports on a nightly basis using CDash for every extension recorded in its extension manager.

To further improve development speed, developers need to have quick feedback on the automated tests execution. To help developers, we have created the SlicerPythonTestRunner extension.

Introducing SlicerPythonTestRunner

3D Slicer is a feature-complete application built in C++ and provides Python extensibility.

Developing 3D Slicer modules revolves around adding a new user interface panel to 3D Slicer’s module panel, and developing the modules logic for the processing steps of the extension.

The module’s logic interacts with 3D Slicer’s scene which contains all the data which have been loaded by the user and with the other extensions and libraries of the application.

To develop a 3D Slicer extension, it is necessary to have access to the different 3D Slicer components, load the relevant data, and trigger the logic using the user interface.

The SlicerPythonTestRunner extension adds multiple functionalities to simplify and improve the development speed for new 3D Slicer modules. The extension is built upon PyTest and PyTest JSON Report for test discovery, execution and reporting. Automated tests can be written using standard Python tools and the user interface allows to quickly filter the tests to be executed and see the tests’ failures.

Once the tests are discovered, the extension launches them in a new 3D Slicer window. The tests will then have access to the full 3D Slicer environment without being impacted by the current application state.

Running the tests in a new 3D Slicer window also allows you to reload all the modules and libraries, allowing to make modifications to the module under test and quickly verify the modifications in the test environment.


The SlicerPythonTestRunner extension empowers developers to build better medical applications within the 3D Slicer ecosystem. By emphasizing software quality through automated testing, we contribute to safer, more reliable healthcare software.

Explore the extension on the 3D Slicer Extensions Catalog and learn more about how to use it on the official repository.

Shall you want to leverage the power of 3D Slicer for your medical imaging software needs, please reach out.

Leave a Reply