【Laravel】artisanのmake:testコマンドを解説

Laravel

Laravel 10.xのartisanの「make:test」コマンドを解説します。

Description

新しいテストクラスの作成

Usage

php artisan make:test [-f|--force] [-u|--unit] [-p|--pest] [--] <name>

Arguments

引数必須設営
name必須テストクラス名。ディレクトリを指定する場合は「/」を使う

Options

オプション省略形必須説明
forcef-テストが既に存在する場合でもクラスを作成
unitu-ユニットテストを作成
pestp-ペストテストの作成

Examples

no options

php artisan make:test FooTest
   INFO  Test [tests/Feature/FooTest.php] created successfully.  
<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class FooTest extends TestCase
{
    /**
     * A basic feature test example.
     */
    public function test_example(): void
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}

Follow me!

コメント

PAGE TOP
タイトルとURLをコピーしました