Test

Go Test

July 31, 2021
Go, Golang, Test, Testing

Go Test # Unit Test # Run # Run all unit tests # $ go test ./... Show detailed information $ go test ./... -v Disable test cache $ go test ./... -count=1 Run a method of a unit test # $ go test ./mypkg/ -run TestSample Coverage # Output coverage to a terminal $ go test -cover ./... Output the coverage profile to a file and view it in a browser ...

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. ...