PHPUnit

PHPUnit

January 1, 2020
PHPUnit, Laravel, Test

PHPUnit # 事前準備 # インストール # composer.json "require-dev": { "fzaninotto/faker": "*", "mikey179/vfsstream": "*", "mockery/mockery": "*", "phpunit/phpunit": "*" }, $ composer install バージョンの確認 # $ ./vendor/bin/phpunit --version 基本 # <?php use Aaa\ClassA; use Bbb\ClassB; use Eee\ExceptionA; use Mockery; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass Aaa\ClassA */ class ClassATest extends TestCase { // Omitted /** * This method is called before class. TestCaseクラス実行前の処理。 * * @return void */ public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); // static 変数を使用(static メソッドのため) self::$hoge = 'some value'; } /** * This method is called before each test. ...