← スキル一覧に戻る

create-test
by hieupvXmasEve
⭐ 0🍴 0📅 2026年1月6日
SKILL.md
name: create-test description: Generates a PHPUnit/Pest test file. Use when adding test coverage for Actions, Features, or Endpoints (e.g., "Create a test for RegisterStudentAction"). allowed-tools: Write, Read
Create Test
This skill generates a Pest test file (preferred) or PHPUnit test class.
Instructions
-
Identify Parameters:
- Target: What are we testing? (e.g.,
RegisterStudentAction,CourseController). - Type:
Unit(for Actions/DTOs/Support) orFeature(for Controllers/Integration). - Module: (e.g.,
Academic). - Path:
app/Modules/{Module}/tests/{Type}/{Target}Test.php(if module-based) ORtests/{Type}/{Target}Test.php.
- Target: What are we testing? (e.g.,
-
Generate Code:
- Use Pest syntax (it's succinct and readable).
- Namespace:
App\Modules\{Module}\Tests\{Type}. - Setup: Use
uses(TestCase::class)->in(__DIR__);if needed, or rely onPest.phpconfiguration. - Content:
- Happy path (Success scenario).
- Validation failure scenario.
- Authorization failure scenario.
Template (Unit - Action)
<?php
namespace App\Modules\Academic\Tests\Unit;
use App\Modules\Academic\Actions\CreateCourseAction;
use App\Modules\Academic\Models\Course;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('it creates a course successfully', function () {
$data = [
'name' => 'Introduction to Computer Science',
'code' => 'CS101',
'credits' => 3,
];
$course = CreateCourseAction::run($data);
expect($course)
->toBeInstanceOf(Course::class)
->name->toBe('Introduction to Computer Science');
$this->assertDatabaseHas('courses', ['code' => 'CS101']);
});
Template (Feature - Controller)
<?php
namespace App\Modules\Academic\Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('admin can view course list', function () {
$user = User::factory()->create();
// specific permission setup if needed
$response = $this->actingAs($user)
->get(route('academic.courses.index'));
$response->assertStatus(200)
->assertInertia(fn ($page) => $page
->component('Academic/Course/Index')
->has('items')
);
});
Checklist
- Are you using
RefreshDatabase? - Are you asserting the side effects (DB changes, Events dispatched)?
- Are you testing the 'Unhappy Path' (errors)?
スコア
総合スコア
50/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
レビュー
💬
レビュー機能は近日公開予定です