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
ミューテーション解析について調べた/2019-02-26-llt7
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Satoshi SAKAO
February 26, 2019
Technology
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ミューテーション解析について調べた/2019-02-26-llt7
社内のLTイベント「えるLT Vol.7」で発表した資料です
Satoshi SAKAO
February 26, 2019
More Decks by Satoshi SAKAO
See All by Satoshi SAKAO
Testcontainers/2024-11-20-llt32
ottijp
0
120
Pkl/2024-04-17-llt31
ottijp
0
130
JavaScriptのデバッグ/2023-09-04-llt30
ottijp
0
200
CDK for TerraformでAzureリソースをデプロイする/2023-05-15-llt29
ottijp
1
350
TWELITEへの誘い/2022-12-27-llt28
ottijp
0
190
ビルドツールBazelを触ってみた/2022-09-28-llt27
ottijp
0
230
HashiCorp Vaultを使ったシークレットのセキュアな一元管理 〜Ansibleを添えて〜/2022-07-12-llt26
ottijp
0
190
AWSインフラのデプロイをCDKでカイゼンする/2022-03-23-llt25
ottijp
0
130
Amazon Timestreamでデータ補間/2021-12-27-llt24
ottijp
0
130
Other Decks in Technology
See All in Technology
AIエージェントの自己改善をどう設計するか / How to Design Self-Improvement for AI Agents
22mi
25
16k
新機種発売前に見直そう!端末移行で再ログインが要るアプリ・要らないアプリは何が違うのか 〜シームレスに再開できる設計と実装〜
zozotech
PRO
0
200
GoのInterface内部構造から学ぶ!最高パフォーマンスを出すコード設計
yappli_developers
0
110
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
3k
LLMに渡さなかった仕事
nanaism
0
360
10分で知る最近のOmarchy
komagata
0
350
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
740
生成AIエージェントを用いた、 手動テスト手順書から自動テストへの 変換手法の検討
magicpod
0
160
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
3
3.1k
開発投資の期待値を上げるプロダクトロードマップづくり ~プロダクトエンジニアが越境して事業を伸ばす~
kekekenta
1
190
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
330
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
510
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5.2k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
So, you think you're a good person
axbom
PRO
2
2.2k
WCS-LA-2024
lcolladotor
0
830
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.9k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
What's in a price? How to price your products and services
michaelherold
247
13k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Transcript
ミューテーション解析について調べた Satoshi SAKAO えるLT Vol.7 2019/02/26 (Tue) N1
話すひと N2 インフォコム株式会社 オープンイノベーションセンター # アプリケーションエンジニア JS (ES6) / Node.js
/ GCP / IoT / iOS (Swift) エースコンバット7 / 技術士合格に向けた学習 Satoshi SAKAO @ottijp
N3 ミューテーション解析?
ミューテーション解析とは • = ミューテーションテスト • テストの十分さを測定する手法 • 欠陥を含むプログラムを生成(ミューテーション操作)し, それを検出できるかどうかで,テストの欠陥検出能力を測る •
さらなるテストケース作成の必要性などの評価に利用できる N4
図解 N5 https://codezine.jp/article/detail/10066
具体例 N6 // monthが0〜11ならtrueを返す function isValid(month) { return month >=
0 && month <= 11 } return month < 0 && month <= 11 return month >= 0 && month > 11 ミューテーション操作 ミュータント ミュータント
具体例 N7 return month >= 0 && month <= 11
return month < 0 && month <= 11 return month >= 0 && month > 11 望ましいテスト結果 テストの失敗が期待される
Swiftでやってみる N8 https://github.com/SeanROlszewski/muter
Swiftでやってみる N9 class MonthValidator { /// monthが0〜11であればtrueを返す func isValid(_ month:
Int) -> Bool { return month >= 0 && month <= 11 } } // more Swifty return 0...11 ~= month
Swiftでやってみる N10 final class swift_muterTests: XCTestCase { func testMonthValidator_valid() {
XCTAssertEqual(MonthValidator().isValid(11), true) } func testMonthValidator_inValid() { XCTAssertEqual(MonthValidator().isValid(-1), false) } } 11 TRUE -1 FALSE
Swiftでやってみる N11 $ muter -------------------------- Applied Mutation Operators -------------------------- File
Position Applied Mutation Operator Mutation Test Result ---- -------- ------------------------- -------------------- swift_muter.swift Line: 4, Column: 18 Negate Conditionals passed swift_muter.swift Line: 4, Column: 32 Negate Conditionals failed -------------------- Mutation Test Scores -------------------- Mutation Score of Test Suite (higher is better): 50/100 File # of Applied Mutation Operators Mutation Score ---- ------------------------------- -------------- swift_muter.swift 2 50 ん?
Swiftでやってみる N12 return month >= 0 && month >= 11
2つめのミュータント 11 TRUE -1 FALSE ミュータントの欠陥を検出できない
Swiftでやってみる N13 func testMonthValidator_inValid_over11() { XCTAssertEqual(MonthValidator().isValid(12), false) } テストを追加 11
TRUE -1 FALSE 12 FALSE 欠陥を検出できるようになった
Swiftでやってみる N14 $ muter -------------------------- Applied Mutation Operators -------------------------- File
Position Applied Mutation Operator Mutation Test Result ---- -------- ------------------------- -------------------- swift_muter.swift Line: 4, Column: 18 Negate Conditionals passed swift_muter.swift Line: 4, Column: 32 Negate Conditionals passed -------------------- Mutation Test Scores -------------------- Mutation Score of Test Suite (higher is better): 100/100 File # of Applied Mutation Operators Mutation Score ---- ------------------------------- -------------- swift_muter.swift 2 100 OK
課題:等価ミュータント • 元のプログラムと常に同じように振る舞うミュータント (等価ミュータント)が発生しうる • このミュータントをkillするようなテストケースの生成は不可能 • ミューテーション解析を実用に移すことを阻む大きな障害の一つ N15
まとめ • ミューテーション解析で,テストの欠陥検出能力を測定できる • テストの十分さを評価する指標として活用できる • 実用には等価ミュータントに注意 N16
$ exit N17
N18 Appendix
留意点 • muterはプロジェクトディレクトリのキャッシュが悪さしがちなので注意 • Muter sometimes fails on Swift PM
projects, probably due to module cache problems · Issue #72 · SeanROlszewski/muter • https://github.com/SeanROlszewski/muter/issues/72 • swift package clean できれいにしてあげると通る • muterはまだ比較演算子のミューテーションしか対応していない • LLVMレベルのミューテーション解析ライブラリもあったが試していない N19
等価ミュータントの例 N20 func isEven(_ n: Int) -> Bool { return
n % 2 == 0 } ミュータント return -n % 2 == 0 ミュータントをkillするテストは書けない
refs • ミューテーション解析 - Wikipedia • https://ja.wikipedia.org/ミューテーション解析 • ミューテーションテストに触れてみよう |
ギャップロ • https://www.gaprot.jp/pickup/tips/mutation-testing • ソフトウェアのテスト品質を効果的に測定するミューテーション 解析 (1/3):CodeZine(コードジン) • https://codezine.jp/article/detail/10066 N21