forked from microsoft/vscode-java-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestRunnerService.ts
More file actions
35 lines (28 loc) · 1.23 KB
/
testRunnerService.ts
File metadata and controls
35 lines (28 loc) · 1.23 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { TestRunProfileKind } from 'vscode';
import { creatTestProfile } from './testController';
import { TestRunner } from '../java-test-runner.api';
// TODO: this should be refactored. The test controller should be extended and hosting the registered runners.
class TestRunnerService {
private registeredRunners: Map<string, TestRunner>;
constructor() {
this.registeredRunners = new Map<string, TestRunner>();
}
public registerTestRunner(name: string, kind: TestRunProfileKind, runner: TestRunner) {
const key: string = `${name}:${kind}`;
if (this.registeredRunners.has(key)) {
throw new Error(`Runner ${key} has already been registered.`);
}
creatTestProfile(name, kind);
this.registeredRunners.set(key, runner);
}
public getRunner(name: string | undefined, kind: TestRunProfileKind | undefined): TestRunner | undefined {
if (!name || !kind) {
return undefined;
}
const key: string = `${name}:${kind}`;
return this.registeredRunners.get(key);
}
}
export const testRunnerService: TestRunnerService = new TestRunnerService();