@salesforce/plugin-apex
Version:
63 lines (62 loc) • 2.05 kB
TypeScript
import { CancellationTokenSource, TestRunIdResult } from '@salesforce/apex-node';
import { Connection } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { RunResult } from '../reporters/index.js';
export declare const TestLevelValues: string[];
export type RunCommandResult = RunResult | TestRunIdResult;
export type TestRunFlags = {
'code-coverage'?: boolean;
'output-dir'?: string;
'test-level'?: string;
'class-names'?: string[];
'suite-names'?: string[];
tests?: string[];
wait?: Duration;
synchronous?: boolean;
'detailed-coverage'?: boolean;
concise?: boolean;
'result-format'?: string;
json?: boolean;
'test-category'?: string[];
'poll-interval'?: Duration;
};
export type TestRunConfig = {
commandType: 'apex' | 'logic';
exclusiveTestSpecifiers: string[];
binName: string;
};
export type TestRunContext = {
flags: TestRunFlags;
config: TestRunConfig;
connection: Connection;
jsonEnabled: boolean;
cancellationToken: CancellationTokenSource;
log: (message: string) => void;
info: (message: string) => void;
};
/**
* Shared service for running tests with command-specific behavior
*/
export declare class TestRunService {
static runTestCommand(context: TestRunContext): Promise<RunCommandResult>;
private static runTest;
private static runTestAsynchronous;
/**
* Get test category based on command type and flags
* - apex command: returns empty string for RunSpecifiedTests, 'Apex' for other test levels
* - logic command: returns test-category flag value or defaults to all categories
*/
private static getTestCategory;
/**
* Log appropriate async test instructions based on command type
*/
private static logAsyncTestInstructions;
/**
* Handle testing server errors with command-specific messaging
*/
private static handleTestingServerError;
/**
* Validate flags with command-specific logic
*/
private static validateFlags;
}