golang-testing
Go testing patterns for unit tests, table-driven tests, subtests, test helpers, mocking/fakes, benchmarks, fuzzing, and coverage. Use when writing or reviewing Go tests to improve correctness, stability, and maintainability.
v2026.11.13-21cd5683 установки+3 за 7 дней39 ЗвездыMITсинхронизировано 11 часов назад
Установка
Ещё нет NotHoly CLI? Сначала установите её.
$ curl -fsSL https://notholy.com/install.sh | sh$ notholy skills install aeondave/golang-testingПишет в ~/.notholy/skills после проверки подписи и SHA-256.
ПодписьПодписано, ed25519
Пакет1c303df2…7a3ea5d6
1c303df21fe2…6d8b7a3ea5d69 файлов · 8.4 KBПроверкаНизкий1 замечание
- Ссылки на внешние домены
Источникgithub.com/AeonDave/malskill/tree/main/coding/golang-testing@21cd568
Эта запись еще не переведена на русский, поэтому показан текст на другом языке: English.
На странице
This skill is about writing tests that are reliable, readable, and useful as documentation.
When to activate
- Writing new tests for functions, packages, or APIs
- Refactoring tests for clarity and reduced flakiness
- Adding benchmarks or fuzz tests
- Stabilizing concurrent or time-dependent tests (
testing/synctest) - Improving coverage without gaming the metric
Core rules (high signal)
- Prefer table-driven tests for coverage and readability.
- Use t.Helper() and t.Cleanup() to keep failures actionable.
- Tests should be deterministic: prefer
testing/synctestovertime.Sleepwhen the code under test usestimeprimitives. - Prefer fakes (in-memory implementations) over heavy mocks.
- Use
t.Parallel()only when the test is truly isolated. - Keep test data local and explicit; avoid hidden cross-test coupling.
- Do not add exported production APIs solely for tests; prefer package seams, interfaces, or local fakes.
- Pair with
test-driven-developmentwhen implementing persistent code or bug fixes test-first. - Pair with
testing-reliabilityfor mock/timing anti-patterns andsystematic-debuggingwhen failure attribution is unclear.
Outcome expectations
- Unit tests are fast, deterministic, and easy to debug.
- Flaky tests are triaged with a repeatable reproduction loop.
- Bench/fuzz/coverage are used as correctness signals, not vanity metrics.
Recommended workflow
- Write/adjust focused unit tests first (table + subtests).
- Run targeted test selection to confirm behavior quickly.
- Add race detector and coverage checks.
- For instability, reproduce with repeated runs (
-count) and isolate state/time dependencies (synctestfortime-based concurrency). - Add benchmarks/fuzz tests when behavior or performance risk justifies them.
Quick checklist for a review
- Setup is outside the assertion loop; minimal shared mutable state
- Subtests have meaningful names (
t.Run("case", ...)) - Error messages show got/want and context
- External dependencies are explicit (DBs, network, time)
- Benchmarks report allocs when relevant (
b.ReportAllocs())
Resources
Load on demand:
references/unit-tests.md— TDD loop, table tests, subtests, parallel subtestsreferences/helpers-fixtures.md— helpers, TempDir, Cleanup, testdata, golden filesreferences/mocking-fakes.md— interfaces for dependencies, fakes vs mocks, examplesreferences/http-testing.md— httptest patterns,NewTestServer(Go 1.27+), JSON assertionsreferences/bench-fuzz.md— benchmarks and fuzzing best practicesreferences/fuzzing-and-race.md— load forgo test -fuzzcampaigns, race detector,goleak,goroutineleakprofiles, andtesting/synctest(Test/Wait/Sleep)references/coverage-ci.md— cover profiles, coverpkg notes, CI integration cautionsreferences/commands.md— go test command recipes (race, timeout, count, patterns)
Файлы этой версии
references/816.6 KB
- bench-fuzz.md1.3 KB
- commands.md974 B
- coverage-ci.md897 B
- fuzzing-and-race.md7.4 KB
- helpers-fixtures.md936 B
- http-testing.md2.1 KB
- mocking-fakes.md1.3 KB
- unit-tests.md1.7 KB
- SKILL.md3.5 KB
Права
| Право | Заявлено | Найдено проверкой |
|---|---|---|
| Читает файлы | Нет | Нет |
| Пишет файлы | Нет | Нет |
| Выполняет команды shell | Да | Да |
| Ходит в сеть | Да | Да |
| Использует коннекторы | Нет | Нет |
| Управляет браузером | Нет | Нет |
Замечания проверки
Проверено 13 нояб. 2026 г.
- ИнфоСсылка · Ссылки на внешние домены
Чистая проверка снижает риск, но не доказывает, что пакет безопасен. Читайте то, что ставите.
| Версия | Опубликована | Коммит | SHA-256 | Подпись | Изменение прав |
|---|---|---|---|---|---|
| v2026.11.13-21cd568 | 13 нояб. 2026 г. | 21cd568 | 1c303df2 | Подписана | – |
Ещё от AeonDave
Всё от этого издателяЕще в категории «Реверс-инжиниринг и фаззинг»
Вся категорияСпрашивайте обо всём, что позволяет ваш скоуп.
Создайте аккаунт, пополните баланс и задайте первый вопрос в чате или в терминале.
- 1/3
Создайте аккаунт
Личный или для компании. Позже можно перейти на аккаунт компании без потери баланса и ключей.
ЛичныйКомпания - 2/3
Пополните баланс
Картой. Оплата за токены, без подписки.
$5.00минимальное пополнение - 3/3
Спрашивайте
В чате, или установите CLI и выполните notholy login в терминале.
$ notholy login