goca test-integration
Generate integration test scaffolding for a named entity. The generated tests exercise the full request-to-database stack in a temporary test environment.
Syntax
bash
goca test-integration <EntityName> [flags]Description
goca test-integration creates an integration test file under internal/testing/tests/ that:
- Spins up an in-memory or test database
- Runs the full use-case and repository stack
- Provides HTTP request helpers when a handler is present
- Uses
testify/suitefor setup and teardown lifecycle
Flags
--dry-run
Preview the files that would be created without writing anything to disk.
bash
goca test-integration Product --dry-run--force
Overwrite existing integration test files.
bash
goca test-integration Product --force--backup
Back up existing test files to .goca-backup/ before overwriting.
bash
goca test-integration Product --backupExamples
Generate integration tests for one entity
bash
goca test-integration OrderPreview without writing
bash
goca test-integration Order --dry-runGenerated Files
| File | Description |
|---|---|
internal/testing/tests/order_integration_test.go | Full integration test suite |
Generated Code Example
go
// Code generated by goca. DO NOT EDIT by hand.
package tests
import (
"testing"
"github.com/stretchr/testify/suite"
)
type OrderIntegrationSuite struct {
suite.Suite
// db, repo, usecase, handler fields
}
func (s *OrderIntegrationSuite) SetupSuite() { /* setup test DB */ }
func (s *OrderIntegrationSuite) TearDownSuite() { /* cleanup */ }
func TestOrderIntegration(t *testing.T) {
suite.Run(t, new(OrderIntegrationSuite))
}Related Commands
goca feature— generate all layers including integration tests via--integration-testsflaggoca mocks— generate unit test mocks for the same entity