Skip to content

Commit

Permalink
Add test view with a welcome button (microsoft#16215)
Browse files Browse the repository at this point in the history
* Add test view with a welcome button

* Register registerTestController only when available.
  • Loading branch information
karthiknadig committed Aug 2, 2021
1 parent 5819912 commit e72ccc0
Show file tree
Hide file tree
Showing 7 changed files with 615 additions and 124 deletions.
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2161,15 +2161,13 @@
}
]
},
"views": {
"test": [
{
"id": "python_tests",
"name": "Python",
"when": "testsDiscovered"
}
]
},
"viewsWelcome": [
{
"view": "testing",
"contents": "Configure a test framework to see your tests here.\n[Configure Python Tests](command:python.configureTests)",
"when": "!testsDiscovered"
}
],
"yamlValidation": [
{
"fileMatch": ".condarc",
Expand Down
45 changes: 0 additions & 45 deletions src/client/testing/explorer/treeView.ts

This file was deleted.

6 changes: 6 additions & 0 deletions src/client/testing/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Event,
EventEmitter,
OutputChannel,
test,
TextDocument,
Uri,
} from 'vscode';
Expand Down Expand Up @@ -43,6 +44,7 @@ import {
} from './common/types';
import { TEST_OUTPUT_CHANNEL } from './constants';
import { ITestingService } from './types';
import { PythonTestController } from './testController/controller';

@injectable()
export class TestingService implements ITestingService {
Expand Down Expand Up @@ -116,6 +118,10 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
this.autoDiscoverTests(undefined).catch((ex) =>
traceError('Failed to auto discover tests upon activation', ex),
);

if (test && test.registerTestController) {
this.disposableRegistry.push(test.registerTestController(new PythonTestController()));
}
}
public async getTestManager(
displayTestNotConfiguredMessage: boolean,
Expand Down
2 changes: 0 additions & 2 deletions src/client/testing/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import { TestDisplay } from './display/picker';
import { TestExplorerCommandHandler } from './explorer/commandHandlers';
import { FailedTestHandler } from './explorer/failedTestHandler';
import { TestTreeViewProvider } from './explorer/testTreeViewProvider';
import { TreeViewService } from './explorer/treeView';
import { TestingService, UnitTestManagementService } from './main';
import { registerTypes as registerNavigationTypes } from './navigation/serviceRegistry';
import { ITestExplorerCommandHandler } from './navigation/types';
Expand Down Expand Up @@ -148,7 +147,6 @@ export function registerTypes(serviceManager: IServiceManager) {
serviceManager.addSingleton<ITestTreeViewProvider>(ITestTreeViewProvider, TestTreeViewProvider);
serviceManager.addSingleton<ITestDataItemResource>(ITestDataItemResource, TestTreeViewProvider);
serviceManager.addSingleton<ITestExplorerCommandHandler>(ITestExplorerCommandHandler, TestExplorerCommandHandler);
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, TreeViewService);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
FailedTestHandler,
Expand Down
18 changes: 18 additions & 0 deletions src/client/testing/testController/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { TestController } from 'vscode';
/* eslint-disable */

// This is a place holder for a controller
export class PythonTestController implements TestController<any> {
public createWorkspaceTestRoot() {
return undefined;
}

public createDocumentTestRoot() {
return undefined;
}

public runTests() {}
}
68 changes: 0 additions & 68 deletions src/test/testing/explorer/treeView.unit.test.ts

This file was deleted.

Loading

0 comments on commit e72ccc0

Please sign in to comment.