Skip to content

Conversation

Copy link

Copilot AI commented Dec 1, 2025

Refactors controller.ts to break down monolithic methods into focused helper methods, reducing nesting depth and eliminating duplication between pytest/unittest code paths.

Changes

  • Discovery flow: Split refreshTestDataInternal into:

    • refreshSingleWorkspace() - single workspace discovery
    • refreshAllWorkspaces() - multi-workspace orchestration
    • discoverTestsForProvider() - provider-specific discovery with validation
    • handleNoTestProviderEnabled() - disabled state handling
    • removeTestItemsForWorkspace() - cleanup helper
  • Execution flow: Split runTests into:

    • getWorkspacesForTestRun() - workspace selection from request
    • runTestsForWorkspace() - single workspace execution
    • getTestItemsForWorkspace() - test item filtering
    • setupCoverageIfNeeded() - coverage profile configuration
    • executeTestsForProvider() - unified pytest/unittest execution

Example

Before (deeply nested, duplicated):

if (settings.testing.pytestEnabled) {
    if (workspace && workspace.uri) {
        const testAdapter = this.testAdapters.get(workspace.uri);
        if (testAdapter) {
            // pytest-specific logic
        }
    }
} else if (settings.testing.unittestEnabled) {
    // nearly identical block for unittest
}

After:

if (settings.testing.pytestEnabled) {
    await this.discoverTestsForProvider(workspace.uri, 'pytest');
} else if (settings.testing.unittestEnabled) {
    await this.discoverTestsForProvider(workspace.uri, 'unittest');
}
Original prompt

Fantastic! I love this plan! Now go an execute the switch to the new design

Created from VS Code via the GitHub Pull Request extension.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Execute switch to the new design Refactor test controller for improved modularity and clarity Dec 1, 2025
Copilot AI requested a review from eleanorjboyd December 1, 2025 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants