# Hands-on Practice2 {%hackmd 48QQ4miqSxmUyp2CZ-kBSw %} ## 測試步驟 :::info :heart: 這裡只是測試步驟,真正的題目在下一段[**說明**](#說明),看完測試步驟先往下看,就知道要做什麼了。 ::: - Requirement: 5G-TAU(機器的型號)的cellular name可以包含英文、數字以及「@!%」,但不能包含「<>~」。 - 測項名稱: Cellular APN Name 1. 初始條件: 將測試APN設為「internet」 2. 出發事件: 1. 將測試APN設為「`<apn_name>`」(參考下表) 3. 查看cellular資訊 3. 預期結果: cellular資訊中應該顯示APN Name為「`<expected_apn_name>`」(參考下表) 4. 將下列兩組Test data(共6筆)依序帶入上述步驟1~3。 - Valid APN Name | apn_name | expected_apn_name | | ------------ | ----------------- | | Work@Home666 | Work@Home666 | | GoodBye!881 | GoodBye!881 | | GinABV40% | GinABV40% | - Invalid APN Name :::danger :exclamation: 這組測試會Fail,是正常的。 | apn_name | expected_apn_name | | -------- | ----------------- | | < | internet | | > | internet | | ~ | internet | ::: - 參考command ```bash= # 設定cellular APN Name configure terminal cellular apn_name <apn_name> exit # 查看cellular資訊 show cellular ``` ## 說明 - 目的: - 學習撰寫Test Case的模板。 - 學習`git push`將local branch推到remote。 - 根據[測試步驟](#測試步驟),利用模板的方式完成Test Case。 :::info :heart: 還是有點不清楚嗎?繼續照步驟做到,你就會更清楚了! ::: ## 更新Local Repo :::info :bulb: 之前提過的步驟之後就不再贅述,可以回去參考前面的Practice和相關的Q&A。 ::: 1. 下載repo/commit - 若還未載過repo,須從remote(`http://mhqnetgitlab.moxa.com:10080/SimonWX_Zhao/auto-test-practice.git`)下載(clone)repo - 如果已經載過repo那麼只需從remote下載新的commits 2. 檢查tag,包含`practice2-c`、`practice2-r`、`practice2-ans-c`和`practice2-ans-r`就對了。 ## Practice2 Cucumber 1. checkout到帶有`practice2-c`tag的commit。 2. 確認現在位置在,`HEAD`和`tag: practice2-c`在同位置就對了。 3. 從這個commit新增一個名為`practice2-c-<你的名字>`的branch並移動到該branch上。 ```bash= git checkout -b practice2-c-<你的名字> ``` 4. 確認現在位置在,`HEAD`指到`practice2-c-<你的名字>`就對了。 5. ==:exclamation:將新建的branch推到remote== :::warning - 記得先[申請本練習的Repo權限](/H1voIxJwSA2f5gSs_xfDMQ#%E7%94%B3%E8%AB%8B%E6%9C%AC%E7%B7%B4%E7%BF%92GitLab-Repository%E7%9A%84Access%E6%AC%8A%E9%99%90) ::: ```bash= git push --set-upstream origin practice2-c-<你的名字> ``` 6. 開始解題,並將你的更動[做commit](/H1voIxJwSA2f5gSs_xfDMQ#git-commit) 7. 執行結果 ```bash= #用"-n"指定要執行的測項名稱 behave -n "Cellular APN Name" -f html -o result/log.html -f pretty ``` 8. 檢查執行結果 :::danger :exclamation: 「<>~」的測試會Fail是正常的,其他要Pass。 ::: - terminal ![](https://i.imgur.com/SoycnF8.jpg) ![](https://i.imgur.com/PsjROtT.jpg) ![](https://i.imgur.com/HwkqNdS.jpg) ![](https://i.imgur.com/AUIjfEs.jpg) - log.html ![](https://i.imgur.com/GLnO7hQ.jpg) 9. 與標有`practice2-ans-c`的[commit比較](/H1voIxJwSA2f5gSs_xfDMQ#git-diff),主要測試步驟沒有多或少就對了! 10. 確定完成後記得做最後的commit且,再將該branch所有commit推到remote。 ## Practice2 Robot 1. checkout到帶有`practice2-r`tag的commit。 2. 確認現在位置在,`HEAD`和`tag: practice2-r`在同位置就對了。 3. 從這個commit新增一個名為`practice2-r-<你的名字>`的branch並移動到該branch上。 ```bash= git checkout -b practice2-r-<你的名字> ``` 4. 確認現在位置在,`HEAD`指到`practice2-r-<你的名字>`就對了。 5. ==:exclamation:將新建的branch推到remote== :::warning - 記得先[申請本練習的Repo權限](/H1voIxJwSA2f5gSs_xfDMQ#%E7%94%B3%E8%AB%8B%E6%9C%AC%E7%B7%B4%E7%BF%92GitLab-Repository%E7%9A%84Access%E6%AC%8A%E9%99%90) ::: ```bash= git push --set-upstream origin practice2-r-<你的名字> ``` 6. 開始解題,並將你的更動[做commit](/H1voIxJwSA2f5gSs_xfDMQ#git-commit) 7. 執行結果 ```bash= #用"-t"指定要執行的測項名稱 robot -d result -t "Cellular APN Name" cellular.robo ``` 8. 檢查執行結果 :::danger :exclamation: 「<>~」的測試會Fail是正常的,其他要Pass。 ::: - terminal ![](https://i.imgur.com/tRXi8RR.png) - log.html ![](https://i.imgur.com/qJkWEhD.jpg) 9. 與標有`practice2-ans-r`的[commit比較](/H1voIxJwSA2f5gSs_xfDMQ#git-diff),主要測試步驟沒有多或少就對了! 10. 確定完成後記得做最後的commit且,再將該branch所有commit推到remote。 --- :::info :heart_decoration: 感謝共編 Sabrina, Jamel :::