Claude Code Testing
This directory contains resources for testing the Claude Code plugin.
Overview
Claude Code Testing
This directory contains resources for testing the Claude Code plugin.
Overview
There are two main components:
- Automated Tests: Unit and integration tests using the Plenary test framework.
- Manual Testing: A minimal configuration for reproducing issues and testing features.
Test Coverage
The automated test suite covers the following components of the Claude Code plugin:
-
Core Functionality
- Plugin initialization and setup
- Command registration and execution
- Version reporting and management
-
Terminal Integration
- Terminal window creation and toggling
- Terminal positioning and configuration
- Insert mode management
-
Git Integration
- Git root detection and handling
- Error handling for non-git directories
-
Configuration
- Config validation for all settings
- Default config values
- Config merging with user-provided options
-
Keymaps
- Normal mode toggle keybindings
- Terminal mode toggle keybindings
- Window navigation keybindings
-
File Refresh
- Auto-refresh functionality
- Timer management
- Updatetime handling
The test suite currently contains 44 tests covering all major components of the plugin.
Minimal Test Configuration
The minimal-init.lua file provides a minimal Neovim configuration for testing the Claude Code plugin in isolation. This standardized initialization file (recently renamed from minimal_init.lua to match conventions used across related Neovim projects) is useful for:
- Reproducing and debugging issues
- Testing new features in a clean environment
- Providing minimal reproducible examples when reporting bugs
Usage
Option 1: Run directly from the plugin directory
# From the plugin root directory
nvim --clean -u tests/minimal-init.lua
Option 2: Copy to a separate directory for testing
# Create a test directory
mkdir ~/claude-test
cp tests/minimal-init.lua ~/claude-test/
cd ~/claude-test
# Run Neovim with the minimal config
nvim --clean -u minimal-init.lua
Automated Tests
The spec/ directory contains automated tests for the plugin using the plenary.busted framework.
Test Structure
The test suite is organized by module and functionality:
command_registration_spec.lua: Tests for command registrationconfig_spec.lua: Tests for configuration parsingconfig_validation_spec.lua: Tests for configuration validationcore_integration_spec.lua: Tests for core plugin integrationfile_refresh_spec.lua: Tests for file refresh functionalitygit_spec.lua: Tests for git integrationkeymaps_spec.lua: Tests for keybinding functionalityterminal_spec.lua: Tests for terminal integrationversion_spec.lua: Tests for version handling
Running Tests
Run all automated tests using:
./scripts/test.sh
You'll see a summary of the test results like:
==== Test Results ====
Total Tests Run: 44
Successes: 44
Failures: 0
Errors: 0
=====================
Writing Tests
Test files should follow the plenary.busted structure:
local assert = require('luassert')
local describe = require('plenary.busted').describe
local it = require('plenary.busted').it
describe('module_name', function()
describe('function_name', function()
it('should do something', function()
-- Test code here
assert.are.equal(expected, actual)
end)
end)
end)
Troubleshooting
The minimal configuration:
- Attempts to auto-detect the plugin directory
- Sets up basic Neovim settings (no swap files, etc.)
- Prints available commands for reference
- Shows line numbers and sign column
To see error messages:
:messages
Reporting Issues
When reporting issues, please include the following information:
- Steps to reproduce the issue using this minimal config
- Any error messages from
:messages - The exact Neovim and Claude Code plugin versions