Go Testingのロゴ

Go Testing

コミュニティ
Integralist
go-testing

Write unit and integration tests for Go services. Use when creating, editing, or updating tests, test helpers, mocks, fuzz tests, or benchmarks in Go projects.

概要

公開者Integralist
リポジトリagent-skills
スキル名go-testing
スター
26
フォーク
1
同梱ファイル
4
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    IntegralistがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルGo TestingをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Integralist/agent-skills/tree/main/.agents/skills/go-testing
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Integralist/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/.agents/skills/go-testing .claude/skills/go-testing
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでGo Testingを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にGo Testingを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Go Testingは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Write Go tests test-first, with each case proving one behaviour through the package's public API. Load the conventions-go skill too: it sets style and linter rules for test code (testCases/tc, rr, noctx, scopeguard, comments, testify/mock), and wins where the two overlap. Before writing or changing tests, read TEST-CONTRACTS for assertion contracts. For acceptance suites, also load conventions-acceptance-tests: it owns scenario-to-code structure for Go/Godog and Make/Bash workflows.

Style. For unit tests, ask whether the user prefers table-driven (default) or f-tests (helper f in named subtests).

A test written before its types exist fails to compile, which doesn't count as red. So:

  1. Stub the types and signatures, returning zero values or a sentinel such as errors.New("unimplemented").
  2. Write the test against the stub and run go test; it must compile and fail on its assertion.
  3. Write the least code that passes, then tidy up and delete dead code.

What each test proves

  • One behaviour per case. The case name states it; a case proving two things becomes two cases.
  • Every error path. Each error the public API can return gets a case that checks the failure, matching errors with errors.Is or errors.AsType. Match on a substring only for an unexported third-party error.
  • Real assertions. Assert state changes, header values, or payloads, never only assert.NoError when the call returns values. Assert the fields that matter rather than whole structs with reflect.DeepEqual or cmp.Diff, which fail on timestamps and generated IDs.
  • Nothing unused. Deleting any field or setup step must break the test. Split cases with different setup into separate tables.
  • Distinct paths only. Each case covers its own branch or dimension, not a trivial variation of another. Add to an existing table before writing a new Test* function.
  • Cancellation. A long-running, I/O-bound, or goroutine-spawning function gets a test proving it stops promptly when ctx is cancelled.
  • Public API. Test through exported names, preferably from package foo_test. Reach each branch through the public call that triggers it; delete any branch no public path reaches. Extract logic to internal/ only when it is a module with its own interface and a second caller or adapter (see code-module-design), not just to make it testable.
  • No coverage loss. Refactoring tests must never lower package statement coverage (go test -cover).

Patterns

Testify mocks. When a test double embeds mock.Mock, call its methods through the embedded field—for example, m.Mock.Called(...) rather than m.Called(...). The explicit receiver makes the mock dependency visible.

Table-driven:

go
// TestNormalize proves Normalize upper-cases input and rejects empty
// strings with ErrEmptyInput.
func TestNormalize(t *testing.T) {
	testCases := []struct {
		// name states the behaviour this case proves.
		name string
		// input is passed to Normalize.
		input string
		// expected is the result on success.
		expected string
		// wantErr is the sentinel to match with errors.Is, or nil.
		wantErr error
	}{
		{name: "upper-cases valid input", input: "hello", expected: "HELLO"},
		{name: "rejects empty input", input: "", wantErr: ErrEmptyInput},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			result, err := Normalize(tc.input)
			if tc.wantErr != nil {
				if !errors.Is(err, tc.wantErr) {
					t.Fatalf("expected %v, got %v", tc.wantErr, err)
				}
				return
			}
			if err != nil {
				t.Fatalf("unexpected error: %v", err)
			}
			if result != tc.expected {
				t.Errorf("expected %q, got %q", tc.expected, result)
			}
		})
	}
}

When cases prove one invariant across operations with different signatures, give each case an invoke func(*Repository) error closure rather than reaching for generics.

F-test:

go
// TestShout proves Shout upper-cases its input.
func TestShout(t *testing.T) {
	// f checks one input against its expected output.
	f := func(t *testing.T, input, expected string) {
		t.Helper()
		if got := Shout(input); got != expected {
			t.Fatalf("Shout(%q) = %q; want %q", input, got, expected)
		}
	}

	t.Run("converts to uppercase", func(t *testing.T) { f(t, "hello", "HELLO") })
	t.Run("handles empty string", func(t *testing.T) { f(t, "", "") })
}

Helpers and context. Call t.Helper() in every helper. Pass t.Context() (Go 1.24+), not context.Background(), to code under test; it cancels when the test ends. Don't block on a bare <-t.Context().Done() for an async wait, or a stuck test hangs until the suite times out; bound it:

go
ctx, cancel := context.WithTimeout(t.Context(), time.Second)
defer cancel()

select {
case <-renewed:
case <-ctx.Done():
	t.Fatalf("claim was not renewed: %v", ctx.Err())
}

Assertions. Prefer t.Errorf and t.Fatalf; use testify/assert for complex checks.

Running and references

bash
make test                                    # unit tests
make test-integration                        # integration tests
go test -v -run TestName ./pkg/...           # one test
go test -race ./...                          # race detector
go test -cover ./...                         # coverage

For specialised work, read:

  • INTEGRATION.md: e2e tests under the e2e build tag.
  • ACCEPTANCE.md: a runnable Godog wiring example for the canonical living features.
  • FUZZ-AND-BENCHMARKS.md: testing.F fuzzing and b.Loop() benchmarks.
  • COVERAGE-PRUNING.md: finding and pruning overlapping tests with Tobari.
  • The mutation-testing skill: checking whether tests catch behaviour changes.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Go Testing」では何ができますか?

Write unit and integration tests for Go services. Use when creating, editing, or updating tests, test helpers, mocks, fuzz tests, or benchmarks in Go projects.

TypingMindでGo Testingを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Go Testingはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにGo Testingをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Integralist/agent-skills/tree/main/.agents/skills/go-testingを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Go Testingを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Go Testingは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもGo Testingを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Go Testing」は無料ですか?

IntegralistがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇