🎯 Areas for Improvement
1. Testify Assertions
The entire file uses plain Go t.Errorf / t.Error instead of testify, which is the project standard.
Current Issues (examples from file):
// ❌ CURRENT
if err != nil {
t.Errorf("Expected to find claude engine, got error: %v", err)
}
if claudeEngine.GetID() != "claude" {
t.Errorf("Expected claude engine ID, got '%s'", claudeEngine.GetID())
}
if registry.IsValidEngine("nonexistent") {
t.Error("Expected nonexistent to be invalid engine")
}
_, err = registry.GetEngine("nonexistent")
if err == nil {
t.Error("Expected error when getting non-existent engine")
}
Recommended Changes:
// ✅ IMPROVED
claudeEngine, err := registry.GetEngine("claude")
require.NoError(t, err, "GetEngine('claude') should succeed")
assert.Equal(t, "claude", claudeEngine.GetID(), "engine ID should match")
assert.False(t, registry.IsValidEngine("nonexistent"), "nonexistent engine should be invalid")
_, err = registry.GetEngine("nonexistent")
assert.Error(t, err, "GetEngine('nonexistent') should return an error")
Why this matters: Testify's require.NoError stops the test immediately on failure, preventing a nil-pointer panic on the next line. assert.* provides cleaner, more readable output in CI logs.
2. Table-Driven Tests
The file contains repetitive patterns for checking multiple engine IDs that are ideal candidates for table-driven tests.
Current Issues:
// Repeated pattern for every engine
claudeEngine, err := registry.GetEngine("claude")
if err != nil { t.Errorf(...) }
if claudeEngine.GetID() != "claude" { t.Errorf(...) }
codexEngine, err := registry.GetEngine("codex")
if err != nil { t.Errorf(...) }
if codexEngine.GetID() != "codex" { t.Errorf(...) }
Recommended Changes:
// ✅ Table-driven for per-engine checks
engines := []string{"claude", "codex", "copilot", "gemini", "opencode", "crush"}
for _, id := range engines {
t.Run("engine/"+id, func(t *testing.T) {
engine, err := registry.GetEngine(id)
require.NoError(t, err, "GetEngine(%q) should succeed", id)
assert.Equal(t, id, engine.GetID(), "engine ID should match requested ID")
assert.True(t, registry.IsValidEngine(id), "IsValidEngine(%q) should be true", id)
})
}
3. Test Coverage Gaps
The following exported methods/functions have no test coverage:
| Method |
Why it matters |
Register |
Core registry mutation — should verify custom engines can be added and retrieved |
GetAllAgentManifestFolders |
Returns filesystem paths used at runtime — should verify non-nil/non-empty |
GetAllAgentManifestFiles |
Same as above |
GetGlobalEngineRegistry |
Singleton accessor — should verify it returns a valid, non-nil registry with all engines |
Recommended new test:
func TestEngineRegistry_Register(t *testing.T) {
registry := NewEngineRegistry()
initialCount := len(registry.GetSupportedEngines())
// Register a custom engine
// (mock or minimal CodingAgentEngine implementation)
// ...
assert.Len(t, registry.GetSupportedEngines(), initialCount+1,
"registry should contain the newly registered engine")
}
func TestGetGlobalEngineRegistry(t *testing.T) {
registry := GetGlobalEngineRegistry()
require.NotNil(t, registry, "global registry should not be nil")
assert.NotEmpty(t, registry.GetSupportedEngines(),
"global registry should have at least one engine")
}
func TestEngineRegistry_GetAllAgentManifestFiles(t *testing.T) {
registry := NewEngineRegistry()
files := registry.GetAllAgentManifestFiles()
assert.NotNil(t, files, "manifest files slice should not be nil")
}
4. Test Organization — Single Monolithic Test
The current TestEngineRegistry function tests 7 different behaviours in a single function. This makes it hard to tell which assertion failed and why.
Recommended: Split into t.Run subtests:
func TestEngineRegistry(t *testing.T) {
t.Run("built-in engines are registered", func(t *testing.T) { ... })
t.Run("get engine by ID succeeds", func(t *testing.T) { ... })
t.Run("get non-existent engine returns error", func(t *testing.T) { ... })
t.Run("IsValidEngine", func(t *testing.T) { ... })
t.Run("default engine is copilot", func(t *testing.T) { ... })
t.Run("GetEngineByPrefix matches prefix", func(t *testing.T) { ... })
t.Run("GetEngineByPrefix no match returns error", func(t *testing.T) { ... })
}
5. Missing Assertion Messages
Most assertions lack context messages, making CI output hard to parse.
// ❌ No context on failure
if !found { t.Errorf("Expected engine '%s' to be registered", engineID) }
// ✅ testify with context
assert.True(t, found, "engine %q should be registered in the default registry", engineID)
The test file
pkg/workflow/agentic_engine_test.gohas been selected for quality improvement by the Testify Uber Super Expert. This issue provides specific, actionable recommendations to enhance test quality using testify best practices.Current State
pkg/workflow/agentic_engine_test.gopkg/workflow/agentic_engine.goTestEngineRegistry)Register,GetAllAgentManifestFolders,GetAllAgentManifestFiles,GetGlobalEngineRegistryTest Quality Analysis
Strengths ✅
EngineRegistryNewEngineRegistry()🎯 Areas for Improvement
1. Testify Assertions
The entire file uses plain Go
t.Errorf/t.Errorinstead of testify, which is the project standard.Current Issues (examples from file):
Recommended Changes:
Why this matters: Testify's
require.NoErrorstops the test immediately on failure, preventing a nil-pointer panic on the next line.assert.*provides cleaner, more readable output in CI logs.2. Table-Driven Tests
The file contains repetitive patterns for checking multiple engine IDs that are ideal candidates for table-driven tests.
Current Issues:
Recommended Changes:
3. Test Coverage Gaps
The following exported methods/functions have no test coverage:
RegisterGetAllAgentManifestFoldersGetAllAgentManifestFilesGetGlobalEngineRegistryRecommended new test:
4. Test Organization — Single Monolithic Test
The current
TestEngineRegistryfunction tests 7 different behaviours in a single function. This makes it hard to tell which assertion failed and why.Recommended: Split into
t.Runsubtests:5. Missing Assertion Messages
Most assertions lack context messages, making CI output hard to parse.
📋 Implementation Guidelines
Priority Order
t.Errorf/t.Errorwithrequire.*/assert.*TestGetGlobalEngineRegistry(global singleton is runtime-critical)TestEngineRegistryintot.RunsubtestsRegister,GetAllAgentManifestFolders,GetAllAgentManifestFilesBest Practices from
scratchpad/testing.mdrequire.*for setup that must not fail (e.g.,GetEngine)assert.*for property checks (e.g., ID equality, bool flags)t.Run()and descriptive namesTesting Commands
Acceptance Criteria
t.Error/t.Errorfreplaced withrequire.*/assert.*from testifyTestEngineRegistrysplit intot.Runsubtests or replaced with table-driven testsGetGlobalEngineRegistry,Register,GetAllAgentManifestFolders, andGetAllAgentManifestFileshave test coveragego test -v ./pkg/workflow/ -run TestEngineRegistryscratchpad/testing.mdAdditional Context
scratchpad/testing.mdpkg/workflow/agentic_engine.go(~22 KB, multiple exported methods)Priority: Medium
Effort: Small (~1-2 hours)
Expected Impact: Cleaner CI output, faster failure diagnosis, coverage of critical global registry path
Files Involved:
pkg/workflow/agentic_engine_test.gopkg/workflow/agentic_engine.goReferences: