Troubleshoot fix-test

Before you start

The fix-test feature provides automated test execution, coverage tracking, and lifecycle management. When tests fail unexpectedly or the system doesn't respond correctly to file changes, use this guide to diagnose and fix the issues.

Symptom table

If you observe Check
Tests not running automatically Verify TestLifecycleManager initialization and file event handlers in your project
Coverage tracking fails Check that coverage.xml exists and is valid XML format at the expected path
Stale test warnings persist Run get_stale_tests() to see if the detection logic matches your actual test files
Queue processing hangs Check get_pending_count() and verify no tasks are stuck with invalid status values
File change events ignored Confirm the ProjectIndex is properly initialized and file paths are relative to project root

Step-by-step diagnosis

  1. Reproduce with minimal setup. Create a simple test case that isolates the failing behavior. For test execution issues, try calling run_tests_with_tracking() directly with just the required parameters.

  2. Check the task queue status. Run TestLifecycleManager.get_status() to see pending tasks and queue health. Look for tasks stuck in 'pending' status or unexpected error states in the results.

  3. Verify file path resolution. Many issues stem from incorrect file paths. Ensure all paths are relative to the project root and that the ProjectIndex can find your test files.

  4. Test the core functions individually:

    • run_tests_with_tracking() — Verify test command execution and result capture
    • track_coverage() — Confirm coverage.xml parsing (check file exists and has valid XML)
    • get_file_test_status() — Test file-to-test mapping logic
    • TestLifecycleManager.on_file_modified() — Verify event handling creates appropriate tasks
  5. Enable debug logging. Set logging level to DEBUG for the attune.workflows modules before running operations. The logs will show task creation, queue processing, and file event handling details.

Common fixes

Source files

Tags: tests, debugging, fixes