# 6/3
{%hackmd 1lpg7PuqRoaui6XyJcrylw %}
## 回顧Practice1
### Cucumber
:::info
如果你的Cucmber文字很難閱讀,一片全黑白,你可以在extension下載套件,搜尋這個套件並安裝
**Cucumber (Gherkin) Full Support**
Robot的套件如下
**Robot Framework Intellisense**
:::
#### Test Case
- `cellular.feature`
- Spoken Language + Gherkin style
- `Feature` provide a high-level description of a software feature, and to group related scenarios.
- `Scenario` illustrate a specific aspect of behavior of the application.
- Steps: mapping to a function
- `Background` allows you to add some context to the scenarios that follow it.
- `Tag` to group related features, independent of your file and directory structure.
#### Implement Code
- python
- use `@given`, `@when`, `@then` to mapping with `*.feature`
### Robot Framework
#### Test Case
- `cellular.robot`
- Spoken Language + Robot Framework "Coding" Rules
- Test data sections
- Setting section: Importing test libraries, resource files and variable files.
- Variable secrion: Defining variables that can be used elsewhere in the test data.
- Test Cases secrion: Creating test cases from available keywords.
- Setting
- Library
- Test Setup
- Test Teardown
- Variables
- `${Scalar}`: when this syntax is used, the variable name is replaced with its value as-is.
- `@{List}`: the list is expanded and individual items are passed in as separate arguments.
- Test Cases
- Test Case Name
- Keywords: Mapping to a function.
- function style
- embedded style
#### Implement Code
- python
- use `@library`, `@keyword` to mapping with `*.robot`
### 關於python import的套件
- from re import findall 用來正規畫的
- pprint 顯示會比較好看用的
- telnet lib 再重新包裝
keyword
1. function style
- argument接在後面
- keyword 跟 argument用2個空格或1個tab隔開,否則會把argument誤以為是keyword的一部份
- keyword要放在testcase後面(robot framework會先抓keyword部分來compile)
2. embedded keyword style
- 把argument放在keyword裡面
## Template
## Q&A
- Coding Style
- 100 Template
## .robot 檔案中常見定義:
1. `*** Keywords ***`
- 從現有的或是 Library 所提供的 Keyword,創建自己定義的 Keyword
- 
2. `*** Test Cases ***`
- 從可用的 Keywords 創建 Test case,測試腳本全由 Keywords 組成
- 
- 第23行使用`[Template]`,在 Test Case 中重複執行流程,其中只有變數不同,如第24行到第31行
- 觀察 `log.html`
- 
- 而其使用的keywords則為自己定義的`The band "${number}" is "${init_state}" and then "${final_state}".`
3. `*** Settings ***`
- 用來 Import 支援 Robot Framework 的 Library,甚至是其他資料或變數的文件
- 也可以定義 Test suites 和 Test cases。
4. `*** Variables ***`
- 定義變數,該變數可以在測試文件中其他地方使用
- 
- 如第7~9行所定義的變數為第2行所用