Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/client/testing/testController/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
// LEGACY MODE: Single WorkspaceTestAdapter per workspace (backward compatibility)
workspaces.forEach((workspace) => {
this.activateLegacyWorkspace(workspace);
void this.refreshTestData(workspace.uri);
});
this.disposables.push(
this.workspaceService.onDidChangeWorkspaceFolders((evt) => {
Expand Down
32 changes: 32 additions & 0 deletions src/test/testing/testController/controller.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,40 @@ suite('PythonTestController', () => {
pythonExecFactory,
debugLauncher,
envVarsService,


);
}
test('discovers tests for existing workspace during activation', async () => {
const workspaceUri = vscode.Uri.file('/workspace');
const workspaceFolder = {
uri: workspaceUri,
name: 'workspace',
index: 0,
} as vscode.WorkspaceFolder;

sandbox.stub(envExtApiInternal, 'useEnvExtension').returns(false);

const discoveryAdapter = {
discoverTests: sandbox.stub().resolves(undefined),
};

sandbox.stub(projectUtils, 'createTestAdapters').returns({
discoveryAdapter,
executionAdapter: {},
} as any);

const controller = createController({
workspaceService: {
workspaceFolders: [workspaceFolder],
},
});

await controller.activate();
await new Promise((resolve) => setTimeout(resolve, 350));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info · Optional note

Replace the fixed 350 ms sleep with fake timers or an observable completion signal. The current assertion is timing-sensitive under load and couples the test to the refresh debounce duration.


assert.strictEqual(discoveryAdapter.discoverTests.calledOnce, true);
});

suite('getTestProvider', () => {
test('returns unittest when enabled', () => {
Expand Down
Loading