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
API-整合測試
Search
Star Rocket
September 11, 2019
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
API-整合測試
LaraGirls Meetup#4
Star Rocket
September 11, 2019
More Decks by Star Rocket
See All by Star Rocket
PHP 也有 Day #51:高效能框架的曙光 - 以 Laravel 經驗開發 Hyperf 應用
starrocket
1
400
PHP 也有 Day #50:處理前人的遺產—聊 legacy code
starrocket
0
110
PHP 也有 Day #49:邊緣人救星!用 Laravel 打造私人定製的聊天機器人
starrocket
0
480
PHP 也有 Day #48:我是誰?我在哪?
starrocket
0
120
PHP 也有 Day #48:我是誰?我在哪?
starrocket
0
120
How we talk about Engineering Culture at Phase
starrocket
0
79
PHP 也有 Day #47:打造好維護的 PHP 程式碼專案
starrocket
0
410
全端起手就用 Laravel+Vue.js 現場實作給你看
starrocket
0
250
PHP 也有 Day #45: VS Code 實戰料理 PHP 套件網站佐 Azure Pipelines
starrocket
0
180
Other Decks in Programming
See All in Programming
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.2k
wkhtmltopdfの次どうするか問題2026
willnet
2
1.9k
AIに “答え“を書かせるのを やめてみた
___akari11
0
110
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
5
4.6k
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.5k
Java 27新機能 / Java 27 new features
kishida
2
200
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
400
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
7.9k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
380
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
560
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
480
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Tell your own story through comics
letsgokoyo
1
1.1k
Thoughts on Productivity
jonyablonski
76
5.4k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
450
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
690
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Scaling GitHub
holman
464
140k
Code Review Best Practice
trishagee
74
20k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Odyssey Design
rkendrick25
PRO
2
860
Transcript
API 整合測試 Glossika Ray
About me
• Glossika Senior Backend Developer • 技能樹點的亂七八糟 • Php &
Laravel & DevOps
Glossika
Glossika Glossika 是由語言學專家和語言學習好手所組成的團隊,致力 於開發有科學根據的語言自學產品!我們利用演算法找出用戶 的語言水平落點,並進而提供有效精準的學習內容幫助學習者 精進語言能力,減少無效的學習時間和資源浪費。Glossika 平 台上線至今近兩年的時間,已開發 65 種語言及獲得超過八萬
名來自世界各地的註冊用戶。
Glossika 30 天免費試用
None
如何提交高品質且可靠的 API ?
寫單元測試!But ….
寫完後,先上線看有沒有問題,然後 如果有時間的話再來補單元測試!
高品質?可靠?
None
API 回應是否正常 API 之間的串接溝通是否也符合預期
對了,你有聽過整合測試嗎?
None
None
Pre Request script Send Request Get Response Tests Script
Postman Collection
Postman Collection • Request 的集合 • 可以分享給其他人 • 雲端儲存 •
可以做 API 之間的串接測試
None
Glossika 開發流程 訂定 API 格式 建立文件 Mock Server 後端 API
設計 前端頁面串接 Staging Production Postman Test
Glossika API 基本測試 • Response Schema Test ◦ Tiny Validator
4 • Http code and Require column Test ◦ Postman sandbox API
Glossika API 測試結構 Get Response Status Code test Schema Test
Tiny Validator 4 basic syntax "type": "array", "item" : {
// item here }, "type": "object", "properties" : { // properties }, "key" : { "type": "data type" }, Json Array Json Object Json Column
{ "article_id": 55 } { "object": { "properties": { "article_id":
{ "type": "integer" } } } } Response Tiny Validator
情境:測試使用者登入 API
Test case: User login • User story ◦ 使用者輸入帳號密碼登入,回傳該使用的的基本資訊 •
Input ◦ Email ◦ Password • Response ◦ User Id ◦ User name ◦ User email ◦ User Auth token
情境:使用者登入後,發表一篇文章,並取得文章資 料
Test case : Post Article • User story ◦ 使用者登入後,發表一篇文章,並取得文章資料
Login API Post Article API Get Article API token id
Environment / Global variable • Postman 中,不同 API 用來儲存需要傳遞的資料變數。
Postman Collection Runner
None
你這樣還是不靠譜啊,現在是自動化的時代了
Postman-CLI Newman
Postman-CLI Newman • 安裝 ◦ $ npm install -g newman
• 執行 ◦ $ newman run mycollection.json
總結
善用工具來協助工作
撰寫測試是提高程式碼品質的最佳方案 而且可以讓我們說話比較大聲
在有限的時間內,撰寫測試依舊可行 時間就像___,擠擠還是有的
Q/A