ActionRecorder

Action recorder for manual testing.

Records user actions during manual testing sessions for: 1. Reproducibility - understand what was tested 2. Test generation - convert actions to automated tests 3. Documentation - capture testing workflows

Uses Slicer observers to automatically capture: - Segmentation modifications (detected via node observers) - Effect parameter state at time of modification

Classes

class ActionRecorder

Records user actions during manual testing.

Automatically captures segmentation modifications via Slicer observers. Records effect parameters at time of each paint action for reproducibility.

Usage:

recorder = ActionRecorder(test_run_folder)

# Start recording with automatic capture recorder.start()

# Manual records (screenshots, notes) still work recorder.record_screenshot(“001_test”, “After painting”) recorder.record_note(“Watershed stopped at expected boundary”) recorder.record_pass(“Segmentation looks correct”)

# Stop recording recorder.stop()

Callback mode (for branch recording):
def my_callback(action_dict):

print(f”Action recorded: {action_dict[‘type’]}”)

recorder = ActionRecorder(test_run_folder, action_callback=my_callback) recorder.start() # … actions are recorded and callback is called …

Methods:

__init__()

Initialize action recorder.

is_recording()

True if currently recording.

action_count()

Number of actions recorded in current session.

has_callback()

True if an action callback is set.

set_action_callback()

Set or clear the action callback.

start()

Start recording actions.

stop()

Stop recording actions.

record_paint()

Record a paint action.

record_parameter_change()

Record a parameter change.

record_algorithm_change()

Record an algorithm change.

record_screenshot()

Record a screenshot capture.

record_note()

Record a user note.

record_pass()

Record a manual pass mark.

record_fail()

Record a manual fail mark.

Functions

is_recording()

True if currently recording.

action_count()

Number of actions recorded in current session.

has_callback()

True if an action callback is set.

set_action_callback()

Set or clear the action callback.

Args:

callback: Callback function that receives action dicts, or None to clear.

start()

Start recording actions.

Sets up observers on the current segmentation node to automatically capture paint events and parameter changes.

stop()

Stop recording actions.

Removes all observers and saves final state.

record_paint()

Record a paint action.

Args:

ijk: Voxel coordinates (i, j, k). algorithm: Algorithm name used for painting. mode: “add” or “erase”. radius_mm: Brush radius in mm. is_3d: Whether 3D brush mode is enabled.

record_parameter_change()

Record a parameter change.

Args:

parameter: Parameter name. value: New value.

record_algorithm_change()

Record an algorithm change.

Args:

algorithm: New algorithm name.

record_screenshot()

Record a screenshot capture.

Args:

screenshot_id: Screenshot identifier. description: Screenshot description.

record_note()

Record a user note.

Args:

note: User’s observation or note.

record_pass()

Record a manual pass mark.

Args:

reason: Reason for passing.

record_fail()

Record a manual fail mark.

Args:

reason: Reason for failing.