# Hands-on/Eaxmple2 {%hackmd 48QQ4miqSxmUyp2CZ-kBSw %} ## 重點提示 1. 了解Test Case的使用「目的」,和撰寫規則。 - 目的會影響之後開發的設計原則(譬如:哪些內容要寫在Test Case中),而設計原則會影響未來的維運和最終自測是否能有效幫助測試者和開發者找到並解決問題,所以真的非常重要! - 撰寫規則 - Cucumber: Feature, Background, Scenario, Scenario Outline, Example - Robot: Test Data Section(Setting, Variables, Test Cases, Keywords), Variable Type(Scalar, List), Keyword(Function style, Embedded style) , Template 2. 了解Implement Code的內容。 - 初階 - 如何與Test Case中的測試步驟對應 - 每一個function/method中做了什麼事 - 進階(Optional) - 使用到的telnet module實際做了什麼 - Cucumber: function中的context, environment.py - Robot: Class的結構 ## 下載/更新 Repository :::info :bulb: 有問題請先服用[開發環境問題/Git](/H1voIxJwSA2f5gSs_xfDMQ) ::: 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,包含`example2-c`和`example2-r`就對了。 ## 執行Cucumber example 1. 移動標有`example2-c`的commit ```bash=1 #要執行這行才會到robot這個commit上 git checkout example2-c ``` 2. 檢查在git tree上的位置,`HEAD`指到`example2-c`就對了 ```bash=+ #看看有沒有到這個commit上 git log --graph --oneline --all ``` 3. 檢查測試結果 ```bash=+ behave -f html -o log.html -f pretty cellular.feature ``` - 在Terminal中長這樣 ![](https://i.imgur.com/bRiy6XK.png) ![](https://i.imgur.com/z0LyxZs.jpg) ![](https://i.imgur.com/1kE0BjZ.png) - 到Windows相對應的資料夾中開啟log.html,察看有排版的格式 擷取部分的 ![](https://i.imgur.com/FWWXfMW.png) ![](https://i.imgur.com/fYE2EFw.png) ## 執行Rrobot framework example 1. 移動標有`example2-r`的commit ```bash=1 #要執行這行才會到robot這個commit上 git checkout example2-r ``` 2. 檢查在git tree上的位置,`HEAD`指到`example2-r`就對了 ```bash=+ #看看有沒有到這個commit上 git log --graph --oneline --all ``` 3. 執行robot framework的自動測試功能 ```bash=+ robot -d result cellular.robot ``` 4. 檢查測試結果 - 在Terminal中長這樣 ![](https://i.imgur.com/27D92VW.png) - 到Windows相對應的資料夾中開啟log.html,察看有排版的格式(僅擷取部分) ![](https://i.imgur.com/owbrg58.png) --- :::info :heart_decoration: 感謝共編 Sabrina :::