diff --git a/src/client/unittests/common/services/testsStatusService.ts b/src/client/unittests/common/services/testsStatusService.ts index 916e1660ec1f..08bd1316e3aa 100644 --- a/src/client/unittests/common/services/testsStatusService.ts +++ b/src/client/unittests/common/services/testsStatusService.ts @@ -48,7 +48,7 @@ export class TestsStatusUpdaterService implements ITestsStatusUpdaterService { } const predicate = (item: TestDataItem) => item.status === TestStatus.Fail || item.status === TestStatus.Error; const visitor = (item: TestDataItem) => { - if (item.status && predicate(item)){ + if (item.status && predicate(item)) { item.status = TestStatus.Running; this.storage.update(resource, item); } diff --git a/src/test/unittests/common/services/testStatusService.unit.test.ts b/src/test/unittests/common/services/testStatusService.unit.test.ts index 342f8f9081b0..d5a0a68a0d22 100644 --- a/src/test/unittests/common/services/testStatusService.unit.test.ts +++ b/src/test/unittests/common/services/testStatusService.unit.test.ts @@ -155,6 +155,7 @@ suite('Unit Tests - Tests Status Updater', () => { tests.testFiles[3].status = TestStatus.Error; tests.testFunctions[2].testFunction.status = TestStatus.Fail; tests.testFunctions[3].testFunction.status = TestStatus.Error; + tests.testFunctions[4].testFunction.status = TestStatus.Pass; tests.testSuites[1].testSuite.status = TestStatus.Fail; tests.testSuites[2].testSuite.status = TestStatus.Error; @@ -168,7 +169,11 @@ suite('Unit Tests - Tests Status Updater', () => { // Update status of test functions and suites. const updatedItems: TestDataItem[] = []; - const visitor = (item: TestDataItem) => updatedItems.push(item); + const visitor = (item: TestDataItem) => { + if (item.status && item.status !== TestStatus.Pass) { + updatedItems.push(item); + } + }; const failedItems = [ tests.testFunctions[2].testFunction, tests.testFunctions[3].testFunction, @@ -182,6 +187,9 @@ suite('Unit Tests - Tests Status Updater', () => { verify(storage.update(workspaceUri, item)).once(); } + // Only items with status Fail & Error should be modified + assert.equal(tests.testFunctions[4].testFunction.status, TestStatus.Pass); + // Should only be called for failed items. verify(storage.update(workspaceUri, anything())).times(updatedItems.length); });