# Hands-on/Practice1
{%hackmd 48QQ4miqSxmUyp2CZ-kBSw %}
## 測試步驟
:::info
:heart: 這裡只是測試步驟,真正的題目在下一段[**說明**](#說明),看完測試步驟先往下看,就知道要做什麼了。
:::
- [Setup](#Steup)
- [初始條件](#初始條件)
- [事件](#事件)
- [期待結果](#期待結果)
### Setup
1. 登入DUT
### 初始條件
2. 關閉cellular 5g band 28
```bash
MOXA TAU-504 Series V1.0 build 21052716
--------------------------------------------------------------------------------
45678# configure terminal
45678(config)# no cellular 5g band 28
45678(config)# exit
```
3. 列出cellular資訊
``` bash
45678# show cellular
Cellular Connection : Enable
APN Name : internet
5G Band 28 : Disable
5G Band 41 : Disable
5G Band 78 : Disable
5G Band 79 : Disable
Cellular Connection Status : Disable
Cellular Attach Status : Attached
Signal Status
RAT : LTE , RSRQ : -3 , SNR : 21.000000
Service Provider Full Name : Chunghwa Telecom
Service Provider Short Name : Chunghwa
Registered PLMN : 46692
Module Manufacturer : Quectel
Module Name : Quectel
Firmware Version : Quectel
IMEI : 863305040253832
IMSI : 466924202921817
ICCID : 89886920042029218174
Temperature Sensor - qfe_wtr_pa0 : 35 Celsius
Temperature Sensor - aoss0_usr : 33 Celsius
Temperature Sensor - mdm_q6_usr : 33 Celsius
Temperature Sensor - ipa_usr : 33 Celsius
Temperature Sensor - cpu0_a7_usr : 33 Celsius
Temperature Sensor - mdm_5g_usr : 33 Celsius
Temperature Sensor - mdm_core_usr : 32 Celsius
Temperature Sensor - mdm_vpe_usr : 33 Celsius
Temperature Sensor - xo_therm_usr : 255 Celsius
Temperature Sensor - sdx_case_therm_usr : 255 Celsius
PIN Protection : Enable
PIN Retry Count : 3
Neighbour Cell [1] :
RAT : WCDMA , RSSI : 10 , ECIO : 0.000000
Neighbour Cell [2] :
RAT : WCDMA , RSSI : 10 , ECIO : 0.000000
```
### 事件
4. 輸入下列指令,開啟cellular 5g band 28
``` bash
45678# configure terminal
45678(config)# cellular 5g band 28
45678(config)# exit
```
5. 並輸入下列指令,列出cellular資訊
``` bash
45678# show cellular
Cellular Connection : Enable
APN Name : internet
5G Band 28 : Enable
5G Band 41 : Disable
5G Band 78 : Disable
5G Band 79 : Disable
Cellular Connection Status : Disable
Cellular Attach Status : Attached
Signal Status
RAT : LTE , RSRQ : -3 , SNR : 21.000000
Service Provider Full Name : Chunghwa Telecom
Service Provider Short Name : Chunghwa
Registered PLMN : 46692
Module Manufacturer : Quectel
Module Name : Quectel
Firmware Version : Quectel
IMEI : 863305040253832
IMSI : 466924202921817
ICCID : 89886920042029218174
Temperature Sensor - qfe_wtr_pa0 : 35 Celsius
Temperature Sensor - aoss0_usr : 33 Celsius
Temperature Sensor - mdm_q6_usr : 33 Celsius
Temperature Sensor - ipa_usr : 33 Celsius
Temperature Sensor - cpu0_a7_usr : 33 Celsius
Temperature Sensor - mdm_5g_usr : 33 Celsius
Temperature Sensor - mdm_core_usr : 32 Celsius
Temperature Sensor - mdm_vpe_usr : 33 Celsius
Temperature Sensor - xo_therm_usr : 255 Celsius
Temperature Sensor - sdx_case_therm_usr : 255 Celsius
PIN Protection : Enable
PIN Retry Count : 3
Neighbour Cell [1] :
RAT : WCDMA , RSSI : 10 , ECIO : 0.000000
Neighbour Cell [2] :
RAT : WCDMA , RSSI : 10 , ECIO : 0.000000
```
### 期待結果
6. 檢查前一步驟所列出的內容,須包含「`5G Band 28 : Enable`」
## 說明
- 目的:
- 了解Test Case與Implement Code的對應關係。
- 學習利用`git`開啟新的branch和commit。
- 根據[測試步驟](#測試步驟),將撰寫好的**Implememt Code**回填到名為「Cellular Band Setting」的Test Case中,以完成自動化,如下圖所示。

:::info
:heart: 還是有點不清楚嗎?繼續照步驟做到[**Practice1 Robot**](#Practice1-Robot)和[**Practice1 Cucumber**](#Practice1-Cucumber),你就會更清楚了!
:::
## 更新Local Repo
1. 下載repo/commit
- 若還未載過repo,須從remote下載repo
```bash=
git clone http://mhqnetgitlab.moxa.com:10080/SimonWX_Zhao/auto-test-practice.git
```
- 如果已經載過repo那麼只需從remote下載新的commits
```bash=
git fetch
```
2. 檢查tag,包含`practice1-c`、`practice1-r`、`practice1-ans-c`和`practice1-ans-r`就對了。
```bash=+
git tag
```
## Practice1 Robot
1. checkout到帶有`practice1-r`tag的commit。
```bash=
git checkout practice1-r
```
:::info
:bulb: 每次checkout後記得重新整理VSCode Explorer再開啟檔案。
:::
2. 確認現在位置在,`HEAD`和`tag: practice1-r`在同位置就對了。
```bash=+
git log --graph --all --oneline
```

3. 從這個commit新增一個名為`my-practice1-r`的branch並移動到該branch上。
```bash=+
git checkout -b my-practice1-r
```

4. 確認現在位置在,`HEAD`指到`my-practice1-r`就對了。
```bash=+
git log --graph --all --oneline
```

3. 開始解題,並將你的更動[做commit](/H1voIxJwSA2f5gSs_xfDMQ#git-commit)

4. 執行結果
```bash=+
robot -d result cellular.robot
```
5. 檢查執行結果
- terminal

- log.html

7. 與標有`practice1-ans-r`的[commit比較](/H1voIxJwSA2f5gSs_xfDMQ#git-diff),主要測試步驟沒有多或少就對了!
## Practice1 Cucumber
1. checkout到帶有`practice1-c`tag的commit。
```bash=
git checkout practice1-c
```
:::info
:bulb: 每次checkout後記得重新整理VSCode Explorer再開啟檔案。
:::
2. 確認現在位置在,`HEAD`和`tag: practice1-c`在同位置就對了。
```bash=+
git log --graph --all --oneline
```

3. 從這個commit新增一個名為`my-practice1-c`的branch並移動到該branch上。
```bash=+
git checkout -b my-practice1-c
```

4. 確認現在位置在,`HEAD`指到`my-practice1-c`就對了。
```bash=+
git log --graph --all --oneline
```

3. 開始解題,並將你的更動[做commit](/H1voIxJwSA2f5gSs_xfDMQ#git-commit)

4. 執行結果
```bash=+
behave cellular.feature
```
或`--no-capture`會將print內容直接輸出
```bash=+
behave --no-capture cellular.feature
```
5. 檢查執行結果
- terminal
```bash=+
behave cellular.feature
```

```bash=+
behave --no-capture cellular.feature
```
- Enable/Disable Cellular Connection

- Cellular Band Setting

- log.html
```bash=+
behave -f html -o log.html cellular.feature
```

7. 與標有`practice1-ans-c`的[commit比較](/H1voIxJwSA2f5gSs_xfDMQ#git-diff),主要測試步驟沒有多或少就對了!