quick start guide淺析博客軟件性能測試交流_第1頁
quick start guide淺析博客軟件性能測試交流_第2頁
quick start guide淺析博客軟件性能測試交流_第3頁
quick start guide淺析博客軟件性能測試交流_第4頁
quick start guide淺析博客軟件性能測試交流_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

RobotFrameworkdemoQuickStartGuide淺by:授博客 歡迎加入軟件性能測試交 1、開發(fā)環(huán) 2、安裝 3、分 運行rst配置文 1環(huán)win7x64PyCharm4.0.5Pythonrobotframework-地 地址 QuickStartGuide-地 地址 (因為的demo有些bug,在其基礎上做了些修改2.zip壓縮文件后解壓安D:\ProgramFiles\python33\Lib\site-packages>robotframework-master>pythonD:\Program參考連接 3、分#!/usr/bin/envpython#-*-coding:utf-8-*- importimportos.pathimportsysimportstudyDATABASE_FILE=os.path.join(tempfile.gettempdir(),'robotframework-quickstart-db.txt')classUser(object): init(self,username,password,status='Inactive'):self._username=usernameself._password=passwordself._status=statusdefreturndefusername(self,username):self._username=defreturndefpassword(self,password):self._password=passworddefreturndefstatus(self,status):self._status=def_validate_password(self,ifnot(7<=len(password)<=raiseValueError('Passwordmustbe7~12characterslong')ifnotself._validate_password_chars(password):raiseValueError('Passwordmustbeacombiantionoflowercaseand''uppercaselettersandnumbers')def_validate_password_chars(self,password):has_lower=has_upper=has_number=Falseforcharinpassword:ifchar.islower():has_lower=elifchar.isupper():has_upper=Trueelifchar.isdigit():has_number=Truereturnreturnhas_lowerandhas_upperandclassdefinit(self,db_file=DATABASE_FILE):self.users=self._read_users(db_file)self.db_file=db_filedef_read_users(self,path):users={}ifos.path.isfile(path):#pathwithopen(path)asforrowinuser=User(*row.rstrip('\r\n').split('\t'))users[user.username]=userreturndefcreate_user(self,username,user=User(username,exceptValueErrorasreturn'Creatinguserfailed:%s'%self.users[user.username]=returndeflogin(self,username,ifself._is_valid_user(username,password):self.users[username].status='Active'return'LoggedIn'return'Accessdef_is_valid_user(self,username,return(usernameinself.usersandself.users[username].password==defchange_password(self,username,old_pwd,ifnotself._is_valid_user(username,raiseValueError('AccessDenied')self.users[username].password=new_pwdexceptValueErrorasreturn'Changingpasswordfaild:%s'%returndefwithopen(self.db_file,'w')asforuserinfile.write('%s\t%s\t%s\n'%(user.username,user.password,defwithopen(self.db_file,'w')asfile:return enterreturndefexit(self,*exec_info):deflogin(username,withUserDataBase()asdb:defcreate_user(username,withUserDataBase()asdb:print(db.create_user(username,defchange_password(username,old_pwd,withUserDataBase()asdb:print(db.change_password(username,old_pwd,new_pwd))defwithUserDataBase()asdb:defprint('Usage:%s{create|login|change-password|truncate|help}'% =='mainactions={'create':create_user,'login':login,'change-password':'truncatefile':truncate,'help':action=sys.argv[1]exceptIndexError:action='help'args=except(KeyError,TypeError):運行登錄用戶帳號不存在、錯E:\Projects\studyproject>pythonsut/login.pyloginnobodyP4ssw0rdAccessDeniedE:\Projects\studyproject>pythonsut/login.pycreatefredP4ssw0rdE:\Projects\studyproject>pythonsut/login.pyloginfredP4ssw0rdLoggedIn創(chuàng)建用戶時,用戶必須包含7-12字符E:\Projects\studyproject>pythonsut/login.pycreatefredshortCreatinguserfailed:Passwordmustbe7~12characterslongE:\Projects\studyproject>pythonsut/login.pycreatefredCreatinguserfailed:Passwordmustbeacombiantionoflowercaseanduppercaselettersandnumbers修改用戶,提供錯誤的原始E:\Projects\studyproject>pythonsut/login.pychange-passwordfredwrongNewP4ssChangingpasswordfaild:AccessDenied修改用戶,提供正確的原始E:\Projects\studyproject>pythonsut/login.pychange-passwordfredP4ssw0rdNewP4ss#!/usr/bin/envpython#-*-coding:utf-8-*-importimportimportclass initself._sut_path=os.path.join(os.path.dirname(file'..','sut',self._status=defcreate_user(self,username,mand('create',username,defchange_password(self,username,old_pwd,mand('change-password',username,old_pwd,defattempt_to_login_with_credentials(self,username,password):mand('login',username,password)deflogin(self,username,mand('login',username,defstatus_should_be(self,ifexpected_status!=raiseAssertionError("Expectedstatustobe'%s'butwas%(expected_status,def mand(self,command,command=[sys.executable,self._sut_path,command]+process=subprocess.Popen(command,universal_newlines=True,self._status QuickStart.rst文..code::***TestCasesUsercancreateanaccountandlogin CreateValid AttempttoLoginwith StatusShouldBeLoggedInvalid[Temte]Creatinguserwithinvalidpasswordshouldfail ${PWDINVALIDLENGTH} ${PWDINVALIDLENGTH}123DEFG${PWDINVALIDCONTENT}abcd56789${PWDINVALIDCONTENT}AbCdEfGh${PWDINVALIDCONTENT}abCD56+${PWDINVALIDUsercanchangeGivenAuserhasavalidaccountWhenshechangesherpasswordThenshecanloginwiththenewpasswordAndshecannotusetheoldpasswordanymore Createvalid[Arguments]${username}${password}Createuser${username}${password}StatusshouldbeSUCCESSCreatinguserwithinvalidpasswordshouldfail Createuser Statusshould Creatinguserfailed:AuserhasavalidCreatevaliduser${USERNAME}ShechangesherChangeStatusshouldShecanloginwiththenewpassword ShecannotusetheoldpasswordAttempttologinwithcredentials Statusshouldbe AccessDeniedClearLoginDatabase***Variables ${NEW ${DATABASE ${TEMPDIR}${/}robotframework-quickstart-${PWDINVALID Passwordmustbe7-12characters${PWDINVALIDCONTENT} andnumbers Creatinguserfailed:Passwordmustbe7-12characters***SettingsSuiteSetup ClearLoginDatabaseTest ClearLogin DefaultTags `Creatingtest運行rst配置文E:\Projects\studyprojec

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論