Use TestLifecycleManager for event-driven test maintenance

Start with TestLifecycleManager when files change in your project—it automatically queues appropriate test actions based on what happened to each file.

Why this matters

Setting up event handlers once is faster than manually tracking which tests need updates every time you modify source code.

How to use it

Initialize the manager with your project root and call the appropriate handler:

manager = TestLifecycleManager(project_root="/path/to/project")

# When a file is created, modified, or deleted
task = manager.on_file_created("src/new_module.py")
task = manager.on_file_modified("src/existing_module.py")
task = manager.on_file_deleted("src/old_module.py")

# Process queued tasks
result = manager.process_queue(max_tasks=5)

The tradeoff

The manager queues tasks instead of running them immediately—you get control over when test maintenance happens, but you must remember to process the queue.