UNPKG

@tsdi/unit

Version:

unit testing framework, base on AOP, Ioc container

176 lines (175 loc) 5.29 kB
import { MetadataExtends, ArgsIteratorAction, Type } from '@tsdi/ioc'; import { SuiteMetadata, TestCaseMetadata, TestMetadata } from './metadata'; /** * Suite decorator type define. * * @export * @interface ISuiteDecorator * @template T */ export interface ISuiteDecorator { /** * suite decorator. * @param {string} suite describe. */ (describe?: string): ClassDecorator; /** * suite decorator. * @param {string} suite describe. * @param {number} timeout suite timeout. */ (describe: string, timeout: number): ClassDecorator; /** * suite decorator with metadata. */ (metadata?: SuiteMetadata): ClassDecorator; /** * suite decorator. */ (target: Type): void; } /** * create filed decorator. * * @export * @template T * @param {string} [SuiteType] * @param {ArgsIteratorAction<T>[]} [actions] * @param {MetadataExtends<T>} [metaExtends] * @returns {IFiledDecorator<T>} */ export declare function createSuiteDecorator<T extends SuiteMetadata>(actions?: ArgsIteratorAction<T>[], metaExtends?: MetadataExtends<T>): ISuiteDecorator; export declare const Suite: ISuiteDecorator; /** * define the method of class as unit test case. * * @export * @interface ITestDecorator * @template T */ export interface ITestDecorator<T extends TestMetadata> { (timeout: number): MethodDecorator; (metadata?: T): MethodDecorator; } /** * create Test decorator. * * @export * @template T * @param {string} [TestType] * @param {MetadataAdapter} [actions] * @param {MetadataExtends<T>} [metaExtends] * @returns {ITestDecorator<T>} */ export declare function createTestDecorator<T extends TestMetadata>(name: string, actions?: ArgsIteratorAction<T> | ArgsIteratorAction<T>[], finallyActions?: ArgsIteratorAction<T> | ArgsIteratorAction<T>[], metaExtends?: MetadataExtends<T>): ITestDecorator<T>; /** * test case decorator * * @export * @interface ITestCaseDecorator * @extends {ITestDecorator<TestCaseMetadata>} */ export interface ITestCaseDecorator extends ITestDecorator<TestCaseMetadata> { /** * @Test decorator. define the method of class as unit test case. Describe a specification or test-case with the given `title` and callback `fn` acting * as a thunk. * * @param {string} title test case title. * @param {number} [timeout] test case timeout. * @param {number} [setp] test case setp order in this test suite. */ (title?: string, timeout?: number, setp?: number): MethodDecorator; } /** * @Test decorator. define the method of class as unit test case. Describe a specification or test-case with the given `title` and callback `fn` acting * as a thunk. * * @export * @interface ITestDecorator * @template T */ export declare const Test: ITestCaseDecorator; /** * @BeforeAll decorator. define the method of class as unit test action run before all test case. * * @export * @interface IBeforeTestDecorator * @extends {ITestDecorator<TestMetadata>} */ export interface IBeforeTestDecorator extends ITestDecorator<TestMetadata> { } /** * @BeforeAll decorator. define the method of class as unit test action run before all test case. * * @export * @interface IBeforeTestDecorator * @template T */ export declare const BeforeAll: IBeforeTestDecorator; /** * @BeforeAll decorator. define the method of class as unit test action run before all test case. * * @export * @interface IBeforeTestDecorator * @template T */ export declare const Before: IBeforeTestDecorator; /** * @BeforeEach decorator. define the method of class as unit test action run before each test case. * * @export * @interface IBeforeEachTestDecorator * @extends {ITestDecorator<TestMetadata>} */ export interface IBeforeEachTestDecorator extends ITestDecorator<TestMetadata> { } /** * @BeforeEach decorator. define the method of class as unit test action run before each test case. * * @export * @interface IBeforeEachTestDecorator * @template T */ export declare const BeforeEach: IBeforeEachTestDecorator; /** * @AfterAll decorator. define the method of class as unit test action run after all test case. * * @export * @interface IAfterTestDecorator * @extends {ITestDecorator<TestMetadata>} */ export interface IAfterTestDecorator extends ITestDecorator<TestMetadata> { } /** * @AfterAll decorator. define the method of class as unit test action run after all test case. * * @export * @interface IAfterTestDecorator * @template T */ export declare const AfterAll: IAfterTestDecorator; /** * @AfterAll decorator. define the method of class as unit test action run after all test case. * * @export * @interface IAfterTestDecorator * @template T */ export declare const After: IAfterTestDecorator; /** * @AfterEach decorator. define the method of class as unit test action run after each test case. * * @export * @interface IAfterEachTestDecorator * @extends {ITestDecorator<TestMetadata>} */ export interface IAfterEachTestDecorator extends ITestDecorator<TestMetadata> { } /** * @AfterEach decorator. define the method of class as unit test action run after each test case. * * @export * @interface IAfterEachTestDecorator * @template T */ export declare const AfterEach: IAfterEachTestDecorator;