codeception-skill について
codeception-skillは、Codeceptionを使うテスト担当者向けのガイドです。受け入れ、API、データベースのテストパターンに加え、設定やCI/CDの手順を扱います。
主な機能
- 01Cest受け入れテストのパターン
- 02Actorによる画面遷移とフォーム操作
- 03ページオブジェクトと再利用可能な手順
- 04APIおよびデータベーステストのガイド
- 05スイート設定とCI/CD連携
活用シーン
- 01ログインフローの受け入れテスト作成
- 02RESTモジュールを使ったAPIテスト
- 03データベースレコードの変更確認
- 04WebDriverによるクラウドテスト設定
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ lambdatest/ agent-skills --skill codeception-skillインストール後、Claude Code で/codeception-skillを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
reference/advanced-patterns.mdcloud-integration.mdplaybook.md詳細
Codeception テストスキル
基本パターン
受け入れテスト(Cest)
<?php
// tests/Acceptance/LoginCest.php
class LoginCest
{
public function _before(AcceptanceTester $I)
{
$I->amOnPage('/login');
}
public function loginWithValidCredentials(AcceptanceTester $I)
{
$I->fillField('email', '[email protected]');
$I->fillField('password', 'password123');
$I->click('Login');
$I->see('Dashboard');
$I->seeInCurrentUrl('/dashboard');
$I->seeElement('.welcome-message');
}
public function loginWithInvalidCredentials(AcceptanceTester $I)
{
$I->fillField('email', '[email protected]');
$I->fillField('password', 'wrong');
$I->click('Login');
$I->see('Invalid credentials');
$I->seeInCurrentUrl('/login');
}
}
アクターメソッド(AcceptanceTester $I)
// Navigation
$I->amOnPage('/path');
$I->click('Button Text');
$I->click('#id');
$I->click(['xpath' => '//button']);
// Forms
$I->fillField('Name or Label', 'value');
$I->selectOption('Select', 'Option');
$I->checkOption('Checkbox');
$I->uncheckOption('Checkbox');
$I->attachFile('Upload', 'file.txt');
$I->submitForm('#form', ['email' => '[email protected]']);
// Assertions
$I->see('Text');
$I->dontSee('Text');
$I->seeElement('#id');
$I->dontSeeElement('.error');
$I->seeInField('email', '[email protected]');
$I->seeInCurrentUrl('/dashboard');
$I->seeInTitle('Page Title');
$I->seeCheckboxIsChecked('#agree');
$I->seeNumberOfElements('li', 5);
// Grabbers
$text = $I->grabTextFrom('.element');
$attr = $I->grabAttributeFrom('#link', 'href');
$value = $I->grabValueFrom('#input');
ページオブジェクト(ステップオブジェクト)
<?php
// tests/_support/Page/Login.php
namespace Page;
class Login
{
public static $url = '/login';
public static $emailField = '#email';
public static $passwordField = '#password';
public static $loginButton = 'button[type="submit"]';
protected $I;
public function __construct(\AcceptanceTester $I) { $this->I = $I; }
public function login(string $email, string $password): void
{
$this->I->amOnPage(self::$url);
$this->I->fillField(self::$emailField, $email);
$this->I->fillField(self::$passwordField, $password);
$this->I->click(self::$loginButton);
}
}
クラウド(TestMu AI)
セットアップ全体については、reference/cloud-integration.mdを参照してください。機能のリファレンスについては、shared/testmu-cloud-reference.mdを参照してください。
クラウド設定(acceptance.suite.yml)
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://localhost:3000'
host: 'hub.lambdatest.com'
port: 80
browser: chrome
capabilities:
'LT:Options':
user: '%LT_USERNAME%'
accessKey: '%LT_ACCESS_KEY%'
build: 'Codeception Build'
video: true
セットアップ:composer require --dev codeception/codeception codeception/module-webdriver
初期化:php vendor/bin/codecept bootstrap
実行:php vendor/bin/codecept run acceptance
詳細パターン
本番環境向けのパターンについては、reference/playbook.mdを参照してください。
| セクション | 内容 |
|---|---|
| §1 プロジェクトのセットアップ | インストール、codeception.yml、スイートの設定 |
| §2 受け入れテスト | Cest パターン、@dataProvider、WebDriver の操作 |
| §3 API テスト | REST モジュール、CRUD 操作、@depends、HttpCode |
| §4 ページオブジェクト | 静的セレクターを持つページクラス、再利用可能なメソッド |
| §5 データベーステスト | haveInDatabase、seeInDatabase、updateInDatabase |
| §6 カスタムヘルパー | Codeception Module を拡張するカスタムモジュール |
| §7 CI/CD 統合 | MySQL、Selenium、カバレッジを使用した GitHub Actions |
| §8 デバッグ表 | よくある問題 12 件と原因、解決方法 |
| §9 ベストプラクティス | Codeception テストの 14 項目チェックリスト |
コメント
Markdown 対応