Skip to content

Commit 8810766

Browse files
authored
remove stale code for displaying config error (#25269)
Two parts: - removes notification on run without configuration, this was meant to be removed as stated in the TODO comment - removes unused function `displayTestFrameworkError` & tests related to it
1 parent 1f8949c commit 8810766

File tree

5 files changed

+4
-233
lines changed

5 files changed

+4
-233
lines changed

src/client/common/utils/localize.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ export namespace DebugConfigStrings {
411411

412412
export namespace Testing {
413413
export const configureTests = l10n.t('Configure Test Framework');
414-
export const testNotConfigured = l10n.t('No test framework configured.');
415414
export const cancelUnittestDiscovery = l10n.t('Canceled unittest test discovery');
416415
export const errorUnittestDiscovery = l10n.t('Unittest test discovery error');
417416
export const cancelPytestDiscovery = l10n.t('Canceled pytest test discovery');

src/client/testing/common/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export interface ITestsHelper {
5050
export const ITestConfigurationService = Symbol('ITestConfigurationService');
5151
export interface ITestConfigurationService {
5252
hasConfiguredTests(wkspace: Uri): boolean;
53-
displayTestFrameworkError(wkspace: Uri): Promise<void>;
5453
selectTestRunner(placeHolderMessage: string): Promise<UnitTestProduct | undefined>;
5554
enableTest(wkspace: Uri, product: UnitTestProduct): Promise<void>;
5655
promptToEnableAndConfigureTestFramework(wkspace: Uri): Promise<void>;

src/client/testing/configuration/index.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,6 @@ export class UnitTestConfigurationService implements ITestConfigurationService {
4040
return settings.testing.pytestEnabled || settings.testing.unittestEnabled || false;
4141
}
4242

43-
public async displayTestFrameworkError(wkspace: Uri): Promise<void> {
44-
const settings = this.configurationService.getSettings(wkspace);
45-
let enabledCount = settings.testing.pytestEnabled ? 1 : 0;
46-
enabledCount += settings.testing.unittestEnabled ? 1 : 0;
47-
if (enabledCount > 1) {
48-
return this._promptToEnableAndConfigureTestFramework(
49-
wkspace,
50-
'Enable only one of the test frameworks (unittest or pytest).',
51-
true,
52-
);
53-
}
54-
const option = 'Enable and configure a Test Framework';
55-
const item = await this.appShell.showInformationMessage(
56-
'No test framework configured (unittest, or pytest)',
57-
option,
58-
);
59-
if (item !== option) {
60-
throw NONE_SELECTED;
61-
}
62-
return this._promptToEnableAndConfigureTestFramework(wkspace);
63-
}
64-
6543
public async selectTestRunner(placeHolderMessage: string): Promise<UnitTestProduct | undefined> {
6644
const items = [
6745
{

src/client/testing/main.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { DelayedTrigger, IDelayedTrigger } from '../common/utils/delayTrigger';
2929
import { ExtensionContextKey } from '../common/application/contextKeys';
3030
import { checkForFailedTests, updateTestResultMap } from './testController/common/testItemUtilities';
3131
import { Testing } from '../common/utils/localize';
32-
import { traceVerbose } from '../logging';
32+
import { traceVerbose, traceWarn } from '../logging';
3333
import { writeTestIdToClipboard } from './utils';
3434

3535
@injectable()
@@ -103,22 +103,9 @@ export class UnitTestManagementService implements IExtensionActivationService {
103103
if (unconfigured.length === workspaces.length) {
104104
const commandManager = this.serviceContainer.get<ICommandManager>(ICommandManager);
105105
await commandManager.executeCommand('workbench.view.testing.focus');
106-
107-
// TODO: this is a workaround for https://github.com/microsoft/vscode/issues/130696
108-
// Once that is fixed delete this notification and test should be configured from the test view.
109-
const app = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
110-
const response = await app.showInformationMessage(
111-
Testing.testNotConfigured,
112-
Testing.configureTests,
106+
traceWarn(
107+
'Testing: Run attempted but no test configurations found for any workspace, use command palette to configure tests for python if desired.',
113108
);
114-
if (response === Testing.configureTests) {
115-
await commandManager.executeCommand(
116-
constants.Commands.Tests_Configure,
117-
undefined,
118-
constants.CommandSource.ui,
119-
unconfigured[0].uri,
120-
);
121-
}
122109
}
123110
});
124111
}

src/test/testing/configuration.unit.test.ts

Lines changed: 1 addition & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
ITestsHelper,
2626
} from '../../client/testing/common/types';
2727
import { ITestingSettings } from '../../client/testing/configuration/types';
28-
import { NONE_SELECTED, UnitTestConfigurationService } from '../../client/testing/configuration';
28+
import { UnitTestConfigurationService } from '../../client/testing/configuration';
2929

3030
suite('Unit Tests - ConfigurationService', () => {
3131
UNIT_TEST_PRODUCTS.forEach((product) => {
@@ -259,198 +259,6 @@ suite('Unit Tests - ConfigurationService', () => {
259259
enabled = true;
260260
expect(testConfigService.target.hasConfiguredTests(workspaceUri)).to.equal(true);
261261
});
262-
test('Prompt to enable a test if a test framework is not enabled', async () => {
263-
unitTestSettings.setup((u) => u.pytestEnabled).returns(() => false);
264-
unitTestSettings.setup((u) => u.unittestEnabled).returns(() => false);
265-
266-
appShell
267-
.setup((s) => s.showInformationMessage(typeMoq.It.isAny(), typeMoq.It.isAny()))
268-
.returns(() => Promise.resolve(undefined))
269-
.verifiable(typeMoq.Times.once());
270-
271-
let exceptionThrown = false;
272-
try {
273-
await testConfigService.target.displayTestFrameworkError(workspaceUri);
274-
} catch (exc) {
275-
if (exc !== NONE_SELECTED) {
276-
throw exc;
277-
}
278-
exceptionThrown = true;
279-
}
280-
281-
expect(exceptionThrown).to.be.equal(true, 'Exception not thrown');
282-
appShell.verifyAll();
283-
});
284-
test('Prompt to select a test if a test framework is not enabled', async () => {
285-
unitTestSettings.setup((u) => u.pytestEnabled).returns(() => false);
286-
unitTestSettings.setup((u) => u.unittestEnabled).returns(() => false);
287-
288-
appShell
289-
.setup((s) => s.showInformationMessage(typeMoq.It.isAny(), typeMoq.It.isAny()))
290-
.returns((_msg, option) => Promise.resolve(option))
291-
.verifiable(typeMoq.Times.once());
292-
293-
let exceptionThrown = false;
294-
let selectTestRunnerInvoked = false;
295-
try {
296-
testConfigService.callBase = false;
297-
testConfigService
298-
.setup((t) => t.selectTestRunner(typeMoq.It.isAny()))
299-
.returns(() => {
300-
selectTestRunnerInvoked = true;
301-
return Promise.resolve(undefined);
302-
});
303-
await testConfigService.target.displayTestFrameworkError(workspaceUri);
304-
} catch (exc) {
305-
if (exc !== NONE_SELECTED) {
306-
throw exc;
307-
}
308-
exceptionThrown = true;
309-
}
310-
311-
expect(selectTestRunnerInvoked).to.be.equal(true, 'Method not invoked');
312-
expect(exceptionThrown).to.be.equal(true, 'Exception not thrown');
313-
appShell.verifyAll();
314-
});
315-
test('Configure selected test framework and disable others', async () => {
316-
unitTestSettings.setup((u) => u.pytestEnabled).returns(() => false);
317-
unitTestSettings.setup((u) => u.unittestEnabled).returns(() => false);
318-
319-
const workspaceConfig = typeMoq.Mock.ofType<WorkspaceConfiguration>(
320-
undefined,
321-
typeMoq.MockBehavior.Strict,
322-
);
323-
workspaceConfig
324-
.setup((w) => w.get(typeMoq.It.isAny()))
325-
.returns(() => true)
326-
.verifiable(typeMoq.Times.once());
327-
workspaceService
328-
.setup((w) => w.getConfiguration(typeMoq.It.isValue('python'), workspaceUri))
329-
.returns(() => workspaceConfig.object)
330-
.verifiable(typeMoq.Times.once());
331-
332-
appShell
333-
.setup((s) => s.showInformationMessage(typeMoq.It.isAny(), typeMoq.It.isAny()))
334-
.returns((_msg, option) => Promise.resolve(option))
335-
.verifiable(typeMoq.Times.once());
336-
337-
let selectTestRunnerInvoked = false;
338-
testConfigService.callBase = false;
339-
testConfigService
340-
.setup((t) => t.selectTestRunner(typeMoq.It.isAny()))
341-
.returns(() => {
342-
selectTestRunnerInvoked = true;
343-
return Promise.resolve(product);
344-
});
345-
346-
const configMgr = typeMoq.Mock.ofType<ITestConfigurationManager>(
347-
undefined,
348-
typeMoq.MockBehavior.Strict,
349-
);
350-
factory
351-
.setup((f) =>
352-
f.create(typeMoq.It.isValue(workspaceUri), typeMoq.It.isValue(product), typeMoq.It.isAny()),
353-
)
354-
.returns(() => configMgr.object)
355-
.verifiable(typeMoq.Times.once());
356-
357-
configMgr
358-
.setup((c) => c.configure(typeMoq.It.isValue(workspaceUri)))
359-
.returns(() => Promise.resolve())
360-
.verifiable(typeMoq.Times.once());
361-
configMgr
362-
.setup((c) => c.enable())
363-
.returns(() => Promise.resolve())
364-
.verifiable(typeMoq.Times.once());
365-
366-
await testConfigService.target.displayTestFrameworkError(workspaceUri);
367-
368-
expect(selectTestRunnerInvoked).to.be.equal(true, 'Select Test Runner not invoked');
369-
appShell.verifyAll();
370-
factory.verifyAll();
371-
configMgr.verifyAll();
372-
workspaceConfig.verifyAll();
373-
});
374-
test('If more than one test framework is enabled, then prompt to select a test framework', async () => {
375-
unitTestSettings.setup((u) => u.pytestEnabled).returns(() => true);
376-
unitTestSettings.setup((u) => u.unittestEnabled).returns(() => true);
377-
378-
appShell
379-
.setup((s) => s.showInformationMessage(typeMoq.It.isAny(), typeMoq.It.isAny()))
380-
.returns(() => Promise.resolve(undefined))
381-
.verifiable(typeMoq.Times.never());
382-
appShell
383-
.setup((s) => s.showQuickPick(typeMoq.It.isAny(), typeMoq.It.isAny()))
384-
.returns(() => Promise.resolve(undefined))
385-
.verifiable(typeMoq.Times.once());
386-
387-
let exceptionThrown = false;
388-
try {
389-
await testConfigService.target.displayTestFrameworkError(workspaceUri);
390-
} catch (exc) {
391-
if (exc !== NONE_SELECTED) {
392-
throw exc;
393-
}
394-
exceptionThrown = true;
395-
}
396-
397-
expect(exceptionThrown).to.be.equal(true, 'Exception not thrown');
398-
appShell.verifyAll();
399-
});
400-
test('If more than one test framework is enabled, then prompt to select a test framework and enable test, but do not configure', async () => {
401-
unitTestSettings.setup((u) => u.pytestEnabled).returns(() => true);
402-
unitTestSettings.setup((u) => u.unittestEnabled).returns(() => true);
403-
404-
appShell
405-
.setup((s) => s.showInformationMessage(typeMoq.It.isAny(), typeMoq.It.isAny()))
406-
.returns((_msg, option) => Promise.resolve(option))
407-
.verifiable(typeMoq.Times.never());
408-
409-
let selectTestRunnerInvoked = false;
410-
testConfigService.callBase = false;
411-
testConfigService
412-
.setup((t) => t.selectTestRunner(typeMoq.It.isAny()))
413-
.returns(() => {
414-
selectTestRunnerInvoked = true;
415-
return Promise.resolve(product);
416-
});
417-
418-
let enableTestInvoked = false;
419-
testConfigService
420-
.setup((t) => t.enableTest(typeMoq.It.isValue(workspaceUri), typeMoq.It.isValue(product)))
421-
.returns(() => {
422-
enableTestInvoked = true;
423-
return Promise.resolve();
424-
});
425-
426-
const configMgr = typeMoq.Mock.ofType<ITestConfigurationManager>(
427-
undefined,
428-
typeMoq.MockBehavior.Strict,
429-
);
430-
factory
431-
.setup((f) =>
432-
f.create(typeMoq.It.isValue(workspaceUri), typeMoq.It.isValue(product), typeMoq.It.isAny()),
433-
)
434-
.returns(() => configMgr.object)
435-
.verifiable(typeMoq.Times.once());
436-
437-
configMgr
438-
.setup((c) => c.configure(typeMoq.It.isValue(workspaceUri)))
439-
.returns(() => Promise.resolve())
440-
.verifiable(typeMoq.Times.never());
441-
configMgr
442-
.setup((c) => c.enable())
443-
.returns(() => Promise.resolve())
444-
.verifiable(typeMoq.Times.once());
445-
446-
await testConfigService.target.displayTestFrameworkError(workspaceUri);
447-
448-
expect(selectTestRunnerInvoked).to.be.equal(true, 'Select Test Runner not invoked');
449-
expect(enableTestInvoked).to.be.equal(false, 'Enable Test is invoked');
450-
factory.verifyAll();
451-
appShell.verifyAll();
452-
configMgr.verifyAll();
453-
});
454262

455263
test('Prompt to enable and configure selected test framework', async () => {
456264
unitTestSettings.setup((u) => u.pytestEnabled).returns(() => false);

0 commit comments

Comments
 (0)