/** * Test Analyzer - Enhanced test detection and symbol matching * * Analyzes test files to determine which production symbols they test by: * - Parsing @testable import statements * - Analyzing test method names (e.g., testAccountsManager_LoadCatalogs_Success) * - Detecting test class naming patterns (e.g., AccountsManagerTests) * - Finding SUT (System Under Test) in setUp methods * - Analyzing XCTAssert calls for tested types * - Supporting Quick/Nimble spec files * - [v2.0] Tier 2 semantic analysis of test method bodies */ import { type TestBodyAnalysis } from './test-body-parser.js'; export interface TestFileAnalysis { file: string; testableImports: string[]; testClasses: TestClassInfo[]; testedSymbols: TestedSymbol[]; isQuickSpec: boolean; bodyAnalysis?: TestBodyAnalysis[]; instantiatedTypes?: string[]; calledMethods?: Array<{ receiver: string; method: string; }>; } export interface TestClassInfo { name: string; line: number; testMethods: TestMethodInfo[]; sutType?: string; sutVariableName?: string; } export interface TestMethodInfo { name: string; line: number; testedType?: string; testedMethod?: string; testedSymbols: string[]; bodyAnalysis?: TestBodyAnalysis; } export interface TestedSymbol { symbol: string; confidence: 'high' | 'medium' | 'low'; reason: string; testMethods: string[]; } /** * Patterns for files that should be excluded from production symbol count */ export declare const TEST_HELPER_PATTERNS: RegExp[]; /** * Extended test suffixes to remove when matching class names to production symbols */ export declare const TEST_SUFFIXES: string[]; /** * Check if a file is a test helper (mock, stub, fake, etc.) */ export declare function isTestHelperFile(filePath: string): boolean; /** * Extract @testable import statements from content */ export declare function extractTestableImports(content: string): string[]; /** * Extract regular imports to understand module dependencies */ export declare function extractImports(content: string): string[]; export interface ParsedTestMethod { /** The type/class being tested (e.g., "UserService") */ type?: string; /** The method being tested (e.g., "loadUser") */ method?: string; /** The test outcome/scenario (e.g., "Success", "WithError") */ outcome?: string; /** All extracted symbol names */ symbols: string[]; } /** * Parse test method name to extract tested type and method * * Supports patterns: * - test{Type}_{Method}_{Outcome} -> Type.method() * - test{Type}{Method} -> Type.method() * - test_{Type}_{Method} -> Type.method() * - testThat{Type}{Method} -> Type.method() * - test{Type}_when{Condition}_should{Outcome} -> Type * - test{Method}_{Outcome} (when type inferred from class) -> method() */ export declare function parseTestMethodName(methodName: string): ParsedTestMethod; /** * Extract the System Under Test (SUT) from a test class * * Looks for patterns like: * - var sut: TypeName! * - var subject: TypeName! * - let accountsManager: AccountsManager! * - private var viewModel: MyViewModel! */ export declare function extractSUTFromContent(content: string): { type?: string; variableName?: string; }; /** * Extract XCTest class declarations */ export declare function extractTestClasses(content: string, filePath: string): TestClassInfo[]; /** * Extract Quick/Nimble spec information */ export declare function extractQuickSpecs(content: string, filePath: string): TestClassInfo[]; /** * Analyze a test file to determine what it tests */ export declare function analyzeTestFile(filePath: string): Promise; /** * Build a comprehensive map of tested symbols from all test files */ export declare function buildTestedSymbolsMap(testFiles: string[]): Promise>; //# sourceMappingURL=test-analyzer.d.ts.map