Skip to content

Commit

Permalink
add uri for unittest subtests fix "go to test" bug (microsoft#24544)
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd authored Dec 4, 2024
1 parent 4153f7c commit b8cc93d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/client/testing/testController/common/resultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ export class PythonResultResolver implements ITestResultResolver {
// clear since subtest items don't persist between runs
clearAllChildren(parentTestItem);
}
const subTestItem = this.testController?.createTestItem(subtestId, subtestId);
const subTestItem = this.testController?.createTestItem(
subtestId,
subtestId,
parentTestItem.uri,
);
// create a new test item for the subtest
if (subTestItem) {
const traceback = data.traceback ?? '';
Expand Down Expand Up @@ -293,7 +297,11 @@ export class PythonResultResolver implements ITestResultResolver {
// clear since subtest items don't persist between runs
clearAllChildren(parentTestItem);
}
const subTestItem = this.testController?.createTestItem(subtestId, subtestId);
const subTestItem = this.testController?.createTestItem(
subtestId,
subtestId,
parentTestItem.uri,
);
// create a new test item for the subtest
if (subTestItem) {
parentTestItem.children.add(subTestItem);
Expand Down
5 changes: 4 additions & 1 deletion src/test/testing/testController/resultResolver.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,12 @@ suite('Result Resolver tests', () => {
resultResolver.runIdToTestItem.set(subtestName, mockSubtestItem);

let generatedId: string | undefined;
let generatedUri: Uri | undefined;
testControllerMock
.setup((t) => t.createTestItem(typemoq.It.isAny(), typemoq.It.isAny()))
.setup((t) => t.createTestItem(typemoq.It.isAny(), typemoq.It.isAny(), typemoq.It.isAny()))
.callback((id: string) => {
generatedId = id;
generatedUri = workspaceUri;
traceLog('createTestItem function called with id:', id);
})
.returns(() => ({ id: 'id_this', label: 'label_this', uri: workspaceUri } as TestItem));
Expand All @@ -373,6 +375,7 @@ suite('Result Resolver tests', () => {

// verify that the passed function was called for the single test item
assert.ok(generatedId);
assert.strictEqual(generatedUri, workspaceUri);
assert.strictEqual(generatedId, '[subTest with spaces and [brackets]]');
});
test('resolveExecution handles failed tests correctly', async () => {
Expand Down

0 comments on commit b8cc93d

Please sign in to comment.