Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
はじめてのミューテーション解析 / Mutation Testing
Search
kazusuke sasezaki
August 19, 2019
Technology
1.7k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
はじめてのミューテーション解析 / Mutation Testing
社内勉強会向けに作成した資料です
kazusuke sasezaki
August 19, 2019
Transcript
26 slides
はじめてのミューテーション解 析/ Mutation testing 2019年 8月19日 社内勉強会
今、Mutation testingが熱い! - Tests Coverage is Dead — Long Live
Mutation Testing - https://medium.com/appsflyer/tests-coverage-is-dead-long-live-mutation-testing-7fd61020330e - カンファレンス・meetupでのフィードバックサイト joind.inでの検索結果 - https://joind.in/search?keyword=mutation ・・・PHP界隈では(多分)
ほかの言語界隈だと・・・ - 「Javaの鉱脈」でPITの記事を書きました | さにあらず : https://blog.satotaichi.info/mutation-testing/ - テストをテストする方法-ミューテーションテスト- #gadvent
- うさぎ組 : http://kyon-mm.hatenablog.com/entry/2014/12/12/120000 - Mutation Testing with Ruby - (define -ayalog '()) : http://ayato.hateblo.jp/entry/20150202/1422839583 ※ ミュータント解析の提案は1993年とのことです http://jasst.jp/archives/jasst04/pdf/A5dh.pdf
用語の確認
ミューテーション解析 > テストスイートの完全性を判定する手法の一つ。プログラムのわずかな変形(変異)を テストスイートがどの程度識別できるかを測定する。 https://www.qbook.jp/qpterm/search?initial=%E3%81%BF http://jstqb.jp/dl/JSTQB-glossary.V2.3.J02.pdf
ミューテーションテスト (mutation testing) > back-to-back testingを参照のこと。 https://www.qbook.jp/qpterm/search?initial=%E3%81%BF http://jstqb.jp/dl/JSTQB-glossary.V2.3.J02.pdf
ミューテーション解析 > ミューテーション解析(ミューテーションテスト[1]、ミューテーション法)はソフトウェアテ ストにおける、テストスイートの十分さを測定するための手法である。この手法では、テ スト対象のプログラムの一部を機械的に書き換えることで、ミュータントと呼ばれる「人工 的な誤りを含むプログラム」を生成する。 https://ja.wikipedia.org/wiki/%E3%83%9F%E3%83%A5%E3%83%BC%E3%83%8 6%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E8%A7%A3%E6%9E %90
ミューテーション解析 > 脚注 ^ mutation analysisよりもmutation testingという単語が広く使われているが、 ミューテーション解析はソフトウェアが想定通りに実装されていることを直接確かめるテ スティングとは異なり、テスティングで利用されるテストケースの品質を評価するための 手法である。従って、本稿ではミューテーション解析という用語を主に利用する。
https://ja.wikipedia.org/wiki/%E3%83%9F%E3%83%A5%E3%83%BC%E3%83%8 6%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E8%A7%A3%E6%9E %90
なので、個人的には「ミューテーション解析」か「Mutation testing」という語に合わせたい と思ってます
どうやって測定するのか
どうやって測定するのか ・・・wikipedia「ミューテーション解析」のつづき > テストスイートをミュータントに対して実行した結果と、元のプログラムに対して実行し た結果が異なれば、テストスイートにはその誤りを発見するだけの鋭敏さが備わってい ると考えられるだろう(テストスイートはミュータントをkillすると表現する)。機械的に大量 にミュータントを生成したとき、そのうちテストスイートがkill出来るミュータントの割合を測 定することで、テストスイートの「欠陥発見能力」の十分さを測定することが出来る。 https://ja.wikipedia.org/wiki/%E3%83%9F%E3%83%A5%E3%83%BC%E3%83%8 6%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E8%A7%A3%E6%9E
%90
どうやって測定するのか ・・・ほかの方の説明では > Mutation testing とは、プログラムに対するテストケースが十分であるかを測定する手 法です。テスト対象のプログラムを機械的に変更してバグを埋め込み、テストがちゃんと 失敗するかどうかを調べます。バグのあるプログラムをテストするので、テストの失敗は バグを検出できたことを意味します。さまざまなバグを作り出してテストを行い、バグの 検出率によってテストケースの十分さを測定します。
https://y-uti.hatenablog.jp/entry/2018/11/18/161639
実際に Mutation testingツールを使ってみる
https://devblog.thebase.in/en try/2019/06/13/110000 より一部改変
None
None
None
10桁の場合の検出が されてないことが 分かる
10桁の場合のテストを追加して 再実行
None
実際のaudiobook.jpのコードに適用した場合(demo)
今回の PHPのmutation testingツール Infectionで用意 されているミューテター https://infection.github.io/guide/mutators.html
拡張として mbstringのミューテーターもあります https://infection.github.io/2019/05/18/whats-new-in-0. 13.0/#mbstring-mutators
ちょっと試してみての感想 - まず(行ベースの)コードカバレッジを100%にしないといけないことには変わりない(周知の事実) - (PHPでに限らず?) カバレッジをとったりいくつものミューテーションを実行するので割と実行時間が長い - https://speakerdeck.com/theofidry/mutation-testing-phpdeveloperday?slide=85
- PHP/Infection に限って言えば、まだ変形させられるものは一杯ある。 - 境界値テストの代わりになる。・・と思ったらダメ - コンポーネントの安心感にはつながりそう
各言語ごとのミューテーションツール一覧など theofidry/awesome-mutation-testing: Mutation testing resources: how to make better code
by introducing bugs - https://github.com/theofidry/awesome-mutation-te sting
表紙・イラスト https://hiyokoyarou.com/flower-color/ おわり
More Decks by kazusuke sasezaki
See All by kazusuke sasezaki
PHPでの .gitattributes
sasezaki
0
190
できる!!! Validation !!! - builderscon tokyo 2017
sasezaki
1
220
こんなPHP開発者はイヤだ
sasezaki
2
3.9k
Introduction of Web scraping for PHP users
sasezaki
0
140
Other Decks in Technology
See All in Technology
大江戸Ruby会議でデータベース クライアントの話をするのは 間違っているだろうか
yahonda
1
120
81天的 AI Agent 軟體開發團隊治理實務分享
regionbbs
0
160
プロダクションコードにおける encoding/json から encoding/json/v2 へのスムーズな移行
sansantech
PRO
1
410
人間+AIを「チーム」としてプロセスを再設計する
littlehands
1
1.2k
生成AI時代のIAMのマニアックな話
takuros
6
3.2k
これからのデータエンジニアの役割について考える / Rethinking the Role of Data Engineers in the AI Era
okiyuki99
0
470
複数システムが同居した 15 年物の AWS アカウントを解体するための考古学
wa6sn
3
140
Biohub - Cell Tracking During Development 5th place solution
rist
0
150
Linuxネットワークスタック進化の軌跡: 過去10年の歩みと最新トレンド
orimanabu
3
600
AWSを利用する上で知っておきたい名前解決の話 2026
nagisa53
5
3.6k
小さなエージェントから始めてみよう!実践コンテキストエンジニアリング
iwamot
PRO
0
120
セキュリティ専任チームなしで攻撃を先回りするSREが実践したSIEM on Amazon OpenSearch Service
cscengineer
PRO
1
860
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
Designing Powerful Visuals for Engaging Learning
tmiket
1
650
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Building AI with AI
inesmontani
PRO
1
1.4k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
470
Building Flexible Design Systems
yeseniaperezcruz
330
41k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
900
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k