Skip to content

Commit 429ebbd

Browse files
authored
Merge pull request #307 from naren2605/fix-217
JVSC #217 | fixing test runner incorrectly processes test names
2 parents f50358c + 373f3be commit 429ebbd

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

vscode/src/views/TestViewController.ts

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { commands, debug, tests, workspace, CancellationToken, TestController, T
2525
import * as path from 'path';
2626
import { asRange, TestCase, TestSuite } from "../lsp/protocol";
2727
import { extCommands, builtInCommands, nbCommands } from "../commands/commands"
28+
import { extConstants } from "../constants";
2829

2930
export class NbTestAdapter {
3031

@@ -35,7 +36,7 @@ export class NbTestAdapter {
3536
private started: boolean = false;
3637

3738
constructor() {
38-
this.testController = tests.createTestController('apacheNetBeansController', 'Apache NetBeans');
39+
this.testController = tests.createTestController(extConstants.ORACLE_VSCODE_EXTENSION_ID + '.testController', 'Java');
3940
const runHandler = (request: TestRunRequest, cancellation: CancellationToken) => this.run(request, cancellation);
4041
this.testController.createRunProfile('Run Tests', TestRunProfileKind.Run, runHandler);
4142
this.testController.createRunProfile('Debug Tests', TestRunProfileKind.Debug, runHandler);
@@ -219,54 +220,29 @@ export class NbTestAdapter {
219220
currentSuite.range = suiteRange;
220221
}
221222
const children: TestItem[] = []
222-
const parentTests: Map<TestItem, TestItem[]> = new Map();
223-
suite.tests?.forEach(test => {
224-
let currentTest = currentSuite?.children.get(test.id);
225-
const testUri = test.file ? Uri.parse(test.file) : undefined;
223+
suite.tests?.forEach(testCase => {
224+
let currentTest = currentSuite?.children.get(testCase.id);
225+
const testUri = testCase.file ? Uri.parse(testCase.file) : undefined;
226226
if (currentTest) {
227227
if (testUri && currentTest.uri?.toString() !== testUri?.toString()) {
228-
currentTest = this.testController.createTestItem(test.id, test.name, testUri);
228+
currentTest = this.testController.createTestItem(testCase.id, testCase.name, testUri);
229229
currentSuite?.children.add(currentTest);
230230
}
231-
const testRange = asRange(test.range);
231+
const testRange = asRange(testCase.range);
232232
if (!testExecution && testRange && testRange !== currentTest.range) {
233233
currentTest.range = testRange;
234234
}
235235
children.push(currentTest);
236236
} else {
237-
if (testExecution) {
238-
const parents: Map<TestItem, string> = new Map();
239-
currentSuite?.children.forEach(item => {
240-
const subName = this.subTestName(item, test);
241-
if (subName && '()' !== subName) {
242-
parents.set(item, subName);
243-
}
244-
});
245-
const parent = this.selectParent(parents);
246-
if (parent) {
247-
let arr = parentTests.get(parent.test);
248-
if (!arr) {
249-
parentTests.set(parent.test, arr = []);
250-
children.push(parent.test);
251-
}
252-
arr.push(this.testController.createTestItem(test.id, parent.label));
253-
}
254-
} else {
255-
currentTest = this.testController.createTestItem(test.id, test.name, testUri);
256-
currentTest.range = asRange(test.range);
237+
if (!testExecution) {
238+
currentTest = this.testController.createTestItem(testCase.id, testCase.name, testUri);
239+
currentTest.range = asRange(testCase.range);
257240
children.push(currentTest);
258241
currentSuite?.children.add(currentTest);
259242
}
260243
}
261244
});
262-
if (testExecution) {
263-
parentTests.forEach((val, key) => {
264-
const item = this.testController.createTestItem(key.id, key.label, key.uri);
265-
item.range = key.range;
266-
item.children.replace(val);
267-
currentSuite?.children.add(item);
268-
});
269-
} else {
245+
if (!testExecution) {
270246
currentSuite.children.replace(children);
271247
}
272248
}

0 commit comments

Comments
 (0)