golang-stretchr-testify
Write Better Go Tests with Testify
Testify gives Go developers readable assertions, reliable mocks, and structured suites. This skill helps AI generate and review focused tests with correct failure behavior and expectation checks.
使用我的智慧代理安裝
將此請求複製給你的智慧代理,其中包含權威 Skill 頁面和清單。
Review the Skillstore skill "golang-stretchr-testify" from https://skillstore.io/skills/samber-golang-stretchr-testify.md and its manifest at https://skillstore.io/api/skills/samber-golang-stretchr-testify/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智慧代理仍應顯示其計畫,並依安全政策請求必要確認。
Agent 可讀資源
當 AI Agent、爬蟲或腳本需要乾淨脈絡、而不是讀取完整頁面時,請使用這些連結。
測試它
正在使用「golang-stretchr-testify」。 How should a test handle a wrapped ErrNotFound value?
預期結果:
Use testify ErrorIs to match the wrapped error chain. Reserve equality assertions for values that require exact comparison.
正在使用「golang-stretchr-testify」。 Why did my mock-based test pass when the dependency was never called?
預期結果:
- Define the expected method call with an explicit call count.
- Run AssertExpectations at the end of the test.
- Use a specific matcher when the argument must be validated.
正在使用「golang-stretchr-testify」。 How should a suite initialize a fresh mock for every test?
預期結果:
Use SetupTest for per-test state, reserve SetupSuite for shared resources, and include the launcher that calls suite.Run.
安全審計
安全All 38 static findings are false positives caused by prose, Markdown delimiters, Go raw string literals, evaluation text, or benign metadata. The reviewed files contain no evidence of executable shell commands, dynamic loading, system reconnaissance, network activity, or prompt injection.
風險因素
⚡ 包含腳本 (2)
⚙️ 外部命令 (33)
🌐 網路存取 (1)
分享與引用此報告
分享版本化評估報告、中性徽章、嵌入卡片與引用。Skillstore 只報告證據,不判斷該 Skill 是否安全。
複製報告連結
https://skillstore.io/skills/samber-golang-stretchr-testify/audits/1?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/samber-golang-stretchr-testify?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/samber-golang-stretchr-testify?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/samber-golang-stretchr-testify/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/samber-golang-stretchr-testify.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>學術引用 (APA · BibTeX · CFF)
APA 引用
samber. (2026). golang-stretchr-testify security audit report (audit version 1) [Author version 1.3.1]. Skillstore. https://skillstore.io/skills/samber-golang-stretchr-testify/audits/1BibTeX 引用
@techreport{samber-samber-golang-stretchr-testify-2026,
author = {samber},
title = {golang-stretchr-testify security audit report (audit version 1)},
institution = {Skillstore},
year = {2026},
number = {1},
url = {https://skillstore.io/skills/samber-golang-stretchr-testify/audits/1},
note = {Author version 1.3.1}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "golang-stretchr-testify security audit report (audit version 1)"
version: "1.3.1"
type: report
authors:
- name: "samber"
date-released: "2026-09-23"
url: "https://skillstore.io/skills/samber-golang-stretchr-testify/audits/1"
identifiers:
- type: other
value: "skillstore:samber-golang-stretchr-testify:audit:1"
description: "Skillstore immutable audit report identifier"
Skillstore 評分
評分依據 證據置信度: 中你可以打造什麼
Add focused unit tests
Generate readable Go tests with fail-fast preconditions and clear value assertions for new functions.
Build dependable mocks
Define mock expectations, argument matchers, call counts, and retry responses for isolated service tests.
Review existing test suites
Find assertion-order errors, missing expectation verification, incorrect suite lifecycle usage, and pointer comparison mistakes.
試試這些提示
Write a testify test for a function that parses a configuration. Use require for parsing and nil preconditions, then use assert for expected field values.
Create a testify mock for a Sender interface. Verify one call with a specific email, use a context matcher, and check all expectations.
Convert these related Go tests into a testify suite. Use shared database setup, fresh mock state before each test, cleanup hooks, and a working suite launcher.
Design a testify test for an asynchronous client that retries after a timeout. Use sequential mock returns, EventuallyWithT, collected assertions, and explicit timeout intervals.
最佳實務
- Use require for setup failures that make later assertions unsafe, and use assert for independent outcomes.
- Make mock expectations explicit with suitable matchers, call counts, and final verification.
- Keep suite lifecycle responsibilities clear and run testifylint during review or continuous integration.
避免
- Using assert for a nil-sensitive precondition and then dereferencing the failed value.
- Comparing wrapped errors with direct equality instead of checking the error chain.
- Defining mock expectations without verifying them or creating a suite without its launcher.
常見問題
When should I use require instead of assert?
How do I check a wrapped Go error?
How do I verify a mock call count?
What matcher ignores an argument value?
How do testify suites run?
Can this skill replace testify documentation?
開發者詳細資訊
作者
samber授權
MIT
作者版本
v1.3.1
Skillstore 修訂
r1
引用
2aa351cb09c29b7287d263bd8ea81e9bee3b2a61
維護新鮮度
2026/9/30
使用量
0 次下載 · 0 次瀏覽
檔案結構