Skip to content

[Feature] Add unit tests for StartLogCatMonitor command #2789

Description

@ConnorQi01

Summary

The StartLogCatMonitor command (src/extension/commands/startLogCatMonitor.ts) has no dedicated unit tests. Its counterpart StopLogCatMonitor just received full test coverage (via the recent stopLogCatMonitor.test.ts addition), but the start-side command is still untested.

Why this is useful

StartLogCatMonitor contains multiple distinct branches — no online device found, a valid target selected, and previous monitor cleanup before starting a new one — that can silently regress. Unit tests would catch those regressions early, consistent with the test coverage pattern being established across other commands.

Suggested scope

  • Add est/extension/commands/startLogCatMonitor.test.ts using proxyquire to stub AndroidTargetManager, LogCatMonitorManager, SettingsHelper, and �scode.window.showErrorMessage
  • Cover: no target returned (null) → error message shown, no monitor created; valid target → delMonitor called first, new monitor started; logCatArguments passed through from settings

Evidence

  • src/extension/commands/startLogCatMonitor.ts — three testable paths: arget === undefined early-return, LogCatMonitorManager.delMonitor(target.id) call, and logCatMonitor.start()
  • est/extension/commands/stopLogCatMonitor.test.ts — existing pattern to follow (proxyquire, stub-based, no vscode runtime needed)
  • No existing issue found for this command's test coverage

Validation

pm test unit suite passes with new test file included

  • All three branches exercised with Sinon stubs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions