Akito.Tsukahara.PHPerKaigi2020

Laravelから始める
テスト駆動開発
PHPerKaigi2020
塚原 彰仁
PHPer歴 3年
Laravel,CakePHP,
WordPress
トークの概要
・テスト書く習慣ゼロの状態から
テスト駆動開発を始めた話
ある案件の話(失敗談)
▼イベント管理システム
・チケット申し込み
・当日来場受付
数々の苦難が…
機能を追加すると
既存機能が動かない…
増え続けるテストケース
・会員種別
・申込み手順
・開催中のイベント
・例外処理
→400件以上をリリースの度に
申し込んだデータが
消えたみたいで…
出典:BLEACH 13巻
何が起きていたのか?
1時間以内に購入
1時間以上経過する
何が起きていたのか?
1時間以内に購入
1時間以上経過する
Akito.Tsukahara.PHPerKaigi2020
よし!テスト書く!
テスト書く習慣を作る
機能追加に耐えられる
きれいなコード書ける
Akito.Tsukahara.PHPerKaigi2020
レベル1
社内案件から始める
Laravelで始めてみる
・ヘルパーメソッドが便利
・ドキュメント豊富
仕様の概要
▼個人の売上貢献度を教えてくれる
システム
・Googleログイン認証
・Google Sheets API連携
この処理をテスト駆動開発でやってみる
Google認証画面(←サンプル)
↓
ログイン
↓
メールアドレス取得
色々参考にしながら
こんな感じに
何とかできそう!
・参考サイトたくさんある
・テスト前提なら書きやすい
これで満足?
出典:BLEACH 13巻
打ち切り漫画っぽい
出典:シャーマンキング 32巻
レベル2
因縁のイベントシステム
問題の処理のテストコードを書いていく
チケット申し込み
↓
予約状態を確認(←サンプル)
↓
チケット予約確定
まずはFatControllerの
リファクタリング
1.予約状況の確認処理をまるごとService
レイヤーに切り出す
2.テスト用に処理を分解する
泥臭くテストを書いていく
こんな感じに
それでも書けないところは
E2Eテスト、手動テストでカバー
問題のテストケースは
E2Eテストにできました!
(1時間の待ち時間解消!!)
Akito.Tsukahara.PHPerKaigi2020
会社のみんなからは
複雑な案件に対して、エンジニアも非エンジニアも
安心感を持って取り組めます!
機能追加の心理ハードルが下がりますー
出典:SLAM DUNK15巻
打ち切り
・やってみる価値はあるよ!
・実務で苦戦したことが
逆にモチベーションに!
・小さく始めていこう!
よかったら
テストどうでしょうか?
@AkitoTsukahara
1 of 39

Recommended

Javaでのバリデーション 〜Bean Validation篇〜 by
Javaでのバリデーション 〜Bean Validation篇〜Javaでのバリデーション 〜Bean Validation篇〜
Javaでのバリデーション 〜Bean Validation篇〜eiryu
19.2K views31 slides
試験にでるSpring by
試験にでるSpring試験にでるSpring
試験にでるSpring土岐 孝平
5.1K views26 slides
リモートワークと子育て3つの秘訣 #iw2017jp #techgirl by
リモートワークと子育て3つの秘訣 #iw2017jp #techgirlリモートワークと子育て3つの秘訣 #iw2017jp #techgirl
リモートワークと子育て3つの秘訣 #iw2017jp #techgirlManami Taira
610 views13 slides
アプリ開発を効率化する 方法あれこれ by
アプリ開発を効率化する 方法あれこれアプリ開発を効率化する 方法あれこれ
アプリ開発を効率化する 方法あれこれAtsushi Mizoue
8.4K views105 slides
Javaでやってみる The Twelve Factor App JJUG-CCC 2014 Fall 講演資料 by
Javaでやってみる The Twelve Factor App JJUG-CCC 2014 Fall 講演資料Javaでやってみる The Twelve Factor App JJUG-CCC 2014 Fall 講演資料
Javaでやってみる The Twelve Factor App JJUG-CCC 2014 Fall 講演資料Y Watanabe
25.8K views76 slides
20141116 jjug ccc_2014_keynote1_public by
20141116 jjug ccc_2014_keynote1_public20141116 jjug ccc_2014_keynote1_public
20141116 jjug ccc_2014_keynote1_publicYoshiharu Hashimoto
5.1K views79 slides

More Related Content

Recently uploaded

SSH超入門 by
SSH超入門SSH超入門
SSH超入門Toru Miyahara
363 views21 slides
onewedge_companyguide1 by
onewedge_companyguide1onewedge_companyguide1
onewedge_companyguide1ONEWEDGE1
27 views22 slides
図解で理解するvetKD by
図解で理解するvetKD図解で理解するvetKD
図解で理解するvetKDryoo toku
86 views22 slides
how query cost affects search behavior translated in JP by
how query cost affects search behavior translated in JPhow query cost affects search behavior translated in JP
how query cost affects search behavior translated in JPTobioka Ken
9 views16 slides
AIで始めるRustプログラミング #SolDevHub by
AIで始めるRustプログラミング #SolDevHubAIで始めるRustプログラミング #SolDevHub
AIで始めるRustプログラミング #SolDevHubK Kinzal
22 views25 slides
Najah Matsuo Self Introduction by
Najah Matsuo Self IntroductionNajah Matsuo Self Introduction
Najah Matsuo Self IntroductionNajahMatsuo
7 views29 slides

Recently uploaded(9)

onewedge_companyguide1 by ONEWEDGE1
onewedge_companyguide1onewedge_companyguide1
onewedge_companyguide1
ONEWEDGE127 views
図解で理解するvetKD by ryoo toku
図解で理解するvetKD図解で理解するvetKD
図解で理解するvetKD
ryoo toku86 views
how query cost affects search behavior translated in JP by Tobioka Ken
how query cost affects search behavior translated in JPhow query cost affects search behavior translated in JP
how query cost affects search behavior translated in JP
Tobioka Ken9 views
AIで始めるRustプログラミング #SolDevHub by K Kinzal
AIで始めるRustプログラミング #SolDevHubAIで始めるRustプログラミング #SolDevHub
AIで始めるRustプログラミング #SolDevHub
K Kinzal22 views
Najah Matsuo Self Introduction by NajahMatsuo
Najah Matsuo Self IntroductionNajah Matsuo Self Introduction
Najah Matsuo Self Introduction
NajahMatsuo7 views
JISTA月例会2023年12月 書籍『3カ月で改善!システム障害対応実践ガイド』ご紹介+失敗学と障害対応と私 by 修治 松浦
JISTA月例会2023年12月 書籍『3カ月で改善!システム障害対応実践ガイド』ご紹介+失敗学と障害対応と私JISTA月例会2023年12月 書籍『3カ月で改善!システム障害対応実践ガイド』ご紹介+失敗学と障害対応と私
JISTA月例会2023年12月 書籍『3カ月で改善!システム障害対応実践ガイド』ご紹介+失敗学と障害対応と私
修治 松浦122 views

Featured

ChatGPT and the Future of Work - Clark Boyd by
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
23.4K views69 slides
Getting into the tech field. what next by
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
5.6K views22 slides
Google's Just Not That Into You: Understanding Core Updates & Search Intent by
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
6.3K views99 slides
How to have difficult conversations by
How to have difficult conversations How to have difficult conversations
How to have difficult conversations Rajiv Jayarajah, MAppComm, ACC
4.9K views19 slides
Introduction to Data Science by
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
82.2K views51 slides
Time Management & Productivity - Best Practices by
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
169.7K views42 slides

Featured(20)

ChatGPT and the Future of Work - Clark Boyd by Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd23.4K views
Getting into the tech field. what next by Tessa Mero
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero5.6K views
Google's Just Not That Into You: Understanding Core Updates & Search Intent by Lily Ray
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray6.3K views
Time Management & Productivity - Best Practices by Vit Horky
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky169.7K views
The six step guide to practical project management by MindGenius
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius36.6K views
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright... by RachelPearson36
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson3612.6K views
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... by Applitools
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools55.5K views
12 Ways to Increase Your Influence at Work by GetSmarter
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter401.7K views
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... by DevGAMM Conference
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference3.6K views
Barbie - Brand Strategy Presentation by Erica Santiago
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago25.1K views
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well by Saba Software
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software25.2K views
Introduction to C Programming Language by Simplilearn
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn8.4K views
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr... by Palo Alto Software
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
Palo Alto Software88.4K views
9 Tips for a Work-free Vacation by Weekdone.com
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
Weekdone.com7.2K views
How to Map Your Future by SlideShop.com
How to Map Your FutureHow to Map Your Future
How to Map Your Future
SlideShop.com275.1K views

Akito.Tsukahara.PHPerKaigi2020