go-fluent-testing
Skill1 starsChanged 2 months agoMITView on GitHub
Go testing with the fluent Given/When/Then DSL across all test tiers: unit (mocks, blackbox), integration (testcontainers, real deps), and E2E (docker-compose, HTTP). ONE methodology — parts struct, newParts(t), .and() chaining, all state in parts. Canonical rules in references/fluent-testing-guideline.md. Use when writing or reviewing ANY Go test: unit, integration, E2E, or choosing the tier for a new test. Keywords: go test, fluent testing, given when then, parts struct, testcontainers, docker-compose, unit test, integration test, e2e test, testify, mocking, blackbox.
In this repository30 other files it gives its agents.
- arch-linux-cachyosSkill
- arch-linux-triageSkill
- bash-defensive-patternsSkill
- bash-linuxSkill
- bash-scriptingSkill
- beansSkill
- context7Skill
- docker-compose-setupSkill
- audioSkill
- deploymentSkill
- ecsSkill
- game-loopSkill
- inputSkill
- physicsSkill
- renderingSkill
- resourcesSkill
- ebitenSkill
- geminiSkill
- go-browser-testsSkill
- go-devSkill
- go-htmx-frontendSkill
- go-setupSkill
- interactive-browser-testingSkill
- keep-on-goingSkill
- mcpcSkill
- minimaxSkill
- pixellabSkill
- playwright-mcpSkill
- public-repo-maturitySkill
- searxngSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
All Go testing — unit, integration, and E2E — in one fluent Given/When/Then methodology.
- Distinctive: line 45
No I/O: no DB, no HTTP, no filesystem — mock every dependency via constructor injection (define a small interface at the consumer).
- Very specific: line 119
NEVER use direct helper function calls inside fluent Test funcs — everything flows through given/when/then methods (classic units: setup …
- Distinctive: line 122
NEVER put validation in the when section (either style)
- Very specific: line 123
NEVER use build tags, //nolint, or skip/delete tests
- Distinctive: line 124
NEVER leave containers running or skip cleanup (integration/E2E)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
What I do
All Go testing — unit, integration, and E2E — in one fluent Given/When/Then methodology. One DSL, one parts struct, three tiers.
MANDATORY Reference
ALL Go tests MUST follow: references/fluent-testing-guideline.md
(included in this skill directory). It is the single source of truth
for the DSL: parts struct, newParts(t), .and() at END of line,
all state in parts, no direct helper calls in Test funcs, t.Run
promotion, fixtures over inline strings.
Choose the tier
| Tier | Directory | Package | Dependencies | Speed |
| Unit | next to code under test | <name>_test (external) | mocks only, no I/O | <10ms/test |
| Integration | test/integration/ | integration_test | testcontainers (real DB/services) | 100ms–1s/test |
| E2E | test/e2e/ | e2e_test | docker-compose services, HTTP on exposed ports | seconds/test |
Decision rule: test business logic through public APIs → unit;
test a component against a real dependency → integration; test a
complete user workflow or API contract across services → E2E.
Browser-checking a frontend needs chromedp — see the go-browser-tests
skill; migrating an existing suite — see the go-fluent-test-migration
skill.
Unit rules (blackbox — CRITICAL)
- Package
<name>_test(e.g.handlers_test); test ONLY exported functions/methods; never touch unexported fields or private funcs. This blackbox rule applies to BOTH unit styles below. - No I/O: no DB, no HTTP, no filesystem — mock every dependency via constructor injection (define a small interface at the consumer).
- Speed <10ms per test; naming
TestComponent_Scenario. - Never:
wantErr bool(split into separate tests), build tags,//nolint, deleting or skipping tests.
Unit styles: fluent OR classic
Unit tests accept two layouts — pick per repo convention, keep one per repo, never mix within a package:
Fluent — the full DSL below (parts struct, newParts(t),
.and() chaining). Use when the package already has a fluent DSL or
the tier is integration/E2E anyway.
Classic — plain test funcs segmented by // given / // when /
// then comments. Default for units: no DSL to build, same
discipline, less machinery.
func TestService_CreateUser(t *testing.T) {
// given
mockRepo := &MockRepository{}
mockRepo.On("Save", mock.Anything, mock.Anything).Return(nil)
service := service.NewService(mockRepo)
// when
err := service.CreateUser("test@example.com", "Test User")
// then
assert.NoError(t, err)
mockRepo.AssertExpectations(t)
}Classic rules: the three comments in order, one each; setup only under
// given, calls only under // when, assertions only under
// then; no section skipped; state stays local to the test func (the
parts-struct rule does not apply here).
Fluent pattern (integration & E2E; units when repo is fluent)
func TestService_CreateUser(t *testing.T) {
_, when, then := newParts(t) // declare only used sections
when.
createUser("test@example.com", "Test User")
then.
noError().and().
userPersisted()
}newParts(t)returnsp, p, p(given, when, then) over one parts struct that embeds*testing.T,require.New(t), and ALL test state — no local state variables in test funcs.- Tier differences live in the given-methods only: unit
givenbuilds mocks; integrationgivenstarts containers; E2Egivenwaits for compose services. The when/then shape is identical everywhere.
Commands
# Use the project's runner (make or just)
<runner> test-unit # unit only
<runner> test-integration # integration only
<runner> test-e2e # e2e only
<runner> check # vet + test + lintForbidden (all tiers)
- NEVER use direct helper function calls inside fluent Test funcs —
everything flows through given/when/then methods (classic units:
setup under
// giveninstead) - NEVER put validation in the when section (either style)
- NEVER use build tags,
//nolint, or skip/delete tests - NEVER leave containers running or skip cleanup (integration/E2E)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

