Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides guidance on Go testing patterns, including table-driven tests, mocking, integration tests, benchmarks and test organization.
Use this skill ↓86% 86%0 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 19 of 22 without it.
3 of 3 safety checks passed
Not used yet
This skill provides guidance on comprehensive testing strategies for Go applications including unit tests, integration tests, benchmarks, and test organization.
func TestAdd(t *testing.T) {
tests := []struct {
name string
a, b int
expected int
}{
{"positive numbers", 2, 3, 5},
{"negative numbers", -2, -3, -5},
{"mixed numbers", -2, 3, 1},
{"zeros", 0, 0, 0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := Add(tt.a, tt.b)
if result != tt.expected {
t.Errorf("Add(%d, %d) = %d; want %d", tt.a, tt.b, result, tt.expected)
}
})
}
}
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.