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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
More Decks by kazusuke sasezaki
See All by kazusuke sasezaki
PHPでの .gitattributes
sasezaki
0
160
できる!!! Validation !!! - builderscon tokyo 2017
sasezaki
1
210
こんなPHP開発者はイヤだ
sasezaki
2
3.9k
Introduction of Web scraping for PHP users
sasezaki
0
140
Other Decks in Technology
See All in Technology
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
32
32k
LLMに渡さなかった仕事
nanaism
0
12k
「今盗んで、後で解く」に備える ― AWSのポスト量子暗号入門
yama3133
2
250
「ピッケル本」日本語版は4.0(第6版)が出版されるべき / pickaxe4-nagoyark05
kakutani
2
300
2026-09-18 gotanda.sre Terraformで複数環境作ったり、複数Stateに分割したりそれとTerragrunt / Terraform multi envs and multi states
masasuzu
4
750
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
170
高負荷プロダクション環境におけるAWS Lambdaのリアル 〜スケールとコストを左右する実行ライフサイクルの技術仕様〜
maimyyym
2
630
AIエージェント時代のPlatform as a Product —— テックリードがPdMとして回す発見・導入・計測 / Platform as a Product in the AI Agent Era
toshi0607
0
200
特殊変数大全
dak2
0
140
Hermes Agentで、AIが調べて記事を書くブログを作った話
blueb
0
110
GitHub Agentic Workflows を触ってみる
htkym
2
660
「大丈夫そう?」をObservabilityで確かめる
mrmtsu
0
170
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
Crafting Experiences
bethany
1
350
Tell your own story through comics
letsgokoyo
1
1.1k
New Earth Scene 8
popppiees
4
2.6k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
710
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
540
Thoughts on Productivity
jonyablonski
76
5.4k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Optimizing for Happiness
mojombo
378
71k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
The Pragmatic Product Professional
lauravandoore
37
7.5k
Visualization
eitanlees
153
17k
Transcript
はじめてのミューテーション解 析/ 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/ おわり