Expand description
§TestProvider (Environment)
RESPONSIBILITIES:
- Implements
TestControllerforMountainEnvironment - Manages test discovery, execution, and result reporting
- Handles test controller registration and lifecycle
- Tracks test run progress and aggregates results
- Provides sidecar proxy for extension-provided test frameworks
ARCHITECTURAL ROLE:
- Environment provider for testing functionality
- Uses controller pattern: each extension can register its own test controller
- Controllers identified by unique
ControllerIdentifierand scoped to extensions - Integrates with
IPCProviderfor RPC to test runners - Stores controller state in
ApplicationState
TEST EXECUTION FLOW:
- Extension registers test controller via
RegisterTestController - Mountain calls
ResolveTeststo discover tests (async, emitsTestItemAdded) - Extension returns test tree structure with IDs, labels, children
- UI requests to run tests via
RunTestorRunTestswith optionalRunProfile - Mountain forwards to extension’s controller via RPC
- Extension executes tests and reports progress via
TestRunStarted,TestItemStarted,TestItemPassed,TestItemFailed,TestRunEndedevents - Mountain aggregates results and emits to UI
ERROR HANDLING:
- Uses
CommonErrorfor all operations - Validates controller identifiers and run profile names (non-empty)
- Controller state tracked in RwLock for thread-safe mutation
- Unknown controller ID errors return
TestControllerNotFound - Duplicate registration returns
InvalidArgumenterror
PERFORMANCE:
- Test discovery is async and can be cancelled (drop sender)
- Test run progress is streamed via events, avoiding blocking
- Controller state uses RwLock for concurrent read access during test runs
- TODO: Consider test result caching for quick re-runs
VS CODE REFERENCE:
vs/workbench/contrib/testing/common/testService.ts- test service architecturevs/workbench/contrib/testing/common/testController.ts- test controller interfacevs/workbench/contrib/testing/common/testTypes.ts- test data modelsvs/workbench/contrib/testing/browser/testingView.ts- testing UI panel
TODO:
- Implement test run cancellation and timeout handling
- Add test result caching and quick re-run support
- Implement test tree filtering and search
- Add test run configuration persistence
- Support test run peeking (inline results in editor)
- Implement test coverage integration
- Add test run duration metrics and profiling
- Support parallel test execution (multiple workers)
- Implement test run retry logic for flaky tests
- Add test run export (JUnit, TAP, custom formats)
- Integrate with CodeLens for in-source test run buttons
MODULE CONTENTS:
TestControllerimplementation:RegisterTestController- register extension’s controllerUnregisterTestController- remove controllerResolveTests- discover tests (async with cancellation)RunTest- run single test by IDRunTests- run multiple tests (by ID or all in parent)StopTestRun- cancel ongoing test runDidTestItemDiscoveryStart- discovery progress eventTestRunStarted/TestItemStarted/TestItemPassed/TestItemFailed/TestRunEnded- events
- Data types:
TestControllerState,TestItemState,TestRunProfile,TestResultState
Structs§
- Test
Controller 🔒State - Represents a test controller’s state
- Test
Provider State - Stores test provider state
- Test
Result 🔒 - Represents a test result
- TestRun 🔒
- Represents an active test run
Enums§
- Test
RunStatus 🔒 - Represents the status of a test run