@intuitionrobotics/testelot
Version:
Nu-Art Sir Testelot
62 lines (61 loc) • 2.44 kB
TypeScript
/**
* Created by IR on 3/18/17.
*/
import { Logger, Constructor } from "@intuitionrobotics/ts-common";
import { ContextKey } from "./ContainerContext";
import { Reporter } from "./Reporter";
export declare enum Status {
Ready = "Ready",
Running = "Running",
Skipped = "Skipped",
Success = "Success",
Error = "Error"
}
export declare const enum ErrorPolicy {
ContinueOnError = 0,
SkipOnError = 1,
HaltOnError = 2
}
export type ShouldFailCondition<T extends Error> = (e: T) => boolean;
export type ReturnValueProcessor<ReturnValue = any> = (returnValue?: ReturnValue) => void;
export declare abstract class Action<ParamValue = any, ReturnValue = any> extends Logger {
private static testsToRun;
readonly actionType: string;
readonly uuid: string;
protected writeKey: ContextKey<ReturnValue>;
private readKey;
private parent;
protected reporter: Reporter;
private label?;
policy: ErrorPolicy;
private _started;
private _ended;
private postExecutionDelay;
status: Status;
private shouldFailCondition?;
private assertFailCondition?;
protected constructor(actionType: Function, tag?: string);
static resolveTestsToRun(): void;
expectToFail<T extends Error>(_exceptionType: Constructor<T>, assertFailCondition?: ShouldFailCondition<T>): this;
processReturnValue(returnValueProcessor: ReturnValueProcessor<ReturnValue>): this;
isContainer(): boolean;
hasParent(): boolean;
setErrorPolicy(policy: ErrorPolicy): this;
protected setParent(parent: Action<any>): void;
protected setReporter(reporter: Reporter): void;
setWriteKey(writeKey: ContextKey<ReturnValue>): this;
setReadKey(readKey: ContextKey<ParamValue>): this;
setPostExecutionDelay(postExecutionDelay: number): this;
setLabel(label?: string | ((param?: ParamValue) => string)): this;
getStarted(): number;
getEnded(): number;
protected _executeSubAction(action: Action): Promise<void>;
protected resolveLabel(param?: ParamValue): string | undefined;
private _execute;
setStatus(status: Status): void;
protected abstract execute(param: ParamValue): Promise<ReturnValue>;
get<ValueType>(key: ContextKey<ValueType>): ValueType | undefined;
protected remove<ValueType>(key: ContextKey<ValueType>): boolean;
set<ValueType>(key: ContextKey<ValueType>, value: ValueType): ValueType | undefined;
reset(): void;
}