---
title: テスターがLaravelのtestをみてみた(公開用)
tags: 
author: [やまずん](https://docswell.com/user/55ymzn)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/VJN8VXW278.jpg?width=480
description: https://phpkansai.connpass.com/event/347053/ php勉強会の初LTです。
published: March 12, 25
canonical: https://docswell.com/s/55ymzn/582679-phpkansai44
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/VJN8VXW278.jpg)

テスターがLaravelのtestをみてみた
第44回関西PHP勉強会（Laravel特集）
2025.3.14(金)
やまずん
Dirty Tester バキバキQA


# Page. 2

![Page Image](https://bcdn.docswell.com/page/YE9K68XDE3.jpg)

自己紹介
⚫ プロのQAであり、テスター
⚫ 駆け出しphper
⚫ 職業:4月から外資系QA
⚫ 住居:大阪
⚫ 所属
⚫ バキバキQAチャンネル チャンネル主
⚫ testing.osaka 主催
⚫ スクフェス祭り 実行委員
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/GE8RZ825JD.jpg)

プロのテスターとして
Laravelのテストについて
解釈してみたという話
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/LELKDR23JR.jpg)

Laravelをいれてみる
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/4JM2PR8MJW.jpg)

&gt; composer global require laravel/installer
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/PJRM1R5LE9.jpg)

&gt; laravel new example-app
6


# Page. 7

![Page Image](https://bcdn.docswell.com/page/PEXVYRX67X.jpg)

&gt; cd example-app
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/3EKQ3RWGED.jpg)

❯ ls -1
README.md
app
artisan
bootstrap
composer.json
composer.lock
config
database
node_modules
package-lock.json
package.json
phpunit.xml
public
resources
routes
storage
tests
vendor
vite.config.js
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/L73PG815E5.jpg)

❯ ls -1 tests
Feature
TestCase.php
Unit
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/87DL1MXYEG.jpg)

❯ ls -1 tests
Feature
TestCase.php
Unit
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/VJP2QRP2J8.jpg)

❯ ls -1 tests
Feature
TestCase.php
Unit
「なんやこれ」
っておもった
ことを
はなす
11


# Page. 12

![Page Image](https://bcdn.docswell.com/page/2EVD5R2XEQ.jpg)

Laravelのtestをみてみよう
12


# Page. 13

![Page Image](https://bcdn.docswell.com/page/57GY6MRR7L.jpg)

Laravelのテストの構成
⚫ Laravelはデフォルトでtestディレクトリが実装され
ている
⚫ tests/Featureとtests/Unit
ふたつあるんだ
ね
⚫ 技術的な制約で区別しているわけではない
⚫ その気になればtests/UnitにFeatureテストを書ける
13


# Page. 14

![Page Image](https://bcdn.docswell.com/page/4EQM4RVYJP.jpg)

“Feature Test”ってなんなの？
Feature tests test larger portions of your codebase, including the
interaction of several objects with each other or even a complete HTTP
request to your application.Generally, feature tests exercise a larger slice of
your code and often include database interactions.
いろいろ繋げる
んだね
フィーチャテストは、コードベースのより大きな部分、例えば複
数のオブジェクト間の相互作用や、アプリケーションへの完全な
HTTPリクエストなどをテストします。一般的に、フィーチャテ
ストはコードのより広い範囲を対象とし、データベースとのやり
取りを含むことが多いです。
14


# Page. 15

![Page Image](https://bcdn.docswell.com/page/KJ4VQ8MZE1.jpg)

“Unit Test”ってなんなの？
Unit tests are focused on testing very small, isolated portions of your code.
You want to determine if a single method is performing as expected very
reliably and quickly.
独立したテスト
をするんだね
ユニットテストは、コードの非常に小さく、独立した部分をテス
トすることに焦点を当てています。単一のメソッドが期待どおり
に、非常に信頼性が高く、迅速に動作するかどうかを判断したい
と考えます。
15


# Page. 16

![Page Image](https://bcdn.docswell.com/page/LE13P28DJG.jpg)

Feature TestとUnit Testの比較
スコープ
実行速度
依存
根拠
実際の
テスト
Feature Test
複数の部品を結合
（大きい）
比較的低速
高い
仕様など
HTTPリクエスト
APIなど
Unit Test
単体の部品
(小さい)
高速
低い
コードなど
関数の返り値など
二つにはこんな
にちがいがある
んだねえ
16


# Page. 17

![Page Image](https://bcdn.docswell.com/page/GEWP2RZ8J2.jpg)

Feature Testを「機能テスト」って呼んでる説
Feature tests may test a larger portion of your code, including how several objects
interact with each other or even a full HTTP request to a JSON endpoint. Generally,
most of your tests should be feature tests. These types of tests provide the most
confidence that your system as a whole is functioning as intended.
日本語翻訳ほん
まにありがたい
機能テストでは、複数のオブジェクトが相互作用する方法や、JSONエ
ンドポイントへの完全なHTTPリクエストなど、コードの広い部分をテ
ストします。一般的に、ほとんどのテストは機能テストである必要が
あります。これらのタイプのテストは、システム全体が意図したとお
りに機能しているという信頼性を一番提供します。
https://github.com/laravel-ja/ja-docs-8.x/blob/master/translation-ja/testing.md
17


# Page. 18

![Page Image](https://bcdn.docswell.com/page/47ZKDR1973.jpg)

Feature Testを「機能テスト」って呼んでる説
⚫ Laravelドキュメントの日本語化プロジェクトでは
「機能テスト」
⚫ 他にも本とかQiitaとか見てると「機能テスト」とい
いろんな本でも
機能テストって
言ってるんだ
う訳語を当てているようにみえる
⚫ これがでPHP界隈で統一的された見解かどうかは不明
⚫ ただ違和感を覚えた
18


# Page. 19

![Page Image](https://bcdn.docswell.com/page/YJ6Q1RLDJV.jpg)

Feature Testを「機能テスト」とすると少し違和感
⚫ Feature Testを「機能テスト」と訳すと、Functional Testとかぶっ
てしまう
⚫ テスト界隈では、単体テストの機能テスト、結合テストの機能テス
ト、システムテストの機能テストがあるという考え方もある（後
機能テストのさ
まざまな解釈
述）
⚫ LaravelにおけるFeature TestはLaravelアプリケーションの複数の
コンポーネントを連結した状態での機能性を検証するテストと整理
するのがより本質的だと思った
⚫ Feature Testの訳語は多分ない
⚫ だからフィーチャーテストというしかない
19


# Page. 20

![Page Image](https://bcdn.docswell.com/page/GJ5R481874.jpg)

テストレベルとテストタイプ
いろんな概念が
あるんだねえ
「テストレベル」というという考え方
⚫ 単体テスト、結合テスト、システムテストとか
⚫ 「ユニットテスト」の訳語は単体テストにあたる
⚫ テストレベルを識別する統一的な見解は実は存在しない
機能テストは
テストレベルではない
⚫ 典型的には「システムの結合度」で判断することが多い
「テストタイプ」という考え方
⚫ 機能テスト、非機能テスト（性能テスト、負荷テストetc）
⚫ 統一的な（略）
機能テストは
テストタイプである
⚫ 典型的にはテストが担保する品質特性で判断することが多い
20


# Page. 21

![Page Image](https://bcdn.docswell.com/page/9E2DVK1VER.jpg)

テストレベルの識別
21


# Page. 22

![Page Image](https://bcdn.docswell.com/page/D7Y23NZQ7M.jpg)

テストレベルを識別することの意味
⚫ テストのスコープを定義することで、効率的なテストが
行える
⚫ より早い段階で、より早いテストを実現する
⚫ 一般的に、結合度の低いテストは早く終わる
識別っ
て”Identify”の訳
語だね
⚫ 例：Webのシステムテストは一件のテストに10秒かかるが、ユニッ
トテストは1秒かからないなど
⚫ 一般的に、それぞれの結合度や環境で見つかりやすい不具合
は違う
⚫ 例：メソッド単位のテストでは本番環境で見つかる不具合は見つか
らないなど
22


# Page. 23

![Page Image](https://bcdn.docswell.com/page/VEN8VX32J8.jpg)

他者と会話する時の注意
⚫ 「機能テストをしました」ではあんまり通じないかもしれな
い
⚫ システムレベルの機能テストと結合レベルの機能テストはできる
ことが異なる
テストは納得感
が大事だという
説がある
⚫ 「hogehoge環境でfugafuga観点のテストをしました」とか
⚫ これだけでは足りないので、この辺はお近くのテスターに聞いて
みてください
⚫ 「Feature Testしました」は「Laravelのテストをしました」
以上の意味を持たない可能性がある
23


# Page. 24

![Page Image](https://bcdn.docswell.com/page/Y79K689D73.jpg)

「自分たちは何のテストをしているのか」
がチームで納得いく形で理解することで
よりよいテストができる
(かもしれない)
24


# Page. 25

![Page Image](https://bcdn.docswell.com/page/G78RZ895ED.jpg)

参考文献
いつもありがと
ね〜
• https://laravel.com
• Laravel8.x公式ドキュメント翻訳リポジトリ,https://github.com/laravelja/ja-docs-8.x/blob/master/translation-ja/testing.md
• ブロッコリーのブログ、テストレベルに「機能テスト」が入ると困る理由、
2025/2/26、https://nihonbuson.hatenadiary.jp/entry/2019/12/03/003000
• https://zenn.dev/55_ymzn/books/what_is_testing
イラスト：タスマニア・デビ男
25


