Add comprehensive BATS black box testing framework#38
Merged
justincampbell merged 14 commits intomainfrom Sep 24, 2025
Merged
Conversation
Move client initialization from init() to PersistentPreRun to ensure flags are parsed before creating the client. This fixes the --directory flag which was being ignored because the client was created with an empty directory string before flag parsing occurred. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add BATS test infrastructure with test_helper.bash utilities - Add Makefile with `make test` target for colored test output - Add 34 focused black box tests covering all core commands: - start.bats (7 tests) - command creation and file writing - finish.bats (6 tests) - completion and history management - clear.bats (4 tests) - current pomodoro removal - cancel.bats (5 tests) - cancellation without history - amend.bats (6 tests) - current pomodoro modification - repeat.bats (6 tests) - last pomodoro repetition Tests verify CLI behavior through actual command execution and file system assertions, providing end-to-end validation of the user experience. All tests use temporary directories for isolation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add hook testing infrastructure to test_helper.bash: - create_hook() - creates executable hook scripts - assert_hook_executed() - verifies hook execution - assert_hook_contains() - checks hook log contents - Add hooks.bats with 9 tests covering all hook scenarios: - start/stop hook execution for all commands - non-executable hook error handling - missing hook graceful handling - hook failure behavior - multiple hook sequence execution Total test coverage now: 43 comprehensive black box tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add status.bats (5 tests) - current pomodoro display and state - Add break.bats (3 tests) - break timer hook execution and validation - Add history.bats (5 tests) - history display and --limit flag functionality Complete black box test coverage: 56 tests across all CLI commands - Core workflow: start, finish, clear, cancel, amend, repeat (34 tests) - Hook system: comprehensive hook execution testing (9 tests) - Display commands: status and history output validation (10 tests) - Break command: timer and hook integration (3 tests) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Run BATS test suite on push and pull requests - Test on both Ubuntu and macOS platforms - Install BATS via package manager (apt/brew) - Execute full test suite with `make test` Ensures all 56 black box tests pass before merge and catches regressions across different environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1cabd42 to
d9d0644
Compare
When no --duration flag is provided, read DefaultPomodoroDuration from settings file instead of hardcoding 25 minutes. This restores the intended behavior that was broken by the --directory flag fix. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Download bats-core automatically if not installed, eliminating the need for users to install BATS separately. Includes clean target to remove downloaded BATS installation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add binary build target to Makefile that tracks Go source files - Use compiled binary instead of 'go run' in tests for better performance - Only rebuild when Go sources or module files change - Add pomodoro binary to .gitignore - Update clean target to remove binary 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Test coverage for: - Default pomodoro duration from settings - Default break duration from settings - Explicit duration flags overriding settings - --directory flag using settings from specified directory - Multiple settings values parsing - Fallback to 25 minute default when no settings 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add create_settings() helper that: - Accepts multiple setting key=value pairs as arguments - Optionally takes custom file path as first arg (if contains /) - Defaults to $TEST_DIR/settings - Makes multi-line settings more readable Updated all settings tests to use the new helper. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace magic path detection with two explicit functions: - create_settings: writes to $TEST_DIR/settings - create_settings_in <path>: writes to specified path This makes the intent clear without relying on / detection. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Remove manual BATS installation from GitHub Actions workflow. The Makefile now handles downloading BATS automatically, ensuring consistent versions across local dev and CI environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ensure all files end with a single newline character. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Removed duplicate 'cancel empties current file' test - Removed duplicate 'clear empties current file' test - Removed duplicate 'finish preserves description' test - Updated test names to include 'and' for combined assertions Reduced test count from 63 to 60 while maintaining coverage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--directoryflag was ignored due to initialization orderChanges
Bug Fix
--directoryflag initialization: Moved client creation frominit()toPersistentPreRunso flags are parsed before client instantiationTesting Framework
test_helper.bashwith utilities for file assertions and hook testingmake testcommand with colored outputCI/CD
make testTest Coverage
All tests use temporary directories for isolation and verify CLI behavior through actual command execution and file system assertions. The framework successfully discovered and helped fix the
--directoryflag bug.Example Test
🤖 Generated with Claude Code