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
生成AIが出力するテストコードのリアル よくあるコードと改善のヒント
Search
starfish719
November 18, 2025
Technology
910
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
生成AIが出力するテストコードのリアル よくあるコードと改善のヒント
starfish719
November 18, 2025
More Decks by starfish719
See All by starfish719
VibeCodingからAgenticWorkflowへ
starfish719
0
1.7k
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
7.2k
「速く作る」から「正しく作る」へ ─ 生成AI時代の開発フロー改革の ロードマップと実行 ─
starfish719
3
14k
AI活用を推進するために ファインディが下した、一つの小さな決断
starfish719
1
460
生成AI時代のエンジニア育成 変わる時代と変わらないコト
starfish719
0
16k
【Claude Code】Plugins作成から始まったファインディの開発フロー改革
starfish719
0
1.2k
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
4.3k
生成AI時代に若手エンジニアが最初に覚えるべき内容と、その学習法
starfish719
2
970
開発生産性を上げるための生成AI活用術
starfish719
3
3.4k
Other Decks in Technology
See All in Technology
Claude Designがめちゃくちゃ便利なので使ってほしい
diggymo
0
180
生成AIを使って「人が」考える技術 ― AI時代の人機共想と実践ノウハウ|UNITT AC2026
ishiirikie
0
510
IR Today: Theory, Practice, and Agents
dtunkelang
0
310
「とりあえず動く」の先へ。 AI時代のチーム開発と内部設計/2026-slsdays
slsops
0
100
GitHub Agentic Workflows を触ってみる
htkym
2
910
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
100
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
120
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
AI感のないAWS構成図をAIエージェントに描かせたい!
sagochiko
2
490
1人アドミンな私はAWSアカウント申請をSlackで完結したい!
ysuzuki
0
110
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
120
AI臭い文章とは何なのか
nasuvitz
37
76k
Featured
See All Featured
Speed Design
sergeychernyshev
33
2.1k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
520
First, design no harm
axbom
PRO
2
1.3k
30 Presentation Tips
portentint
PRO
1
410
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Making Projects Easy
brettharned
120
6.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
The SEO identity crisis: Don't let AI make you average
varn
0
570
A designer walks into a library…
pauljervisheath
211
25k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
RailsConf 2023
tenderlove
30
1.6k
Transcript
© Findy Inc. 2025.11 Findy AI Meetup ⽣成AIが出⼒するテストコードのリアル よくあるコードと改善のヒント 1
ファインディ株式会社 テックリードマネージャー ⼾⽥ 千隼 @starfish0206
© Findy Inc. 2 ⽣成AI時代のテストコードの役割
© Findy Inc. 3 暴⾛を防ぐためのガードレール • テストコードが持つ役割 ◦ 仕様を把握するための情報源 ◦
暴⾛しないためのガードレール • ⽣成AIが出⼒したコードが原因で既存のテストコードが失敗した場合 ◦ エラー内容を元に⽣成AIが実装または、テストコードを修正する ◦ エラーの原因がどこにあるのかの判断を間違えないことがポイント • 「何が正しいのか」を⽣成AIが理解することで、出⼒内容の⽅向性がズレないようにする
© Findy Inc. 4 ⽣成されるテストコードの実状と改善⽅法
© Findy Inc. 不要な新規ケースが追加される 5
© Findy Inc. 6 どんどんテストケースが追加されてしまう • 既存のテストケースに⼿を加えればいいだけなのに、新しいテストケースが追加されてし まう ◦ モデルなどに項⽬追加する時に⾒られる
• テストケースの名称がポイントになる
© Findy Inc. 7 class TestUserModel: def test_user_attributes(self): user =
User( name="Test User", is_deleted=True ) assert user.name == "Test User" assert user.is_deleted is True def test_user_default_is_deleted(self): user = User( name="Test User", ) assert user.is_deleted is False
© Findy Inc. 8 class TestUserModel: def test_user_attributes(self): user =
User( name="Test User", role="admin", is_deleted=True ) assert user.name == "Test User" assert user.role == "admin" assert user.is_deleted is True def test_user_default_is_deleted(self): user = User( name="Test User", ) assert user.is_deleted is False def test_user_default_role(self): user = User( name="Test User", ) assert user.role == "member"
© Findy Inc. 9 class TestUserModel: def test_user_attributes(self): user =
User( name="Test User", role="admin", is_deleted=True ) assert user.name == "Test User" assert user.role == "admin" assert user.is_deleted is True def test_user_default_is_deleted(self): user = User( name="Test User", ) assert user.is_deleted is False def test_user_default_role(self): user = User( name="Test User", ) assert user.role == "member"
© Findy Inc. 10 class TestUserModel: def test_user_attributes(self): user =
User( name="Test User", role="admin", is_deleted=True ) assert user.name == "Test User" assert user.role == "admin" assert user.is_deleted is True def test_user_default_attributes(self): user = User( name="Test User", ) assert user.role == "member" assert user.is_deleted is False
© Findy Inc. 11 class TestUserModel: def test_user_attributes(self): user =
User( name="Test User", role="admin", is_deleted=True ) assert user.name == "Test User" assert user.role == "admin" assert user.is_deleted is True def test_user_default_attributes(self): user = User( name="Test User", ) assert user.role == "member" assert user.is_deleted is False まずは既存のテストコードを⾒直す
© Findy Inc. テストを通すためのテスト 12
© Findy Inc. 13 無理やりテストを通そうとする • テストを通すための修正をやりがち ◦ テストが通るまでトライアンドエラーを繰り返す ◦
⾊々試している流れでテストが通ったら、それが正解だと判断されてしまう • 適切にmockを使いましょう
© Findy Inc. 14 class TestEmailService: def test_create_invite_mail_body(self): to_email =
"
[email protected]
" invite_link = "https://example.com/invite/12345" text_body = email_service.create_invite_mail_body(to_email, invite_link) assert f"{to_email}様" in text_body assert invite_link in text_body assert "このリンクの有効期限は " in text_body assert "です" in text_body
© Findy Inc. 15 class TestEmailService: def test_create_invite_mail_body(self): to_email =
"
[email protected]
" invite_link = "https://example.com/invite/12345" text_body = email_service.create_invite_mail_body(to_email, invite_link) assert f"{to_email}様" in text_body assert invite_link in text_body assert "このリンクの有効期限は " in text_body assert "です" in text_body - 有効期限の⽇時の確認が漏れている - 意図しない⽂字列が⼊っていても通っ てしまう
© Findy Inc. 16 class TestEmailService: def test_create_invite_mail_body(self, monkeypatch): mock_datetime
= MagicMock() mock_datetime.now.return_value = datetime(2025, 11, 1, 0, 0, 0, tzinfo=UTC) monkeypatch.setattr("src.service.email.datetime", mock_datetime) to_email = "
[email protected]
" invite_link = "https://example.com/invite/12345" text_body = email_service.create_invite_mail_body(to_email, invite_link) assert text_body == f"{to_email}様\n{invite_link}\nこのリンクの有効期限は 2025/11/15 です。"
© Findy Inc. 17 class TestEmailService: def test_create_invite_mail_body(self, monkeypatch): mock_datetime
= MagicMock() mock_datetime.now.return_value = datetime(2025, 11, 1, 0, 0, 0, tzinfo=UTC) monkeypatch.setattr("src.service.email.datetime", mock_datetime) to_email = "
[email protected]
" invite_link = "https://example.com/invite/12345" text_body = email_service.create_invite_mail_body(to_email, invite_link) assert text_body == f"{to_email}様\n{invite_link}\nこのリンクの有効期限は 2025/11/15 です。" ケースに応じたmockの使⽤⽅法を カスタムインストラクションなどに 追記
© Findy Inc. システムを守るテスト 18
© Findy Inc. 19 現状は問題ないが、拡張してもコケてくれない • テストを通すことが⽬的ではない ◦ 適切な理由とタイミングでコケるのが良いテスト •
意図しない変更を、テストがコケることで事前に検知したい ◦ 何がどうなったらテストがコケてくれるのかをイメージしましょう
© Findy Inc. 20 class TestGetUserById: def test_get_user_by_id_success(self, client): target_user
= User( name="Test User", ) response = client.get(f"/api/v1/users/{target_user.id}") assert response.status_code == status.HTTP_200_OK assert response["id"] == target_user.id assert response["name"] == "Test User"
© Findy Inc. 21 class TestGetUserById: def test_get_user_by_id_success(self, client): target_user
= User( name="Test User", ) response = client.get(f"/api/v1/users/{target_user.id}") assert response.status_code == status.HTTP_200_OK assert response["id"] == target_user.id assert response["name"] == "Test User" responseに項⽬が 追加されてもコケない
© Findy Inc. 22 class TestGetUserById: def test_get_user_by_id_success(self, client): target_user
= User( name="Test User", ) response = client.get(f"/api/v1/users/{target_user.id}") assert response.status_code == status.HTTP_200_OK assert response.json() == { "id": target_user.id, "name": "Test User", }
© Findy Inc. class TestGetUserById: def test_get_user_by_id_success(self, client): target_user =
User( name="Test User", ) response = client.get(f"/api/v1/users/{target_user.id}") assert response.status_code == status.HTTP_200_OK assert response.json() == { "id": target_user.id, "name": "Test User", } 23 意図しない項⽬追加時に コケてくれる ケースごとの テストのサンプルコードを カスタムインストラクションに追記
© Findy Inc. 24 まとめ
© Findy Inc. まとめ 25 • ⽣成AIが出⼒するテストコードの質には伸び代がある ◦ 伸び代ポイントを⾒つけた場合 ▪
既存のテストコードの⾒直し ▪ カスタムインストラクションなどにサンプルコードを記述 • ⽣成AI時代のテストコードが持つ役割は、今までよりも重要になった ◦ 出⼒される実装コードの質を向上させるために、テストコードとも向き合いましょう ファインディに興味がある⽅は、ぜひカジュアル⾯談しましょう
© Findy Inc. ご清聴ありがとうございました 26