SlideShare a Scribd company logo
1 of 36
テスト自動化の勉強会
やはり俺達の回帰テストは間違っている
Yusuke Hosonuma
最初に
言っておくことがある
やはり
俺達の回帰テスト
は間違っている
回帰(リグレッション)テスト
・回帰テスト?人海戦術だね(ドヤッ
・回帰テスト?そんな時間ないでしょ?
・回帰テスト?なにそれ美味しいの?
もはや時代錯誤もいいところ
朗報
『テストの自動化』
という考え方があります
・テストをプログラムで記述する
・ことにより何度でも自動でテストできる
・ことにより変更に強くなる
・ことにより変更に対して勇気を持てる
テストの自動化とは?
『作業面』として
→ 回帰テストのコストを減らせる
『心理面』として
→ 仕様変更やリファクタリング、
そして何よりリリースに勇気を持てる
つまり・・・
Question & Answer
・回帰テストやってますか?
・それで十分だと本当に思っていますか?
・仕様変更に自信を持てていますか?
・リリースの度に不安を抱えていませんか?
・リファクタリングしてますか?
・いつまでこんなことを続ける気ですか?
Question.
今のあなたの答えは重要ではありません。
これから現状を少しでも変えたいかどうか、
その気持ちと勇気があるかが重要です。
Answer.
・単体テスティングフレームワーク、通称「
xUnit」は、Java向けのJUnitが最初ですが、
現在は殆どの言語に用意されています。
・OSSでも積極的に利用されています。例え
ばHTTPServerであるApacheのテストコード
は、本体コードの10倍ちかくなっています。
xUnit
xUnitによるユニットテスト
・Objective-C向けのxUnit
・Xcodeに標準搭載されている
・既存プロジェクトへの導入も簡単
XCTest(えっくすしーてすと)
・メソッド単位で完結するテスト
→ 2つの引数を足し算するとか
・状態を変更するメソッドのテスト
→ リストオブジェクトから削除とか
XCTestで出来ること
・UI(画面)のテスト
→ 一般的にはUnitTestでUIのテストは自動化し
ません。難しいし、その価値に見合うリターン
が得られないことが多いからです。
・マクロのテスト
→ プリプロセッサなどObjective-Cランタイム
から外れるものはテスト出来ません。
XCTestで出来ないこと
①テスト対象の関数を呼び出す
NSInteger price = [Money tax:100];
②期待値と比較する
XCTAssertEqual(108, price, @”100円の消
費税は108円であること);
XCTestの基本
XCTest on Xcode
・Modelクラス
→ MVCにおいて一番変更が少ない。
・Util/Helperクラス
→ 関数単位で処理が完結することが多く書き
やすい。
テストコードを書くべき箇所
・Red
→ テストの失敗
・Green
→ テストの成功
・リファクタリング
→ Greenである限りリファクタリングは成功
Red / Green / Refactoring
現実を直視する
・テストを定期的に実行する
→ Greenな状態を保たなければ、テストを自
動化する意味がありません。
・Greenであれば大丈夫という勘違いをしない
→ テストコード、あるいは仕様自体が間違っ
ていたら全く意味がありません。
あなたが絶対に守るべきこと
・自動化すると品質上がる
→ 一側面ではありますが、これを強く語る人
は夢を見すぎている傾向が強いです。
現実を見ましょう。手でテストしたほうが効率
的なケースも多々有ります。
よくある間違った認識①
・だれでも書ける
→ 一定のスキルが必要です。
xUnitを使うスキル。そして何より単体テスト
しやすいコードを書くスキルが必要になります
。
よくある間違った認識②
・テスト対象のコードは完璧な設計
→ 時にはテスト対象のコードをリファクタリ
ングする必要もあります。
ぐちゃぐちゃな依存関係のクラスをテストする
のは苦痛ですし、少し変更が入るたびにテスト
が失敗するようになり意味がありません。
よくある間違った認識③
・ユニットテストはコストが低い
→ 実装コストの2倍は必要と言われます。
2倍は一般論であり、それに見合うだけのメリ
ットがあるケースも十分あります。ただ、その
コストを受け入れることが出来るかはプロジェ
クト次第です。
よくある間違った認識④
・結合テストは不要
→ ・・・
目をさませ!!( 'д'⊂彡☆))Д´) パーン
よくある間違った認識⑤
まとめ
・何度でも自動で実行できるテスト
・それによって得られるデグレの防止
・それによって得られる変更に対する勇気
・安全なリファクタリング
ユニットテストで得られるもの
・UI(画面)まわりのテスト
・結合レベルでの品質保証
ユニットテストで得られないもの
・ユニットテストのスキルを身につける
・テストコードを書く
・テストコードを定期的に実行する
・テストコードをメンテナンスする
ユニットテストで払う必要のある対価
最後に
・ユニットテストの一部についてしか、この資
料では語っていません。
・一般論はあくまで一般論であり、あなたのプ
ロジェクトに当てはまるかは分かりません。
・ユニットテストはソフトウェア開発技法の一
つであり、それ以上でも以下でもありません。
注意事項
想像してごらん・・・
リリース前に全ての単体テストが成功すること
を確認できる・・・
そんな世界(ソフトウェア開発)を。
Let’s UnitTest
ご清聴ありがとう
ございました!

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - 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 Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
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...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
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...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
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...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - 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
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
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...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
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...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
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...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

iOSテスト自動化勉強会 -やはり俺達の回帰テストは間違っている-