Nm Sanctum Test Updates
by @athola
Updates, generates, and validates tests using git-workspace context and TDD/BDD methodology
clawhub install nm-sanctum-test-updatesπ About This Skill
name: test-updates description: | Update, generate, and validate tests using git-workspace-review for change context version: 1.9.4 triggers: - tdd - bdd - testing - quality-assurance - test-generation - pytest metadata: {"openclaw": {"homepage": "https://github.com/athola/claude-night-market/tree/master/plugins/sanctum", "emoji": "\ud83e\udd9e", "requires": {"config": ["night-market.test-driven-development", "night-market.git-workspace-review", "night-market.file-analysis"]}}} source: claude-night-market source_plugin: sanctum
> Night Market Skill β ported from claude-night-market/sanctum. For the full experience with agents, hooks, and commands, install the Claude Code plugin.
Table of Contents
Test Updates and Maintenance
Overview
detailed test management system that applies TDD/BDD principles to maintain, generate, and enhance tests across codebases. This skill practices what it preaches - it uses TDD principles for its own development and serves as a living example of best practices.
Core Philosophy
What It Is
A modular test management system that:
Quick Start
Quick Checklist for First Time Use
pip install pytest)src/ or similar directorytests/ directory if it doesn't existSkill(sanctum:git-workspace-review) first to understand changesSkill(test-updates) --target for focused updatesdetailed Test Update
# Run full test update workflow
Skill(test-updates)
Verification: Run pytest -v to verify tests pass.Targeted Test Updates
# Update tests for specific paths
Skill(test-updates) --target src/sanctum/agents
Skill(test-updates) --target tests/test_commit_messages.py
Verification: Run pytest -v to verify tests pass.TDD for New Features
# Apply TDD to new code
Skill(test-updates) --tdd-only --target new_feature.py
Verification: Run pytest -v to verify tests pass.Using the Scripts Directly
Human-Readable Output:
# Analyze test coverage gaps
python plugins/sanctum/scripts/test_analyzer.py --scan src/Generate test scaffolding
python plugins/sanctum/scripts/test_generator.py \
--source src/my_module.py --style pytest_bddCheck test quality
python plugins/sanctum/scripts/quality_checker.py \
--validate tests/test_my_module.py
Verification: Run pytest -v to verify tests pass.Programmatic Output (for Claude Code):
# Get JSON output for programmatic parsing - test_analyzer
python plugins/sanctum/scripts/test_analyzer.py \
--scan src/ --output-jsonReturns:
{
"success": true,
"data": {
"source_files": ["src/module.py", ...],
"test_files": ["tests/test_module.py", ...],
"uncovered_files": ["module_without_tests", ...],
"coverage_gaps": [{"file": "...", "reason": "..."}]
}
}
Get JSON output - test_generator
python plugins/sanctum/scripts/test_generator.py \
--source src/my_module.py --output-jsonReturns:
{
"success": true,
"data": {
"test_file": "path/to/test_my_module.py",
"source_file": "src/my_module.py",
"style": "pytest_bdd",
"fixtures_included": true,
"edge_cases_included": true,
"error_cases_included": true
}
}
Get JSON output - quality_checker
python plugins/sanctum/scripts/quality_checker.py \
--validate tests/test_my_module.py --output-jsonReturns:
{
"success": true,
"data": {
"static_analysis": {...},
"dynamic_validation": {...},
"metrics": {...},
"quality_score": 85,
"quality_level": "QualityLevel.GOOD",
"recommendations": [...]
}
}
Verification: Run pytest -v to verify tests pass.When To Use It
Use this skill when you need to:
Perfect for:
When NOT To Use
Workflow Integration
Phase 1: Discovery
1. Scan codebase for test gaps 2. Analyze recent changes 3. Identify broken or outdated testsSee modules/test-discovery.md for detection patterns.
Phase 2: Strategy
1. Choose appropriate BDD style (seemodules/bdd-patterns.md)
2. Plan test structure
3. Define quality criteriaPhase 3: Implementation
1. Write failing tests (RED) - seemodules/tdd-workflow.md
2. Implement minimal passing code (GREEN)
3. Refactor for clarity (REFACTOR)See modules/test-generation.md for generation templates.
Phase 4: Validation
1. Static analysis and linting 2. Dynamic test execution 3. Coverage and quality metricsSee modules/quality-validation.md for validation criteria.
Quality Assurance
The skill applies multiple quality checks:
Examples
BDD-Style Test Generation
See modules/bdd-patterns.md for additional patterns.
class TestGitWorkflow:
"""BDD-style tests for Git workflow operations.""" def test_commit_workflow_with_staged_changes(self):
"""
GIVEN a Git repository with staged changes
WHEN the user runs the commit workflow
THEN it should create a commit with proper message format
AND all tests should pass
"""
# Test implementation following TDD principles
pass
Verification: Run pytest -v to verify tests pass.Test Enhancement
See modules/test-enhancement.md for enhancement strategies.
Integration with Existing Skills
1. git-workspace-review: Get context of changes 2. file-analysis: Understand code structure 3. test-driven-development: Apply strict TDD discipline 4. skills-eval: Validate quality and compliance
Success Metrics
Troubleshooting FAQ
Common Issues
Q: Tests are failing after generation A: This is expected! The skill follows TDD principles - generated tests are designed to fail first. Follow the RED-GREEN-REFACTOR cycle: 1. Run the test and confirm it fails for the right reason 2. Implement minimal code to make it pass 3. Refactor for clarity
Q: Quality score is low despite having tests A: Check for these common issues:
assert result is not NoneQ: Generated tests don't match my code structure A: The scripts analyze AST patterns and may need guidance:
--style flag to match your preferred BDD styleQ: Mutation testing takes too long A: Mutation testing is resource-intensive:
--quick-mutation flag for subset testingQ: Can't find tests for my file A: The analyzer uses naming conventions:
my_module.py β Test: test_my_module.pyPerformance Tips
--target to focus on specific directoriesGetting Help
1. Check script outputs for detailed error messages
2. Use --verbose flag for more information
3. Review the validation report for specific recommendations
4. Start with small modules to understand patterns before scaling
π‘ Examples
BDD-Style Test Generation
See modules/bdd-patterns.md for additional patterns.
class TestGitWorkflow:
"""BDD-style tests for Git workflow operations.""" def test_commit_workflow_with_staged_changes(self):
"""
GIVEN a Git repository with staged changes
WHEN the user runs the commit workflow
THEN it should create a commit with proper message format
AND all tests should pass
"""
# Test implementation following TDD principles
pass
Verification: Run pytest -v to verify tests pass.Test Enhancement
See modules/test-enhancement.md for enhancement strategies.