Skeleton-Testkit

A comprehensive testing framework for skeleton-based applications
Skeleton-Testkit is a specialized testing framework designed to provide robust, containerized testing environments for applications built on the Skeleton Framework. It offers production-like testing scenarios, comprehensive verification strategies, and reusable testing infrastructure.
π― Purpose
The Skeleton-Testkit bridges the gap between unit testing and production deployment by providing:
- Container-First Testing: Realistic testing environments using Docker containers
- Skeleton-Aware Testing: Deep integration with skeleton component architecture
- Production-Like Scenarios: Testing that mirrors real-world deployment conditions
- Comprehensive Verification: Health monitoring, state verification, and behavior validation
- Developer Experience: Streamlined testing workflows and clear feedback
ποΈ Architecture Overview
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Skeleton-Testkit β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Testing Layer β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β
β β Verification β β Container β β Health β β
β β Strategies β β Management β β Monitoringβ β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Skeleton Framework β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β
β β Components β β Plugins β β Services β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Container Runtime β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β
β β Docker β β PostgreSQL β β Redis β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Quick Start
Prerequisites
Installation
# Clone the repository
git clone https://github.com/fintechain/skeleton-testkit.git
cd skeleton-testkit
# Setup development environment
make setup-dev
# Verify installation
make validate
Basic Usage
package main
import (
"context"
"testing"
"github.com/fintechain/skeleton-testkit/pkg/testkit"
"github.com/fintechain/skeleton-testkit/pkg/container"
)
func TestSkeletonApplication(t *testing.T) {
// Create a new testkit instance
tk := testkit.New(t)
defer tk.Cleanup()
// Start a skeleton application container
app, err := tk.StartSkeletonApp(context.Background(), &container.SkeletonConfig{
Image: "my-skeleton-app:latest",
Env: map[string]string{
"DATABASE_URL": "postgres://test:test@localhost:5432/testdb",
},
})
if err != nil {
t.Fatalf("Failed to start skeleton app: %v", err)
}
// Wait for application to be ready
if err := app.WaitForReady(context.Background()); err != nil {
t.Fatalf("Application failed to become ready: %v", err)
}
// Verify application behavior
verifier := tk.NewVerifier()
if err := verifier.VerifyHealthy(app); err != nil {
t.Fatalf("Health verification failed: %v", err)
}
// Test application functionality
response, err := app.HTTPClient().Get("/api/health")
if err != nil {
t.Fatalf("Health check failed: %v", err)
}
defer response.Body.Close()
if response.StatusCode != 200 {
t.Errorf("Expected status 200, got %d", response.StatusCode)
}
}
π Project Structure
skeleton-testkit/
βββ cmd/ # Command-line tools
β βββ testkit-cli/ # CLI for testkit operations
β βββ examples/ # Example applications
βββ pkg/ # Public API packages
β βββ testkit/ # Core testkit functionality
β βββ container/ # Container management
β βββ verification/ # Verification strategies
β βββ health/ # Health monitoring
βββ internal/ # Internal implementation
β βββ domain/ # Domain models and interfaces
β βββ infrastructure/ # Infrastructure implementations
β βββ adapters/ # External service adapters
βββ test/ # Test suites
β βββ integration/ # Integration tests
β βββ unit/ # Unit tests
β βββ fixtures/ # Test fixtures and data
βββ examples/ # Usage examples
β βββ basic/ # Basic usage examples
β βββ advanced/ # Advanced scenarios
β βββ benchmarks/ # Performance examples
βββ docs/ # Documentation
β βββ architecture/ # Architecture documentation
β βββ api/ # API documentation
β βββ guides/ # User guides
βββ deployments/ # Deployment configurations
β βββ docker/ # Docker configurations
β βββ k8s/ # Kubernetes manifests
βββ scripts/ # Build and utility scripts
βββ configs/ # Configuration files
βββ Makefile # Build automation
π οΈ Development
Available Make Targets
The project includes a comprehensive Makefile with organized targets:
# Show all available targets
make help
# Development workflow
make dev # Full development cycle
make setup-dev # Setup development environment
make test-watch # Run tests in watch mode
# Testing
make test # Run all tests
make test-unit # Unit tests only
make test-integration # Integration tests (requires Docker)
make test-performance # Performance benchmarks
make coverage # Generate coverage report
# Code quality
make lint # Run linter
make fmt # Format code
make vet # Run go vet
# CI/CD
make ci # Fast CI pipeline
make ci-integration # Full CI with integration tests
make validate # Quick validation
Testing Strategy
The testkit implements a comprehensive testing strategy:
Unit Tests
- Fast execution (< 30 seconds)
- No external dependencies
- High coverage of business logic
- Isolated components
make test-unit
Integration Tests
- Container-based testing environments
- Real database connections
- Network communication testing
- End-to-end scenarios
make test-integration
- Startup time benchmarks
- Resource usage monitoring
- Throughput measurements
- Scalability testing
make test-performance
Code Quality Standards
- Go fmt: Consistent code formatting
- Go vet: Static analysis for common errors
- golangci-lint: Comprehensive linting
- Test coverage: Minimum 80% coverage
- Documentation: Comprehensive godoc comments
π§ Configuration
Environment Variables
| Variable |
Description |
Default |
TESTKIT_LOG_LEVEL |
Logging level (debug, info, warn, error) |
info |
TESTKIT_TIMEOUT |
Default timeout for operations |
30s |
TESTKIT_DOCKER_HOST |
Docker daemon host |
unix:///var/run/docker.sock |
TESTKIT_CLEANUP_CONTAINERS |
Auto-cleanup containers after tests |
true |
TESTKIT_PARALLEL_TESTS |
Enable parallel test execution |
true |
Configuration Files
# configs/testkit.yaml
testkit:
timeout: 30s
log_level: info
docker:
host: unix:///var/run/docker.sock
cleanup: true
containers:
postgres:
image: postgres:15-alpine
env:
POSTGRES_DB: testdb
POSTGRES_USER: test
POSTGRES_PASSWORD: test
redis:
image: redis:7-alpine
π Documentation
Core Concepts
API Reference
Examples
π€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Make your changes
- Run tests (
make test)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Code Standards
- Follow Go Code Review Comments
- Write comprehensive tests for new features
- Update documentation for API changes
- Ensure all CI checks pass
Benchmarks
| Operation |
Duration |
Memory |
Allocations |
| Container Startup |
~2.5s |
45MB |
1,234 |
| Health Check |
~50ms |
2MB |
45 |
| Verification |
~100ms |
5MB |
123 |
| Cleanup |
~1s |
10MB |
234 |
Resource Requirements
- Memory: 512MB minimum, 2GB recommended
- CPU: 2 cores minimum, 4 cores recommended
- Disk: 10GB for container images and test data
- Network: Internet access for pulling container images
π Security
Security Considerations
- Container Isolation: Tests run in isolated Docker containers
- Network Security: Containers use isolated networks
- Credential Management: Test credentials are ephemeral
- Resource Limits: Containers have resource constraints
Reporting Security Issues
Please report security vulnerabilities to security@fintechain.com.
π Roadmap
Short-term (Q1 2024)
- Enhanced CI/CD integration
- Performance optimization
- Extended container support
- Improved documentation
Medium-term (Q2-Q3 2024)
- Kubernetes testing support
- Advanced verification strategies
- Monitoring and observability
- Plugin system
Long-term (Q4 2024+)
- Cloud provider integration
- Distributed testing
- AI-powered test generation
- Community ecosystem
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
π Support
Built with β€οΈ by the Fintechain Team