Skip to content

Commit

Permalink
Fix unittest subtest names that have spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Sep 7, 2023
1 parent 6e9e656 commit c8b9e1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/client/testing/testController/common/resultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ export class PythonResultResolver implements ITestResultResolver {
}
} else if (rawTestExecData.result[keyTemp].outcome === 'subtest-success') {
// split on " " since the subtest ID has the parent test ID in the first part of the ID.
const parentTestCaseId = keyTemp.split(' ')[0];
const subtestId = keyTemp.split(' ')[1];
const parentTestCaseId = keyTemp.split(' [')[0];
const subtestId = `[${keyTemp.split(' [')[1]}`;
const parentTestItem = this.runIdToTestItem.get(parentTestCaseId);

// find the subtest's parent test item
Expand Down
14 changes: 7 additions & 7 deletions src/test/testing/testController/resultResolver.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ suite('Result Resolver tests', () => {
testProvider,
workspaceUri,
);
const mockSubtestItem = createMockTestItem('parentTest subTest');
const mockSubtestItem = createMockTestItem('parentTest [subTest with spaces]');
// add a mock test item to the map of known VSCode ids to run ids
resultResolver.runIdToVSid.set('mockTestItem2', 'mockTestItem2');
// creates a mock test item with a space which will be used to split the runId
resultResolver.runIdToVSid.set('parentTest subTest', 'parentTest subTest');
resultResolver.runIdToVSid.set('parentTest [subTest with spaces]', 'parentTest [subTest with spaces]');

// add this mock test to the map of known test items
resultResolver.runIdToTestItem.set('parentTest', mockTestItem2);
resultResolver.runIdToTestItem.set('parentTest subTest', mockSubtestItem);
resultResolver.runIdToTestItem.set('parentTest [subTest with spaces]', mockSubtestItem);

let generatedId: string | undefined;
testControllerMock
Expand All @@ -294,12 +294,12 @@ suite('Result Resolver tests', () => {
cwd: workspaceUri.fsPath,
status: 'success',
result: {
'parentTest subTest': {
test: 'test',
'parentTest [subTest with spaces]': {
test: 'parentTest',
outcome: 'subtest-success', // failure, passed-unexpected, skipped, success, expected-failure, subtest-failure, subtest-succcess
message: 'message',
traceback: 'traceback',
subtest: 'subtest',
subtest: 'parentTest [subTest with spaces]',
},
},
error: '',
Expand All @@ -310,7 +310,7 @@ suite('Result Resolver tests', () => {

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

0 comments on commit c8b9e1d

Please sign in to comment.