Skip to content

[Test Improver] test: expand unit tests for list command (42% -> 100%)#444

Merged
danielmeppiel merged 4 commits intomainfrom
test-assist/list-cmd-coverage-23519877749-2817668d6a8edeee
Apr 2, 2026
Merged

[Test Improver] test: expand unit tests for list command (42% -> 100%)#444
danielmeppiel merged 4 commits intomainfrom
test-assist/list-cmd-coverage-23519877749-2817668d6a8edeee

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver - automated AI assistant

Goal and Rationale

list_cmd.py is user-facing (shows available scripts to developers) but was only 42% covered. The untested paths included the "no scripts found" case, the Rich table rendering branch, and exception handling. These are all exercised regularly by users.

Approach

Extended the existing tests/unit/test_list_command.py (which had 1 test) with 12 additional tests covering:

  • No scripts: warning shown, rich panel attempted → fallback on ImportError / NameError
  • Scripts found + console available: Rich table rendered, start annotated as default
  • Scripts found + no console: plain-text fallback with all script names
  • Rich table raises: fallback to plain text
  • No start script: no "default script" annotation
  • Exception in _list_available_scripts: sys.exit(1) and error message shown

Coverage Impact

File Before After
src/apm_cli/commands/list_cmd.py 42% (23/55 lines) 100% (55/55)

Test Status

All 3041 unit tests pass:

uv run pytest tests/unit/ tests/test_console.py --no-header -q
3041 passed in 13.36s

Reproducibility

# Run just the new tests
uv run pytest tests/unit/test_list_command.py -v

# Coverage
uv run pytest tests/unit/test_list_command.py --cov=apm_cli.commands.list_cmd --cov-report=term-missing

Generated by Daily Test Improver ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@b87234850bf9664d198f28a02df0f937d0447295

Add 12 new tests covering list_cmd.py paths previously untested:
- No scripts found: warning shown with rich panel + fallback (ImportError/NameError)
- Scripts found: rich table rendered with default 'start' annotation
- Scripts found: fallback text when no console or rich raises
- Multiple scripts all shown in fallback
- Exception handling: sys.exit(1) with error message

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danielmeppiel danielmeppiel marked this pull request as ready for review April 2, 2026 12:31
Copilot AI review requested due to automatic review settings April 2, 2026 12:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands unit test coverage for the user-facing apm list command to exercise previously untested output branches (no scripts, Rich vs fallback rendering, and error handling), improving confidence in CLI behavior.

Changes:

  • Add comprehensive unit tests for empty-script behavior, including Rich panel attempt and fallback paths.
  • Add tests for script listing with/without a default (start) script across Rich and non-Rich output paths.
  • Add tests for exception handling to ensure failures exit with code 1 and emit an error message.

Comment thread tests/unit/test_list_command.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@danielmeppiel danielmeppiel merged commit 140a23b into main Apr 2, 2026
6 checks passed
@danielmeppiel danielmeppiel deleted the test-assist/list-cmd-coverage-23519877749-2817668d6a8edeee branch April 2, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants