【正文】
RAM lParam) { if(IsWindowVisible(hwnd)) //判斷窗口是否可見 { POINT pCursorPos。 //保存鼠標(biāo)點(diǎn)擊位置的屏幕坐標(biāo) =true。 GetWindowText(hwnd,chObjectText,256)。 //獲取窗口標(biāo)題 GetClassName(hwnd,chObjectClassName,256)。 //獲取窗口類 hObjectHandle=hwnd。 //存儲窗口句柄 HDC hDC。 hDC=GetDC(hwnd)。 GetWindowOrgEx(hDC,amp。pTopLeftPos)。 //獲取矩形窗口起點(diǎn)坐標(biāo) ReleaseDC(hwnd,hDC)。 ClientToScreen(hwnd,amp。pTopLeftPos)。 //將邏輯坐標(biāo)轉(zhuǎn)換為屏幕坐標(biāo) =+。 =+。 蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 34 //計(jì)算鼠標(biāo)點(diǎn)擊位置的屏幕坐標(biāo) if(strcmp(chObjectClassName,Edit)==0 ||strcmp(chObjectClassName,Button)==0 ||strcmp(chObjectClassName,ComboBox)==0 ||strcmp(chObjectClassName,ListBox)==0 ||strcmp(chObjectClassName,CheckBox)==0 ||strcmp(chObjectClassName,msctls_updown32)==0) =true。 else =false。 //通過窗口類判斷窗口是否支持鼠標(biāo)和鍵盤操作 if(IsWindowEnabled(hwnd)) =true。 else =false。 //判斷窗口是否可操作 if(strcmp(chObjectClassName,Button)==0 ||strcmp(chObjectClassName,Static)==0) { strcpy(,chObjectText)。 strcpy(,chObjectClassName)。 } //保存某些窗口類為 “ Static” 、 “ Button” 的窗口的關(guān)聯(lián)窗口的 //窗口標(biāo)題和窗口類 if(strcmp(,)==0 amp。amp。strcmp(,chObjectClassName)==0) { =true。 =。 =。 =hObjectHandle。 蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 35 return false。 } //如果當(dāng)前遍歷到的窗口的窗口標(biāo)題和窗口類與腳本內(nèi)所寫的目標(biāo)窗口的 //窗口標(biāo)題和窗口類相一致,則將當(dāng)前遍歷到的窗口的句柄保存為目標(biāo)窗 //口句柄,并保存相應(yīng)的鼠標(biāo)點(diǎn)擊位置的屏幕坐標(biāo),然后結(jié)束窗口遍歷 } else =false。 return true。 } 操作對象 目前本自動化測試工具所支持的窗口事件主要有三種: “Click”、 “Input”和 “Select”,與之相對應(yīng)的窗口事件處理函數(shù)也有三個: MouseEvent、 KeyboardEvent 和SelectEvent。當(dāng)查找定位對象執(zhí)行完畢后,由函數(shù) WindowEvent 負(fù)責(zé)判斷窗口事件類型,并轉(zhuǎn)入相應(yīng)的窗口事件處理函數(shù)執(zhí)行操作對象的任務(wù)。 void WindowEvent() { if (strcmp(,Click)==0) MouseEvent()。 else if (strcmp(,Input)==0) KeyboardEvent()。 else if (strcmp(,Select)==0) SelectEvent()。 else MessageBox(NULL,Unknown window event!,Error,MB_OK)。 } 函數(shù) MouseEvent 主要負(fù)責(zé)模擬鼠標(biāo)左鍵的單擊事件;函數(shù) KeyboardEvent 主要負(fù)責(zé)模擬鍵盤的按鍵事件;函數(shù) SelectEvent 則是作為一種擴(kuò)展窗口事件類型專門負(fù)責(zé)模擬 ComboBox 的選擇事件。 日志模塊 日志模塊分為生成日志、讀出日志、樹形顯示和列表顯示四個部分。界面由主程序菜單蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 36 調(diào)用, 并 以對話框形式顯示 , 圖 44是 本自動化測試工具的 日志界面。當(dāng)用戶回放腳本時會 在指定路徑下生成日志文件,采取 每 執(zhí)行一條腳本 命令就往日志文件中 寫入一 條 日志 信息的 方式,直到 測試 腳本 中的腳本命令全都執(zhí)行完畢。每回放腳本一次就 重新 生成 一個 新的 日志文件 , 先按規(guī)則得到日志文件名,然后生 成日志 文件 。 日志內(nèi)容 包 括 測試 所使用的計(jì)算機(jī)名 、測試時間、測試內(nèi)容、測試結(jié)果和測試失敗原因 分析 等。 圖 44 自動化測試工具的 日志界面 本章小結(jié) 本章從自動化測試工具的主界面開始,依次介紹了自動化測試工具各模塊的設(shè)計(jì)與實(shí)現(xiàn)過程,并圍繞著錄制模塊和對象交互模塊列舉出部分較典型的代碼。在整個實(shí)現(xiàn)過程中,軟件結(jié)構(gòu)非常清晰,體現(xiàn)了基于 UML 建立軟件模型的優(yōu)勢。 蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 37 第 五 章 結(jié)論 本文 主要對自動化測試工具進(jìn)行了深入研究,并在此基礎(chǔ)之上基于 UML 進(jìn)行了自動化測試 工具的建模,然后重點(diǎn)介紹了錄制模塊與對象交互模塊的設(shè)計(jì)與開發(fā)過程。軟件建模與面向?qū)ο箝_發(fā)方法相結(jié)合,不但使我從整體上牢牢把握住了自動化測試工具的結(jié)構(gòu),而且可以充分利用 UML 面向?qū)ο蟮膬?yōu)勢,最終使得項(xiàng)目成功完成。 在進(jìn)行畢業(yè)設(shè)計(jì)和撰寫畢業(yè)論文的過程中,我 對軟件 設(shè)計(jì)與 開發(fā)的全過程有了 更 深刻的認(rèn)識。短短三個月的畢業(yè)設(shè)計(jì)是寶貴的,它使我對大學(xué)四年所學(xué)的知識有了一個全面的總結(jié),并認(rèn)識到 了 自己的不足。由于 能力 有限,對自動化測試工具的認(rèn)識還不夠深入和透徹,理論過程和實(shí)際應(yīng)用還存在著差異,功能還不是特別完善,這是本次設(shè)計(jì)的 不足之處。 蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 38 參考文獻(xiàn) [1] (美 )Mark Fewster, Dorothy Graham. 軟件測試自動化技術(shù)與實(shí)例詳解 . 電子工業(yè)出版社 , 1999. 2~ 14 [2] (美 )Kanglin Li, Mengqi Wu. 圖形用戶界面測試自動化 . 電子工業(yè)出版社 , 2021 [3] 劉寅虓 . 系統(tǒng)分析與軟件開發(fā)過程管理實(shí)用案例教程 . 清華大學(xué)出版社 , 2021 [4] 張志強(qiáng) . Windows 編程技術(shù) . 機(jī)械工業(yè)出版社 , 2021 [5] 求是科技 . Windows API 程序設(shè)計(jì)參考大全 . 人民郵 電出版社 , 2021 [6] (美 )Elfriede Dustin. 軟件自動化測試:引入、管理與實(shí)施 . 電子工業(yè)出版社 , 2021 [7] 軟件測試自動化技術(shù) IBM Rational 技術(shù)白皮書 . IBM Rational 公司 軟件技術(shù)資料 [8] QuickTest Professional 8 Tutorial. Mercury 公司 軟件技術(shù)資料 [9] Rational Robot 基礎(chǔ)使用手冊 . IBM Rational 公司 軟件技術(shù)資料 [10] 蘇峰 , 黃金雙 , 湯蕾 . Visual C++.NET 編程實(shí)例 . 清華大學(xué)出版社 , 2021 [11] (美 )Wendy Boggs, Michael Boggs. UML 與 Rational Rose 2021 從入門到精通 . 電子工業(yè)出版社 , 2021 [12] (美 )Craig Larman. UML 和模式應(yīng)用:面向?qū)ο蠓治雠c設(shè)計(jì)導(dǎo)論 . 機(jī)械工業(yè)出版社 , 2021 蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 39 致 謝 首先感謝我的指導(dǎo)老師張廣泉教授對我的悉心指導(dǎo)和循循善誘,他嚴(yán)謹(jǐn)?shù)闹螌W(xué)態(tài)度、睿智的學(xué)者風(fēng)度與鍥而不舍的鉆研精神深深感染著我,為我今后的學(xué)習(xí)、工作道路點(diǎn)亮了一盞指路明燈。 同時還 要感謝 佳能(蘇州)系統(tǒng)軟件有限公司的魯亮課長、袁學(xué)明組長及其他員工的悉心指導(dǎo),感謝他們在此期間對我的幫助。 另外,我還要感謝和我同項(xiàng)目組的同學(xué),在我的學(xué)習(xí)和研究過程中,他們給予 了 我熱情的幫助。 最后感謝所有關(guān)心和幫助過我的 老師與同學(xué)。 蘇州大學(xué)本科生畢業(yè)設(shè)計(jì)(論文) 40 Are you hungry now? No, I am tired and lazy now。 if I pursue you I will not catch you, and if I catch youthrough your own slowness and clumsinessI will not kill you, and if I kill you I will not eat you. Nicholas had begun to back away, and at the last。 words, realizing that they were a signal, he turned and began to run, splashing through the shallow water. Ignacio ran after him, much helped by his longer legs, his hair flying behind his dark young face, his square teetheach white as a bone and as big as Nicholas39。s thumbnailshowing like spectators who lined the railings of his lips. Don39。t run, N icholas, Dr. Island said with the voice of a wave. It only makes him angry that you run. N icholas did not answer, but cut to his left, up the beach and among the trunks of the palms, sprinting all the way because he had no way of knowing Ignacio was not right behind him, about to grab him by the neck. When he stopped it was in the thick jungle, among the boles of the hardwoods, where he leaned,.。 out of breath, the thumping of his own heart the only39。 . sound in an atmosphere silent and unwa ked as Earth39。s long, prehuman day. For a time he listened for any sound Ignacio might m ake searching for him。 there was none. He drew a deep breath then and said, Well, that39。s over, expecting Dr. Island to answer from somewhere。 there was only the green hush. The light was still bright and strong and nearly, shadowless, but some interior sense told him the day, was nearly over, and he noticed that such faint shades as he could see stretched long, hor izontal distortions of their objects. He felt no hunger, but he had fasted be39。 fore and knew on which side of hunger he stood。 he was not as strong as he had been only a day past, and by this time next day he would probably be unable to outrun Ignacio. He should, he now realized, have eaten the monkey he had killed。 but his stomach revolted at the thought of the raw flesh, and he did not know how he might build a