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
次世代タクシー配車サービス「MOV」におけるテスト事例紹介
Search
tokubass
July 18, 2019
Programming
1.3k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
次世代タクシー配車サービス「MOV」におけるテスト事例紹介
- MOV紹介
- 前提環境
- テストを書く上での方針
- 並列テストのためのデータ生成
- DIできないコードと戦う
- その他tips
tokubass
July 18, 2019
Other Decks in Programming
See All in Programming
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
190
The Rails Doctrine Decade
koic
2
520
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
260
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
200
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
130
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
450
Are APIs Still Relevant in the AI Era?
soyuka
0
430
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.9k
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
310
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
110
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
760
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
450
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
730
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.1k
BBQ
matthewcrist
90
10k
For a Future-Friendly Web
brad_frost
184
10k
The Invisible Side of Design
smashingmag
301
52k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Building an army of robots
kneath
307
47k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
350
What's in a price? How to price your products and services
michaelherold
247
13k
Transcript
次世代タクシー配車サービス「MOV 」における テスト事例紹介 DeNA.go #2 オートモーティブ事業本部 toku_bass 1
目次 MOV 紹介 前提環境 テストを書く上での方針 並列テストのためのデータ生成 DI できないコードと戦う その他tips 2
MOV 紹介 3
MOV 紹介 2018/04 神奈川県 地域限定でリリース 2018/06 神奈川県 対象エリア拡大 2018/12 東京都
リリース 2019/07 大阪府、京都府 リリース 4
発表の前提 GAE/Go 1st MOV API サーバーで使用 test 実行方法 local でgoapp
test CircleCI chatbot E2E 5
テストを書く上での方針 注目しているtestcase 以外の暗黙のデータに依存しない テスト全体に関わる xture を使わない 並列(testing.T.Parallel )でテスト実行 6
テスト全体に関わる xture を使わない テスト実行前にマスターデータ以外をDB にload しない テストが初期 xture に依存するようになる 7
並列でテスト実行 testing.T.Parallel() をしたいがグローバルな状態をもつDB がネック user_id=1 のような固定値を書かないようにする github.com/bxcodec/faker (のv3 )がいい 8
並列テストのためのデータ生成 前述の github.com/bxcodec/faker を使用 テスト用のユーザを作りたい場合などに構造体のgotag を利用してダミ ーデータを生成する type User struct
{ Name string // ランダムな文字列を生成 Email string `faker:"email"` // email 形式で生成 } s := SomeStruct{} faker.FakeData(&s) faker:"email" のようにデフォルトで用意されているタグ以外にもプロダ クト用に自作のtag を作ることができる 9
faker のMOV での利用例 テスト用のtag をプロダクトコードに記述したくないという意見がで たため、静的解析で同等の構造体を別名で生成しgotag を付与 primary key がランダム値が偶然被らないように管理(todo)
id 採番アルゴリズム採用(go-katsubushi など) 10
DI できないコードと戦う すべてDI できればいいが、現実は厳しい。 特にtime.Now() はどこにでも現れる 11
time.Now - DI できないコードと戦う time.Now 定義をpackage 変数に保存し、ラッパー関数経由で呼び出 す テスト時にだけpackage 変数を書き換えるsetter
をビルド対象に含め る build タグを使用する 12
ラッパー package util var nowFunc func() time.Time func init() {
// setter 関数はテスト時にしか定義されない nowFunc = time.Now } func Now() time.Time { return nowFunc() } 13
setter // +build test package util import ( "sync" "time"
) var m sync.Mutex func SetNowFunc(f func() time.Time) func() { m.Lock() nowFunc = f return func() { m.Unlock() } } 14
利用例 func TestXXXX(t *testing.T) { unlock := util.SetNowFunc(func() time.Time {
return time.Date(...) // 省略 }) defer unlock() ... } 15
Client 実装をファイル単位で偽装 - DI できない コードと戦う build タグを使うことでファイル単位で偽装する大技 基本アイデア link
利用例 var gotMessageText string reset := infra.SetMock_Send(func(message domain.MailMessage) error { gotMessageText = message.TextPart return nil }) defer reset() 16
その他tips testerator pstest 17
testerator GAE 用のテストサーバーの起動には3 秒ほどかかるため、テストケー スごとに上げ下げしないためのライブラリ SpinUp 関数を呼ぶと、起動済みサーバーの情報か、起動していなけ れば改めて起動して情報を返す ins, ctx,
err := testerator.SpinUp() しかし、たまに意図せずテストサーバーが落ちる問題がおきた 18
testerator がサーバーを落とす条件 内部カウンター(Setup.counter) が0 になったとき SpinUp で+1, SpinDown で-1 Setup.total
% Setup.ResetThreshold == 0 のとき total はSpinUp のときに+1 される RestThreshold はデフォルトで1000 counter が0 にならないように中央管理 テストごとに実装者がSpinUp,SpinDown を記述していると内部カウ ンタが0 になるタイミングが発生した SpinUp するラッパー関数を用意し中央管理 19
Cloud PubSub 依存のテスト pstest が便利 Cloud PubSub の公式ライブラリのテスト方法 どうやってテストすればいいのか悩んだ場合はライブラリそのもののテ ストを確認しにいくと良い
20