Slide 1

Slide 1 text

API 整合測試 Glossika Ray

Slide 2

Slide 2 text

About me

Slide 3

Slide 3 text

● Glossika Senior Backend Developer ● 技能樹點的亂七八糟 ● Php & Laravel & DevOps

Slide 4

Slide 4 text

Glossika

Slide 5

Slide 5 text

Glossika Glossika 是由語言學專家和語言學習好手所組成的團隊,致力 於開發有科學根據的語言自學產品!我們利用演算法找出用戶 的語言水平落點,並進而提供有效精準的學習內容幫助學習者 精進語言能力,減少無效的學習時間和資源浪費。Glossika 平 台上線至今近兩年的時間,已開發 65 種語言及獲得超過八萬 名來自世界各地的註冊用戶。

Slide 6

Slide 6 text

Glossika 30 天免費試用

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

如何提交高品質且可靠的 API ?

Slide 9

Slide 9 text

寫單元測試!But ….

Slide 10

Slide 10 text

寫完後,先上線看有沒有問題,然後 如果有時間的話再來補單元測試!

Slide 11

Slide 11 text

高品質?可靠?

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

API 回應是否正常 API 之間的串接溝通是否也符合預期

Slide 14

Slide 14 text

對了,你有聽過整合測試嗎?

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Pre Request script Send Request Get Response Tests Script

Slide 18

Slide 18 text

Postman Collection

Slide 19

Slide 19 text

Postman Collection ● Request 的集合 ● 可以分享給其他人 ● 雲端儲存 ● 可以做 API 之間的串接測試

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Glossika 開發流程 訂定 API 格式 建立文件 Mock Server 後端 API 設計 前端頁面串接 Staging Production Postman Test

Slide 22

Slide 22 text

Glossika API 基本測試 ● Response Schema Test ○ Tiny Validator 4 ● Http code and Require column Test ○ Postman sandbox API

Slide 23

Slide 23 text

Glossika API 測試結構 Get Response Status Code test Schema Test

Slide 24

Slide 24 text

Tiny Validator 4 basic syntax "type": "array", "item" : { // item here }, "type": "object", "properties" : { // properties }, "key" : { "type": "data type" }, Json Array Json Object Json Column

Slide 25

Slide 25 text

{ "article_id": 55 } { "object": { "properties": { "article_id": { "type": "integer" } } } } Response Tiny Validator

Slide 26

Slide 26 text

情境:測試使用者登入 API

Slide 27

Slide 27 text

Test case: User login ● User story ○ 使用者輸入帳號密碼登入,回傳該使用的的基本資訊 ● Input ○ Email ○ Password ● Response ○ User Id ○ User name ○ User email ○ User Auth token

Slide 28

Slide 28 text

情境:使用者登入後,發表一篇文章,並取得文章資 料

Slide 29

Slide 29 text

Test case : Post Article ● User story ○ 使用者登入後,發表一篇文章,並取得文章資料 Login API Post Article API Get Article API token id

Slide 30

Slide 30 text

Environment / Global variable ● Postman 中,不同 API 用來儲存需要傳遞的資料變數。

Slide 31

Slide 31 text

Postman Collection Runner

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

你這樣還是不靠譜啊,現在是自動化的時代了

Slide 34

Slide 34 text

Postman-CLI Newman

Slide 35

Slide 35 text

Postman-CLI Newman ● 安裝 ○ $ npm install -g newman ● 執行 ○ $ newman run mycollection.json

Slide 36

Slide 36 text

總結

Slide 37

Slide 37 text

善用工具來協助工作

Slide 38

Slide 38 text

撰寫測試是提高程式碼品質的最佳方案 而且可以讓我們說話比較大聲

Slide 39

Slide 39 text

在有限的時間內,撰寫測試依舊可行 時間就像___,擠擠還是有的

Slide 40

Slide 40 text

Q/A