|
| 1 | +import { Position, Range } from 'vscode-languageserver'; |
| 2 | +import { Editor, TextDocument } from './editor'; |
| 3 | +export interface AutoTestCase<T> { |
| 4 | + kind: string; |
| 5 | + title: string; |
| 6 | + tag?: string; |
| 7 | + expect: T; |
| 8 | + error?: { |
| 9 | + message: string; |
| 10 | + cause: string; |
| 11 | + }; |
| 12 | +} |
| 13 | +export interface KeybindingExpect { |
| 14 | + /** |
| 15 | + * apply之后对应的函内容匹配 |
| 16 | + */ |
| 17 | + lines: string[] | RegExp[]; |
| 18 | + /** |
| 19 | + * apply之后对应的光标位置 |
| 20 | + */ |
| 21 | + cursor?: Position; |
| 22 | +} |
| 23 | +export interface AutoTestKeybindCase extends AutoTestCase<KeybindingExpect> { |
| 24 | + kind: 'keybind'; |
| 25 | + range: Range; |
| 26 | + input: string; |
| 27 | + typeInNewLine?: boolean; |
| 28 | + keybind: string; |
| 29 | +} |
| 30 | +export interface AutoTestCheckEditorCase extends AutoTestCase<KeybindingExpect> { |
| 31 | + kind: 'checkEditor'; |
| 32 | +} |
| 33 | +export interface AutoEditExpect { |
| 34 | + /** |
| 35 | + * apply之后对应的函内容匹配 |
| 36 | + */ |
| 37 | + lines: string[] | RegExp[]; |
| 38 | + /** |
| 39 | + * apply之后对应的光标位置 |
| 40 | + */ |
| 41 | + cursor?: Position; |
| 42 | +} |
| 43 | +export interface AutoTestAutoEditCase extends AutoTestCase<AutoEditExpect> { |
| 44 | + kind: 'autoedit'; |
| 45 | + range: Range; |
| 46 | + typeInNewLine?: boolean; |
| 47 | + input: string; |
| 48 | +} |
| 49 | +export interface DefinitionExpect { |
| 50 | + uri: string; |
| 51 | + line: string | RegExp; |
| 52 | + cursor?: number; |
| 53 | +} |
| 54 | +export interface AutoTestDefinitionCase extends AutoTestCase<DefinitionExpect> { |
| 55 | + kind: 'definition'; |
| 56 | + range: Range; |
| 57 | +} |
| 58 | +export interface HoverExpect { |
| 59 | + /** |
| 60 | + * hover的内容 |
| 61 | + */ |
| 62 | + content: string | RegExp; |
| 63 | + /** |
| 64 | + * 是否支持F1打开帮助文档 |
| 65 | + */ |
| 66 | + supportF1?: boolean; |
| 67 | +} |
| 68 | +export interface AutoTestHoverCase extends AutoTestCase<HoverExpect> { |
| 69 | + kind: 'hover' | 'noerror' | 'error'; |
| 70 | + range: Range; |
| 71 | + docOffsetAt: number; |
| 72 | + type: 'string'; |
| 73 | +} |
| 74 | +export interface OutlineExpect { |
| 75 | + filePath: string; |
| 76 | +} |
| 77 | +export interface AutoTestOutlineCase extends AutoTestCase<OutlineExpect> { |
| 78 | + kind: 'outline'; |
| 79 | + needCreate?: boolean; |
| 80 | + project: string; |
| 81 | + lsDir: string; |
| 82 | + programData: string; |
| 83 | + programPlugin: string; |
| 84 | +} |
| 85 | +export interface ReferencesExpect { |
| 86 | + filePath: string; |
| 87 | +} |
| 88 | +export interface AutoTestReferencesCase extends AutoTestCase<ReferencesExpect> { |
| 89 | + kind: 'references'; |
| 90 | + needCreate?: boolean; |
| 91 | + range: Range; |
| 92 | + docOffsetAt: number; |
| 93 | + project: string; |
| 94 | + lsDir: string; |
| 95 | + programData: string; |
| 96 | + programPlugin: string; |
| 97 | +} |
| 98 | +export interface ErrorExpect { |
| 99 | + content: string | RegExp; |
| 100 | +} |
| 101 | +export interface CompletionExpect { |
| 102 | + /** |
| 103 | + * 代码助手列表项 |
| 104 | + */ |
| 105 | + items: string[]; |
| 106 | + /** |
| 107 | + * 代码助手列表项-不能包含项 |
| 108 | + */ |
| 109 | + excludeItems: string[]; |
| 110 | + /** |
| 111 | + * apply之后对应的函内容匹配 |
| 112 | + */ |
| 113 | + lines: string[] | RegExp[]; |
| 114 | + /** |
| 115 | + * apply之后对应的光标位置 |
| 116 | + */ |
| 117 | + cursor?: Position; |
| 118 | + /** |
| 119 | + * apply的item的详细信息 |
| 120 | + */ |
| 121 | + detail?: string | RegExp; |
| 122 | +} |
| 123 | +export interface AutoTestCompletionCase extends AutoTestCase<CompletionExpect> { |
| 124 | + kind: 'completion' | 'init'; |
| 125 | + /** |
| 126 | + * 是否在新的一行写,如为true,则会在range位置回车后开始写 |
| 127 | + */ |
| 128 | + typeInNewLine?: boolean; |
| 129 | + /** |
| 130 | + * 要输入的位置 |
| 131 | + */ |
| 132 | + range: Range; |
| 133 | + /** |
| 134 | + * 要输入的文字 |
| 135 | + */ |
| 136 | + input: string; |
| 137 | + /** |
| 138 | + * 选择哪一项,默认是第一项。下标从`0`开始 |
| 139 | + */ |
| 140 | + applyIndex?: number; |
| 141 | +} |
| 142 | +export interface AutoTestDbClickCase extends AutoTestCase<DbClickExpect> { |
| 143 | + kind: 'dbclick'; |
| 144 | + range: Range; |
| 145 | +} |
| 146 | +export interface DbClickExpect { |
| 147 | + begin: string; |
| 148 | + end: string; |
| 149 | + match: string; |
| 150 | +} |
| 151 | +export interface PerformanceExpect { |
| 152 | + expect: AutoTestDefinitionCase | AutoTestHoverCase | AutoTestCompletionCase; |
| 153 | +} |
| 154 | +export interface AutoTestPerformanceCase extends AutoTestCase<PerformanceExpect> { |
| 155 | + kind: 'performance'; |
| 156 | + type: string; |
| 157 | + num: number; |
| 158 | + timer: number; |
| 159 | + range: Range; |
| 160 | +} |
| 161 | +interface TestCaseResult { |
| 162 | + casename: string; |
| 163 | + passed: boolean; |
| 164 | + message?: string; |
| 165 | + filePath?: string; |
| 166 | +} |
| 167 | +export declare function getTestMergedResults(testResults: TestCaseResult[], project_name: string, autotestOptions: any): unknown[]; |
| 168 | +export declare function generateTestReport(testResults: TestCaseResult[], testBaseInfo: any, allCase: number): any; |
| 169 | +export declare function matchTestcaseContent(line: string): string | undefined; |
| 170 | +export declare function scan(doc: TextDocument, project: string, config: any, range?: { |
| 171 | + startLine: number; |
| 172 | + endLine: number; |
| 173 | +}): AutoTestCase<any>[][]; |
| 174 | +export declare function runCaseItem(testcase: AutoTestCase<any>, editor: Editor, config?: any): Promise<any[]>; |
| 175 | +export declare function runcase(testcase: AutoTestCase<any>, editor: Editor, config?: any): Promise<any[]>; |
| 176 | +export {}; |
0 commit comments