1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LaravelにてPHP Unitでテストを指定して実行する方法

Posted at

はじめに

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"
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?