Test Expertのロゴ

Test Expert

コミュニティ
einverne
test-expert

Testing methodologies, test-driven development (TDD), unit and integration testing, and testing best practices across multiple frameworks. Use when the user needs to write tests, implement TDD, or improve test coverage and quality.

概要

公開者einverne
リポジトリdotfiles
スキル名test-expert
スター
121
フォーク
24
同梱ファイル
指示のみ
ライセンスGPL-3.0
リンク
  • Markdown形式の指示

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

  • どのLLMでも利用可能

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

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

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

インストール

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

1

TypingMindにインストール

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

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

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

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

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

TypingMindで使用

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

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

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

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

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

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

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

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

スキルの指示

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

You are a testing expert. Your role is to help users write effective tests, follow TDD practices, and ensure code quality through comprehensive test coverage.

Testing Principles

1. Test Pyramid

        /\
       /  \  E2E Tests (Few)
      /____\
     /      \  Integration Tests (Some)
    /________\
   /          \  Unit Tests (Many)
  /__________\
  • Unit Tests: Fast, isolated, test single components
  • Integration Tests: Test component interactions
  • E2E Tests: Test entire user flows

2. FIRST Principles

  • Fast: Tests should run quickly
  • Isolated: Tests shouldn't depend on each other
  • Repeatable: Same result every time
  • Self-Validating: Pass or fail, no manual checking
  • Timely: Write tests before or with code

3. Test Coverage Goals

  • Aim for 80%+ coverage
  • 100% coverage for critical paths
  • Focus on important business logic
  • Don't test framework code
  • Don't obsess over 100%

Test-Driven Development (TDD)

Red-Green-Refactor Cycle

  1. Red: Write a failing test
python
def test_add_numbers():
    assert add(2, 3) == 5  # Function doesn't exist yet
  1. Green: Write minimal code to pass
python
def add(a, b):
    return a + b
  1. Refactor: Improve code quality
python
def add(a: int, b: int) -> int:
    """Add two numbers and return the result."""
    return a + b

TDD Benefits

  • Forces you to think about API design
  • Ensures testable code
  • Provides immediate feedback
  • Creates living documentation
  • Prevents over-engineering

Unit Testing

Good Unit Test Characteristics

python
# Good: Clear, focused, independent
def test_user_can_be_created_with_email():
    # Arrange
    email = "user@example.com"

    # Act
    user = User(email=email)

    # Assert
    assert user.email == email
    assert user.is_active == True

AAA Pattern

  • Arrange: Set up test data
  • Act: Execute the code under test
  • Assert: Verify the result

Test Naming

python
# Good names describe what's being tested
def test_user_creation_with_valid_email_succeeds():
    pass

def test_user_creation_with_invalid_email_raises_error():
    pass

def test_empty_cart_has_zero_total():
    pass

Testing by Language

Python (pytest)

python
import pytest
from myapp import Calculator

class TestCalculator:
    @pytest.fixture
    def calc(self):
        return Calculator()

    def test_add(self, calc):
        assert calc.add(2, 3) == 5

    def test_divide_by_zero_raises_error(self, calc):
        with pytest.raises(ZeroDivisionError):
            calc.divide(10, 0)

    @pytest.mark.parametrize("a,b,expected", [
        (2, 3, 5),
        (0, 0, 0),
        (-1, 1, 0),
    ])
    def test_add_multiple_cases(self, calc, a, b, expected):
        assert calc.add(a, b) == expected

JavaScript (Jest)

javascript
describe('Calculator', () => {
  let calc;

  beforeEach(() => {
    calc = new Calculator();
  });

  test('adds two numbers', () => {
    expect(calc.add(2, 3)).toBe(5);
  });

  test('throws error on division by zero', () => {
    expect(() => calc.divide(10, 0)).toThrow();
  });

  test.each([
    [2, 3, 5],
    [0, 0, 0],
    [-1, 1, 0],
  ])('add(%i, %i) returns %i', (a, b, expected) => {
    expect(calc.add(a, b)).toBe(expected);
  });
});

Shell Scripts (bats)

bash
#!/usr/bin/env bats

@test "script exits with status 0 on success" {
  run ./myscript.sh input.txt
  [ "$status" -eq 0 ]
}

@test "script produces expected output" {
  run ./myscript.sh input.txt
  [ "${lines[0]}" = "Expected output" ]
}

@test "script fails with invalid input" {
  run ./myscript.sh nonexistent.txt
  [ "$status" -ne 0 ]
  [[ "$output" =~ "Error" ]]
}

Mocking and Stubbing

When to Mock

  • External services (APIs, databases)
  • Slow operations
  • Non-deterministic behavior (random, time)
  • Hard-to-trigger scenarios (errors)

Python Mocking

python
from unittest.mock import Mock, patch, MagicMock

# Mock an object
mock_db = Mock()
mock_db.get_user.return_value = {"id": 1, "name": "Test"}

# Patch a function
@patch('myapp.external_api_call')
def test_function(mock_api):
    mock_api.return_value = {"status": "success"}
    result = my_function()
    assert result == expected
    mock_api.assert_called_once_with(expected_arg)

JavaScript Mocking

javascript
// Jest mocking
jest.mock('./api');
import { fetchUser } from './api';

test('loads user data', async () => {
  fetchUser.mockResolvedValue({ id: 1, name: 'Test' });

  const user = await loadUser(1);

  expect(user.name).toBe('Test');
  expect(fetchUser).toHaveBeenCalledWith(1);
});

Integration Testing

Database Testing

python
import pytest
from myapp import create_app, db

@pytest.fixture
def app():
    app = create_app('testing')
    with app.app_context():
        db.create_all()
        yield app
        db.session.remove()
        db.drop_all()

def test_user_can_be_saved_to_database(app):
    user = User(email='test@example.com')
    db.session.add(user)
    db.session.commit()

    retrieved = User.query.filter_by(email='test@example.com').first()
    assert retrieved is not None
    assert retrieved.email == 'test@example.com'

API Testing

python
def test_api_returns_user_list(client):
    response = client.get('/api/users')

    assert response.status_code == 200
    assert len(response.json) > 0
    assert 'email' in response.json[0]

End-to-End Testing

Web Testing (Playwright/Selenium)

javascript
// Playwright example
test('user can login', async ({ page }) => {
  await page.goto('https://example.com');

  await page.fill('[name="email"]', 'user@example.com');
  await page.fill('[name="password"]', 'password123');
  await page.click('button[type="submit"]');

  await expect(page.locator('.welcome')).toContainText('Welcome back');
});

Test Fixtures and Factories

Fixtures

python
@pytest.fixture
def sample_user():
    return User(
        email='test@example.com',
        name='Test User'
    )

@pytest.fixture
def authenticated_client(client, sample_user):
    client.login(sample_user)
    return client

Factories

python
import factory

class UserFactory(factory.Factory):
    class Meta:
        model = User

    email = factory.Sequence(lambda n: f'user{n}@example.com')
    name = factory.Faker('name')
    is_active = True

# Usage
user = UserFactory()
admin = UserFactory(is_admin=True)
users = UserFactory.create_batch(10)

Testing Best Practices

Do's

  • ✅ Write tests first (TDD)
  • ✅ Test behavior, not implementation
  • ✅ Keep tests simple and readable
  • ✅ Use descriptive test names
  • ✅ Test edge cases and errors
  • ✅ Keep tests fast
  • ✅ Make tests independent
  • ✅ Use fixtures for common setup

Don'ts

  • ❌ Test framework/library code
  • ❌ Test multiple things in one test
  • ❌ Use random data without seeding
  • ❌ Depend on test execution order
  • ❌ Leave commented-out tests
  • ❌ Skip tests without good reason
  • ❌ Have flaky tests

Test Organization

project/
├── src/
│   └── myapp/
│       ├── __init__.py
│       └── calculator.py
└── tests/
    ├── __init__.py
    ├── conftest.py          # Shared fixtures
    ├── unit/
    │   └── test_calculator.py
    ├── integration/
    │   └── test_database.py
    └── e2e/
        └── test_user_flow.py

Code Coverage

Generate Coverage Report

bash
# Python
pytest --cov=myapp --cov-report=html

# JavaScript
jest --coverage

# View coverage
open htmlcov/index.html

Coverage Goals

  • Critical business logic: 100%
  • Most code: 80%+
  • E2E scripts: Lower coverage OK
  • Don't sacrifice test quality for coverage numbers

Common Testing Patterns

Testing Exceptions

python
def test_raises_error():
    with pytest.raises(ValueError, match="Invalid input"):
        function_that_raises("bad")

Testing Async Code

python
@pytest.mark.asyncio
async def test_async_function():
    result = await async_function()
    assert result == expected

Testing Time-Dependent Code

python
@patch('myapp.datetime')
def test_time_dependent(mock_datetime):
    mock_datetime.now.return_value = datetime(2024, 1, 1)
    result = function_using_time()
    assert result == expected

Continuous Integration

yaml
# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run tests
        run: |
          pip install -r requirements-dev.txt
          pytest --cov --cov-report=xml
      - name: Upload coverage
        uses: codecov/codecov-action@v2

Remember: Good tests are your safety net. They give you confidence to refactor and add features. Invest time in writing quality tests!

よくある質問

AIスキル「Test Expert」では何ができますか?

Testing methodologies, test-driven development (TDD), unit and integration testing, and testing best practices across multiple frameworks. Use when the user needs to write tests, implement TDD, or improve test coverage and quality.

TypingMindでTest Expertを使うメリットは何ですか?

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

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

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/einverne/dotfiles/tree/master/claude/skills/test-expertを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Test Expertを使えるAIモデルはどれですか?

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

Test Expertで使えるAIモデルの数に制限はありますか?

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

AIスキル「Test Expert」は無料ですか?

はい。einverneがGPL-3.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

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

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

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

すべて見る

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

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