はじめに
LaravelにてPHPUnitを実行する際にテストを指定して、実行する方法をまとめました
環境
$ php artisan -V
Laravel Framework 5.8.29
実行方法
- 実行するテスト
project/tests/Unit/HogeTest.php
<?php
namespace Tests\Unit;
use Tests\TestCase;
class HogeTest extends TestCase
{
/**
* @test Hoge::hello()
*/
public function testHello()
{
$result = Hoge::hello();
$this->assertTrue($result);
}
}
- テスト実行例
# テストを指定して実行
$ ./vendor/bin/phpunit project/tests/Unit/HogeTest.php --filter "testHello"