forked from microsoft/vscode-java-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava-test-runner.api.ts
More file actions
362 lines (310 loc) · 7.8 KB
/
java-test-runner.api.ts
File metadata and controls
362 lines (310 loc) · 7.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as vscode from 'vscode';
/**
* @todo Proposed API
* Register a test profile to the test runner service.
*/
export type registerTestProfile = (name: string, kind: vscode.TestRunProfileKind, runner: TestRunner) => void;
/**
* @todo Proposed API
* Parse the test id from the parts.
*/
export type parseTestIdFromParts = (parts: TestIdParts) => string;
/**
* @todo Proposed API
* Parse the test id parts from the id.
*/
export type parsePartsFromTestId = (id: string) => TestIdParts;
/**
* @todo Proposed API
* The parts that compose a test id.
*/
export interface TestIdParts {
/**
* The project name.
*/
project: string;
/**
* The package fully qualified name.
*/
package?: string;
/**
* The class fully qualified name.
*/
class?: string;
/**
* The method name or the invocation names(for example, the dynamic tests in JUnit Jupiter).
*/
invocations?: string[];
}
/**
* @todo Proposed API
* The test runner.
*/
export interface TestRunner {
/**
* launch the test execution.
* @param context the context for this test run.
*/
launch(context: IRunTestContext): vscode.ProviderResult<void>;
/**
* Event that should be emitted when the status of a test item changes.
*/
onDidChangeTestItemStatus: vscode.Event<TestItemStatusChangeEvent>;
/**
* Event that should be emitted when the test run is finished.
*/
onDidFinishTestRun: vscode.Event<TestFinishEvent>;
}
/**
* @todo Proposed API
* The event that should be emitted when the status of a test item changes.
*/
export interface TestItemStatusChangeEvent {
/**
* An identifier representing the test item in the test explorer.
* The identifier must follow the following format:
* <package name>.<class name>[#<method or invocation name>]*
*
* Please note that:
*
* 1. The test controller will split the identifier to multiple parts according
* to the above example, and find the target test item using this hierarchy in the test explorer.
* 2. The class fully qualified name must be a valid one which exists in the test explorer.
* 3. Only the last part of the invocation or method name of the item is allowed to be non-existent
* in the explorer. In such case, the test controller will create a new test item in the test explorer.
*
* @example 'org.junit.Test#testMethod'
* @example 'foo.bar#test(String, String)#1 + 1 = 2'
*/
testId: string;
/**
* The new state of the test item.
*/
state: TestResultState;
/**
* The display name of the test item which will be displayed as description in the test explorer.
*/
displayName?: string;
/**
* The message of the test item. It can be used to show the error stacktrace for failed items.
*/
message?: string;
/**
* Execution duration for this test item in milliseconds.
*/
duration?: number;
}
/**
* @todo Proposed API
* The state of a test item.
*/
export enum TestResultState {
/**
* Test will be run, but is not currently running.
*/
Queued = 1,
/**
* Test is currently running.
*/
Running = 2,
/**
* Test run has passed.
*/
Passed = 3,
/**
* Test run has failed (on an assertion).
*/
Failed = 4,
/**
* Test run has been skipped.
*/
Skipped = 5,
/**
* Test run failed for some other reason (compilation error, timeout, etc).
*/
Errored = 6,
}
/**
* @todo Proposed API
* The event that should be emitted when the test run is finished.
*/
export interface TestFinishEvent {
/**
* The status of the test run.
*/
statusCode: number;
/**
* The message of the test run.
*/
message?: string;
}
/**
* @todo Proposed API
* The context for running tests.
*/
export interface IRunTestContext {
/**
* The flag to indicate whether the test run is in debug mode.
*/
isDebug: boolean;
/**
* The kind of the test.
*/
kind: TestKind;
/**
* The name of the project.
*/
projectName: string;
/**
* The test items to run.
*/
testItems: vscode.TestItem[];
/**
* VS Code's TestRun object for this test execution.
*/
testRun: vscode.TestRun;
/**
* The workspace folder where the tests are run.
*/
workspaceFolder: vscode.WorkspaceFolder;
/**
* The profile for this test run.
*/
profile?: vscode.TestRunProfile;
/**
* The configuration for this test run.
*/
testConfig?: IExecutionConfig;
}
/**
* @todo Proposed API
* The test kind.
*/
export enum TestKind {
JUnit5 = 0,
JUnit = 1,
TestNG = 2,
None = 100,
}
/**
* @todo Proposed API
* The test level.
*/
export enum TestLevel {
Root = 0,
Workspace = 1,
WorkspaceFolder = 2,
Project = 3,
Package = 4,
Class = 5,
Method = 6,
Invocation = 7,
}
/**
* @todo Proposed API
* The configuration for running tests.
*/
export interface IExecutionConfig {
/**
* The name of the configuration item.
* @since 0.14.0
*/
name?: string;
/**
* The working directory when running the tests.
* @since 0.14.0
*/
workingDirectory?: string;
/**
* The classpaths defined in this setting will be appended to the resolved classpaths.
* @since 0.33.0
*/
classPaths?: string[]
/**
* The modulepaths defined in this setting will be appended to the resolved modulepaths
* @since 0.33.0
*/
modulePaths?: string[]
/**
* The command line arguments which will be passed to the test runner.
* @since 0.14.0
*/
args?: any[];
/**
* The path to java executable to use. If undefined project JDK's java executable is used.
* @since 0.40.0
*/
javaExec?: string;
/**
* the default encoding the JVM will start with. If undefined, this will be UTF-8.
* @since 0.43.0
*/
encoding?: string;
/**
* the extra options and system properties for the JVM.
* @since 0.14.0
*/
vmArgs?: any[];
/**
* The extra environment variables when running the tests.
* @since 0.25.0
*/
env?: { [key: string]: string; };
/**
* The absolute path to a file containing environment variable definitions.
* @since 0.33.0
*/
envFile?: string;
/**
* The extra source paths when debugging the tests
* @since 0.22.4
*/
sourcePaths?: string[];
/**
* The label of a task specified in tasks.json.
* @since 0.33.0
*/
preLaunchTask?: string;
/**
* The label of a task specified in tasks.json.
* @since 0.39.0
*/
postDebugTask?: string;
/**
* the test framework kind of this test configuration.
* @since 0.37.0
*/
testKind?: string;
/**
* The configurations for test filters.
* @since 0.37.0
*/
filters?: {
/**
* The test tags which will be included or excluded when running tests.
* This field will only take effect on JUnit 5 tests and user needs to
* explicitly set `testKind` to `junit`.
* @since 0.37.0
*/
tags?: string[]
};
/**
* The coverage configuration.
* @since 0.41.0
*/
coverage?: {
/**
* Whether the coverage result is appended. For Jacoco, it means the execution data
* is appended to the existing data file if it already exists.
* @since 0.41.0
*/
appendResult?: boolean;
}
/**
* The when clause for matching tests by to determine if the configuration should be run with.
* @since 0.41.0
*/
when?: string
}