前情介紹:
行為驅(qū)動(dòng)是一種在關(guān)鍵詞驅(qū)動(dòng)之上更加抽象更加高級(jí)的自動(dòng)化測(cè)試手段;通常結(jié)構(gòu)是“Given-When-and-Then”炫加,即在一個(gè)什么樣的前置條件下,當(dāng)用戶觸發(fā)了什么操作铡恕,產(chǎn)生了一個(gè)什么樣的結(jié)果琢感,結(jié)果該是怎么樣丢间。
行為驅(qū)動(dòng)風(fēng)格的測(cè)試用例(given-when-then)探熔,官方稱謂是gherkins風(fēng)格的。烘挫。诀艰。
***Test Cases***
User can change password
Given A user has a valid account
when she changes her password
Then she can log in with the new password
And she cannot use the old password anymore
練習(xí)環(huán)境配置
實(shí)例1(UI自動(dòng)化-百度搜索)
實(shí)例2(有效登錄)
實(shí)例3(無效登錄)
實(shí)例4 (Appium)
實(shí)例5 (連接mysql數(shù)據(jù)庫(kù))
實(shí)例6 (GET/POST請(qǐng)求)
實(shí)例7(接口API測(cè)試)
實(shí)例8 (數(shù)據(jù)驅(qū)動(dòng))
Appium Error總結(jié)
robotframework Error總結(jié)
測(cè)試需求:
測(cè)試設(shè)計(jì):
因?yàn)锽DD(行為驅(qū)動(dòng)測(cè)試)這個(gè)方式我個(gè)人理解是更多的是一種溝通方式柬甥。
此次的例子只是一個(gè)簡(jiǎn)單的秀肌肉行為,也就是你知道寫法就可以了其垄,其實(shí)個(gè)人覺得和關(guān)鍵字驅(qū)動(dòng)的差別就在于剛開始的測(cè)試用例的寫法上面苛蒲。
測(cè)試實(shí)現(xiàn):
- 新建測(cè)試用例
- 所有的實(shí)現(xiàn)語句都以關(guān)鍵字的形式存在
上代碼:
*** settings ***
Library Selenium2Library
*** Test Cases ***
Scenario: No template operation selected
Given I have logged in and I have selected to perform template configuration
When I do not select a template operation
And I press the next button
Then I should not see a template operation selected error message
*** Keywords ***
I have logged in and I have selected to perform template configuration
Log Given I have logged in and I have selected to perform template configuration
open browser http://www.baidu.com chrome
I do not select a template operation
Log No template operation selected
page does not contain a no template operation selected error message
Page Should Not Contain 'ddTemplateOperation' is required.
I press the next button
Log I press the next button
I should not see a template operation selected error message
Page Should Contain 'ddTemplateOperation' is required.
Close Browser