Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Specs2入門
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Nguyen Hong Phuc
October 21, 2016
Technology
860
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Specs2入門
Nguyen Hong Phuc
October 21, 2016
Other Decks in Technology
See All in Technology
Tab5をRubyで動くパソコンにする
kishima
1
180
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
230
PdMをやめて、 "プロダクトビルダー"という 働き方に変えました / PdM to Product Builder
shikichee
2
710
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
1
570
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
880
生成AI時代の クレデンシャルとパーミッション設計
nrinetcom
PRO
3
1.5k
Beyond the Hype: Practical AI for Your Oracle Database with MCP
thatjeffsmith
1
260
Bet AI Day 2026丨Agentは、「金融」という巨大産業の何を変えられるのか
layerx
PRO
0
780
AIで実装は速くなった。なのにプロダクトは速くならない。職能の壁を越えて価値のフローを設計する
nwiizo
6
7k
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
2
170
Level Up Your CDK DX: 5 Tools I’ve Been Building
gotok365
2
190
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
180
Featured
See All Featured
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
510
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
490
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
470
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
For a Future-Friendly Web
brad_frost
183
10k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.7k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Being A Developer After 40
akosma
91
590k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
510
Transcript
Specs2テスト入門 Nguyen Hong Phuc (フック)
早速 Specs2でテストを書いてみる
OpenRtb BidRequest Specs Take from https://github.com/openrtb/OpenRTB/blob/master/OpenRTB-API-Specification-Version-2-3-1-FINAL.pdf
BidRequest Class
正確なBidRequestは 1. BidRequest.idが空白文字列ではない 2. BidRequest.impがnon-empty配列 3. BidRequest.imp.idが空白文字列ではない 4. …
Simple BidRequest Test
Simple BidRequest Tests ← CODE IS NOT “DRY” Take from:
http://www.slideshare.net/ardentlearner/the-principles-of-good-programming
Keep our code is DRY with Specs2 style
Specs2のMatcherを使ってみる
Matcherについて データがあれば、それが正しいかどうかを確認したいとき、 最も一般的に利用されるMatcherであります
Matcherについて 赤い下線のところはMatcherです
Matcherの種類 Specs2で色々な Matcherが定義されている - StringMatchers - NumericMatchers - OptionMatchers -
TraversableMatchers - FutureMatchers (scala.concurrent.Future) - FutureZMatchers (scalaz.concurrent.Future向け) - XorMatchers (catsライブラリ向け) - … Reference Card: https://etorreborre.github.io/specs2/guide/SPECS2-3.8.5/org.specs2.guide.matchers.ReferenceCard.html Matcher collection: https://github.com/etorreborre/specs2/tree/master/matcher/src/main/scala/org/specs2/matcher
“beAValidBidRequest” Matcher Create BidRequest Matcher
Before After ➡
テストケースが失敗のとき
実行結果
Expectation Description改善 “aka”を利用する
Expectation Description改善
テストを生成する
テスト生成 Example
実行結果
テストグループに入れてみる
コンパイルできなくなった
def foreach(f: (A) => Unit): Unit
Fragmentsでテストを生成する package org.specs2 package specification package core object Fragments {
… def foreach[T](seq: Seq[T])(f: T => Fragments): Fragments = ... } (c.fhttps://github.com/etorreborre/specs2/blob/master/core/src/main/scala/org/specs2/specification/core/Fragments.s cala#L116-L118)
テストが実行されるようになりました
Fragmentについて “In specs2 a specification can simply be viewed as
a sequence of Fragments.” そしてFragmentは - A Description - An Execution - An Example - ...
FragmentFactory APIでテストを生成する References: https://etorreborre.github.io/specs2/guide/SPECS2-3.8.5/org.specs2.guide.FragmentsApi.html
DataTablesがカッコイイ c.f. https://etorreborre.github.io/specs2/guide/SPECS2-3.8.5/org.specs2.guide.UseDatatables.html
実行結果
Specs2が結構便利なライブラリ ぜひ使ってみてください
Thank you for listening