Skip to content

[Feature] Add unit tests for StartLogCatMonitor command #2827

Description

@ConnorQi01

Summary

StartLogCatMonitor has no dedicated unit tests. The command covers three meaningful code paths: no device found (shows error message), device found (stops any previous monitor and starts a new one), and LogCat start failure (logs a warning). Its counterpart StopLogCatMonitor already has comprehensive tests; adding tests here completes the LogCat monitor lifecycle coverage.

Why this is useful

A regression in target selection, monitor replacement, or error propagation would silently break the Android LogCat workflow. The current test suite guards StopLogCatMonitor but leaves the start path untested.

Suggested scope

  • Add test/extension/commands/startLogCatMonitor.test.ts using the proxyquire + sinon pattern from stopLogCatMonitor.test.ts.
  • Stub AndroidTargetManager, LogCatMonitorManager, LogCatMonitor, SettingsHelper, TipNotificationService, OutputChannelLogger, and vscode.window.showErrorMessage.
  • Test: selectAndPrepareTarget returns nullshowErrorMessage called, monitor not started.
  • Test: selectAndPrepareTarget returns a target → delMonitor called for previous, new monitor created and start() invoked.
  • Test: logCatMonitor.start() rejects → warning logged, no error thrown from baseFn.

Evidence

Validation

  • Run npm run build.
  • Run npm test and confirm the new suite passes.
  • startLogCatMonitor scenarios: no-device, device-found, start-error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions