TestCase ======== Base test case class for Slicer testing. Test cases inherit from TestCase and implement setup, run, verify, and teardown methods. Tests call Slicer API directly - no wrapper classes are provided. Classes ------- .. py:class:: Assertion Result of a test assertion. .. py:class:: TestResult Result of running a single test case. **Methods:** .. py:method:: failed_assertions() Return only failed assertions. .. py:class:: TestCaseInfo Information about a registered test case. .. py:class:: TestCase :bases: ABC Base class for all test cases. Test cases implement: - setup(): Prepare test environment (load data, create nodes) - run(): Execute the test (paint, change parameters, etc.) - verify(): Check results with assertions - teardown(): Clean up (optional) Tests call Slicer functions directly. The TestContext provides only test-specific utilities (screenshots, timing, assertions) - not wrappers for Slicer API. Example: class TestAlgorithmWatershed(TestCase): name = "algorithm_watershed" description = "Test watershed algorithm on brain tissue" category = "algorithm" def setup(self, ctx: TestContext): import SampleData self.volume = SampleData.downloadSample("MRHead") def run(self, ctx: TestContext): ctx.screenshot("001_before", "Before painting") # Call Slicer/effect methods directly self._apply_paint() ctx.screenshot("002_after", "After painting") def verify(self, ctx: TestContext): voxel_count = self._count_voxels() ctx.assert_greater(voxel_count, 100, "Should segment tissue") **Methods:** .. py:method:: __init__() Initialize test case. .. py:method:: setup() Set up test environment. .. py:method:: run() Execute the test actions. .. py:method:: verify() Verify test results with assertions. .. py:method:: teardown() Clean up after test (optional). Functions --------- .. py:function:: failed_assertions() Return only failed assertions. .. py:function:: setup() Set up test environment. Called before run(). Load sample data, create segmentation nodes, configure the effect. Call Slicer API directly. Args: ctx: Test context for screenshots, timing, assertions. .. py:function:: run() Execute the test actions. Perform the main test operations: paint with the brush, change parameters, interact with UI. Call Slicer API directly. Args: ctx: Test context for screenshots, timing, assertions. .. py:function:: verify() Verify test results with assertions. Check that the test produced expected results. Use ctx.assert_* methods to record pass/fail conditions. Args: ctx: Test context for screenshots, timing, assertions. .. py:function:: teardown() Clean up after test (optional). Override to perform cleanup. Called after verify(), even if verify() raised an exception. Args: ctx: Test context for screenshots, timing, assertions.