# Demo Example1 {%hackmd 1lpg7PuqRoaui6XyJcrylw %} :::info 1. 了解 test case(用spoken language寫)跟 implement code(用programming code寫) 間的對應關係 2. 熟悉 Gherkin 的 keywords: Given, When, Then, And, But, ... ::: ### Robot framework Demo test case :::info Test case: `cellular.robot` Implement code: `Router.py` ::: `[Test Setup & Test Teardown]` Robot內建的做法,表示每個test case一開始/結束後都會做動此部分的運作 ![](https://i.imgur.com/oJxd1CD.png) ![](https://i.imgur.com/fsOKhk2.png) `[Tags]` - Robot 用來給 case 或是變數等的標籤,可以在 report 呈現,以這舉例report裡面就會有 BVT 跟 major 這兩個 tag - 可以用 tag 來選擇要執行特定的 test case - Tag可以用在 case或是用在suite都可以 ![](https://i.imgur.com/xtqokJT.png) --- ### Test case 內文部分 - Test case 中的 Given And When Then 是 Gherkin語法定義的 keywords - 這些 keyowrd 後面接的句子,舉例來說 `cellular.robot`中 `Given SIM PIN is set to` 的 **SIM PIN is set to** 會在 `Router.py`定義這個step叫`@keyword('SIM PIN is set to')` **cellular.robot與Router.py對應的example** ![](https://i.imgur.com/pZFEXx2.png) --- ### Cucumber Demo test case :::info Test case: `cellular.feature` Implement code: `router.py` ::: - `@` 類似在robot 中 tag 的效果 - `Background` 類似於 robot 的 test setup,會在執行case之前,先去做動這塊precondition ![](https://i.imgur.com/lVgaMK0.png) --- :::info :heart_decoration: 感謝共編 Mike :::