README
¶
Taskw End-to-End Tests
This directory contains comprehensive end-to-end tests for Taskw that verify the complete workflows developers will experience when using the tool.
Test Cases
1. Project Initialization (01_init_test.go)
Scenario: Developer creates a new Taskw project from scratch
Test Steps:
- Run
taskw initwith a Go module path - Verify all scaffolded files are created correctly
- Check go.mod has correct module and dependencies
- Validate taskw.yaml configuration
- Verify health handler template content
- Check .taskwignore patterns
- Ensure
go mod tidyworks - Verify project has correct structure and compiles
Expected Outcome: A fully functional Taskw project ready for development
2. Adding New Dependency (02_dependency_test.go)
Scenario: Developer adds a new service with provider functions
Test Steps:
- Start with initialized project
- Add new notification service module with multiple providers
- Run
taskw scanto detect new providers - Generate dependencies to include new providers
- Generate routes for new handlers
- Update server struct to include new handlers
- Run wire generation
- Verify project still compiles
Expected Outcome: New providers are automatically detected and included in dependency injection
3. Adding New Route (03_route_test.go)
Scenario: Developer adds new handler methods with @Router annotations
Test Steps:
- Start with project + basic user service
- Create initial handler with 2 routes
- Generate initial routes
- Add 4 new handler methods with @Router annotations
- Scan to detect new routes
- Regenerate routes
- Verify route ordering and conflict resolution
- Update server to include handlers
- Verify project builds with new routes
Expected Outcome: New routes are automatically detected and added to route registration
Running the Tests
Prerequisites
# Build Taskw binary
cd /path/to/taskw
go build -o bin/taskw cmd/taskw/main.go
# Ensure Go and basic tools are installed
go version # Should be Go 1.21+
Run All E2E Tests
cd test/e2e
go test -v ./...
Run Specific Test
cd test/e2e
go test -v -run TestProjectInitialization
go test -v -run TestAddingNewDependency
go test -v -run TestAddingNewRoute
Run with Verbose Output
cd test/e2e
go test -v -run TestProjectInitialization 2>&1 | tee init_test.log
Test Environment
Each test creates its own temporary directory under /tmp/taskw-e2e-*-test and cleans up automatically. Tests are designed to be:
- Isolated: Each test runs in its own directory
- Self-contained: No dependencies on external services
- Fast: Focus on critical path verification
- Comprehensive: Cover the major user workflows
Expected Test Results
Successful Run Example
=== RUN TestProjectInitialization
=== RUN TestProjectInitialization/01_initialize_project
01_init_test.go:45: ✅ Project directory created: /tmp/taskw-e2e-init-test/e2e-init-project
=== RUN TestProjectInitialization/02_verify_scaffolded_files
01_init_test.go:60: ✅ File exists: cmd/server/main.go
01_init_test.go:60: ✅ File exists: internal/api/server.go
01_init_test.go:60: ✅ File exists: internal/api/wire.go
# ... more verification steps
=== RUN TestProjectInitialization/08_project_compiles
01_init_test.go:180: ✅ Build issues are related to missing RegisterRoutes method (expected)
--- PASS: TestProjectInitialization (2.34s)
Troubleshooting
Test Failures
"Could not find taskw binary"
# Ensure taskw is built
go build -o bin/taskw cmd/taskw/main.go
"go mod tidy failed"
# Check Go version and module setup
go version
go env GOMOD
"Wire generation failed"
# Install wire (optional for tests)
go install github.com/google/wire/cmd/wire@latest
Debug Mode
Set environment variable for more detailed output:
export TASKW_E2E_DEBUG=1
go test -v ./...
Adding New E2E Tests
When adding new test scenarios:
- Create new file:
XX_feature_test.go - Follow naming:
TestFeatureName - Use subtests: Break into logical steps
- Clean up: Use
defer os.RemoveAll(testDir) - Verify thoroughly: Check generated files, compilation, functionality
- Document: Add to this README
Test Template
func TestNewFeature(t *testing.T) {
// Setup
testDir := filepath.Join(os.TempDir(), "taskw-e2e-feature-test")
defer os.RemoveAll(testDir)
t.Run("01_setup", func(t *testing.T) {
// Test setup
})
t.Run("02_main_functionality", func(t *testing.T) {
// Core test logic
})
t.Run("03_verification", func(t *testing.T) {
// Verify expected outcomes
})
t.Logf("✅ Feature e2e test completed successfully")
}
This ensures consistency and maintainability across all e2e tests.
Documentation
¶
There is no documentation for this package.