Module TestProvider

Module TestProvider 

Source
Expand description

§TestProvider (Environment)

RESPONSIBILITIES:

  • Implements TestController for MountainEnvironment
  • 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 ControllerIdentifier and scoped to extensions
  • Integrates with IPCProvider for RPC to test runners
  • Stores controller state in ApplicationState

TEST EXECUTION FLOW:

  1. Extension registers test controller via RegisterTestController
  2. Mountain calls ResolveTests to discover tests (async, emits TestItemAdded)
  3. Extension returns test tree structure with IDs, labels, children
  4. UI requests to run tests via RunTest or RunTests with optional RunProfile
  5. Mountain forwards to extension’s controller via RPC
  6. Extension executes tests and reports progress via TestRunStarted, TestItemStarted, TestItemPassed, TestItemFailed, TestRunEnded events
  7. Mountain aggregates results and emits to UI

ERROR HANDLING:

  • Uses CommonError for 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 InvalidArgument error

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 architecture
  • vs/workbench/contrib/testing/common/testController.ts - test controller interface
  • vs/workbench/contrib/testing/common/testTypes.ts - test data models
  • vs/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:

  • TestController implementation:
  • RegisterTestController - register extension’s controller
  • UnregisterTestController - remove controller
  • ResolveTests - discover tests (async with cancellation)
  • RunTest - run single test by ID
  • RunTests - run multiple tests (by ID or all in parent)
  • StopTestRun - cancel ongoing test run
  • DidTestItemDiscoveryStart - discovery progress event
    • TestRunStarted/TestItemStarted/TestItemPassed/TestItemFailed/ TestRunEnded - events
  • Data types: TestControllerState, TestItemState, TestRunProfile, TestResultState

Structs§

TestControllerState 🔒
Represents a test controller’s state
TestProviderState
Stores test provider state
TestResult 🔒
Represents a test result
TestRun 🔒
Represents an active test run

Enums§

TestRunStatus 🔒
Represents the status of a test run