スキル一覧に戻る
so-ta

add-test

by so-ta

0🍴 0📅 2026年1月23日
GitHubで見るManusで実行

SKILL.md


name: add-test description: | Add test cases to the codebase. Use when writing new tests, improving test coverage, or when the user asks to add tests for specific functionality.

Add Test Cases

テストケースの追加。

Backend (Go)

テストファイルの配置

backend/internal/<package>/<file>_test.go

テスト構造

func Test<Function>_<Scenario>(t *testing.T) {
    // Arrange
    // テストデータの準備

    // Act
    // テスト対象の実行

    // Assert
    // 結果の検証
}

テーブル駆動テスト

func Test<Function>(t *testing.T) {
    tests := []struct {
        name    string
        input   <Type>
        want    <Type>
        wantErr bool
    }{
        {"valid case", input1, want1, false},
        {"error case", input2, nil, true},
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got, err := Function(tt.input)
            if (err != nil) != tt.wantErr {
                t.Errorf("error = %v, wantErr %v", err, tt.wantErr)
                return
            }
            if !reflect.DeepEqual(got, tt.want) {
                t.Errorf("got = %v, want %v", got, tt.want)
            }
        })
    }
}

テスト実行

cd backend && go test ./...
cd backend && go test ./internal/<package>/... -v

Frontend (TypeScript/Vue)

テストファイルの配置

frontend/tests/<component>.test.ts
frontend/composables/<composable>.test.ts

テスト構造

import { describe, it, expect } from 'vitest'

describe('<Component/Function>', () => {
  it('should <expected behavior>', () => {
    // Arrange
    // Act
    // Assert
    expect(result).toBe(expected)
  })
})

テスト実行

cd frontend && npm run test:run
cd frontend && npm run test:run -- --grep "<pattern>"

テストのベストプラクティス

観点ガイドライン
カバレッジ正常系、異常系、境界値をカバー
独立性各テストは独立して実行可能に
可読性テスト名で何をテストしているか明確に
保守性テストデータは最小限に

次のステップ

テスト追加後、全テストがパスすることを確認し、PR作成へ進む。

スコア

総合スコア

40/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です