View Issue Details

IDProjectCategoryView StatusLast Update
0003201Slicer4Core: Extensionspublic2014-03-07 10:22
Reporterjcfr Assigned Tojcfr  
PrioritynormalSeverityminorReproducibilityhave not tried
Status acknowledgedResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0003201: Improve support of selftest within slicer_add_python_unittest
Description

Discussion: http://slicer-devel.65872.n3.nabble.com/Writing-unit-tests-for-module-widgets-tp4029167p4029262.html

// ---------------------
Luis: Thanks, Steve. This works great when I'm testing using the default "Reload & Test" button on the module widget.

I'm now trying to test my extension using the "make Experimental" target from these instructions. However, my test now fails when trying to access my module's widget in the following code:

m = slicer.util.mainWindow()
m.moduleSelector().selectModule('<ModuleName>')
w = slicer.module.<ModuleName>Widget

The selectModule() call doesn't seem to have an effect. Looking closer at the console output during the test, the number of modules loaded into Slicer is 1 fewer than usual; this indicates to me that my module isn't actually being loaded into Slicer during this unit test. How can I get my module to be correctly loaded into Slicer during a unit test with 'make Experimental'?

// ---------------------
Luis: JC and I found a fix for this issue. The problem was that the extension module doesn't actually get loaded; to fix this, I edited the module's CMakeLists file (i.e. <ExtensionName>/<ModuleName>/CMakeLists.txt) and changed the slicer_add_python_unittest line to:

slicer_add_python_unittest(SCRIPT ${MODULE_NAME}.py SLICER_ARGS "--additional-module-path" "${CMAKE_CURRENT_LIST_DIR}")

This isn't a perfect fix, since it doesn't take into account other possible modules in the extension that might need to be loaded as well. This issue might be worth more consideration later, since writing tests which use the module's GUI is very useful.

TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2013-07-01 07:34 jcfr New Issue
2013-07-01 07:34 jcfr Status new => assigned
2013-07-01 07:34 jcfr Assigned To => jcfr
2013-07-01 07:34 jcfr Assigned To jcfr =>
2014-03-06 08:48 nicole Status assigned => new
2014-03-06 09:19 jcfr Status new => assigned
2014-03-06 09:19 jcfr Assigned To => jcfr
2014-03-07 10:22 jcfr Status assigned => acknowledged
2014-03-07 10:22 jcfr Description Updated