Stellarion
Tools

stellarion_find_related_tests

Find tests that exercise a given function

Discovers test files and test functions that exercise specific code. Traces call graph edges to find functions with test-like names (test_, _test, it(), describe()) that directly or transitively call the target.

When to Use

  • Before modifying code, to know which tests to run and update
  • Debugging a failure, to find test cases that cover the broken path
  • Assessing test coverage for a specific function
  • After refactoring, to verify that relevant tests still pass

Parameters

ParameterTypeRequiredDefaultDescription
uristringYes--File URI to find tests for (e.g., file:///path/to/file.ts)
linenumberNo0Line number of the function (0-indexed). Omit or set to 0 to find tests for the entire file.
limitnumberNo10Maximum number of related tests to return

Examples

Find Tests for a Specific Function

Natural Language: "What tests cover the createUser function?"

MCP Tool Call:

{
  "name": "stellarion_find_related_tests",
  "arguments": {
    "uri": "file:///home/dev/project/src/services/user.ts",
    "line": 45
  }
}

Returns: 4 tests: test_create_user_success, test_create_user_duplicate_email, test_create_user_invalid_input, and test_user_service_integration with their file locations and relationship types (direct caller, transitive).

Find All Tests for a File

Natural Language: "Which tests exercise anything in the payment module?"

MCP Tool Call:

{
  "name": "stellarion_find_related_tests",
  "arguments": {
    "uri": "file:///home/dev/project/src/billing/payment.py",
    "limit": 20
  }
}

Returns: All test functions that call any function in the payment module, across all test files.

Quick Coverage Check

Natural Language: "Does this function have any tests?"

MCP Tool Call:

{
  "name": "stellarion_find_related_tests",
  "arguments": {
    "uri": "file:///home/dev/project/src/utils/retry.rs",
    "line": 12,
    "limit": 1
  }
}

Returns: Either 1 test (confirming coverage exists) or an empty array (no tests found).

Output Format

  • tests -- Array of related test functions, each containing:
    • name -- Test function name
    • id -- Internal node ID (can be used with other tools like get_detailed_symbol)
    • relationship -- How the test relates to the target: direct (test calls the function directly) or transitive (test calls something that calls the function)
    • file -- File path where the test is located
    • line -- Line number of the test function
  • total -- Total count of related tests found (may exceed limit)

Tips

  • Use before making any code change. The tests returned are the ones you need to run after your edit.
  • A function with 0 related tests is a coverage gap. Consider writing tests before modifying it.
  • Transitive tests are less specific but still relevant. A transitive test calls your function through another function, so it exercises the code path but may not test edge cases.
  • Chain with stellarion_get_edit_context which already includes related tests alongside callers, memories, and git history.
  • For the inverse operation (finding what code a test covers), use stellarion_get_callees on the test function.