




已閱讀5頁,還剩8頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
軟件測試實習(xí)報告 班級: 軟件122 學(xué)號: 12477218 姓名: 孫劍峰 指導(dǎo)老師: 王暉 實習(xí)時間: 15.11.30-15.12.4 1、 需求分析說明書軟件行業(yè)的產(chǎn)業(yè)化發(fā)展對軟件的質(zhì)量及其開發(fā)效率都提出了較高要 求,而軟件測試作為軟件開發(fā)項目管理中軟件質(zhì)量保證的關(guān)鍵,正發(fā)揮著越來越重要的作用,自動化測試作為提高軟件測試效率的重要手段也被更多的軟件開發(fā)者所 重視。本文根據(jù)Windows平臺下UI自動化測試的需求,基于.NET框架,采用數(shù)據(jù)驅(qū)動模型設(shè)計并實現(xiàn)了一套UI自動化測試系 統(tǒng)。使用底層的Windows自動化測試技術(shù)通過用戶界面(UI)來測試應(yīng)用程序。這些技術(shù)涉及Win32API函數(shù)的調(diào)用(比如FindWindow()函數(shù))以及向待測程序(AUT)發(fā)送Windows消息(比如WM_LBUTTONUP)。所有的Windows控件本質(zhì)上都是一個窗體(window)。每個控件/窗體都有一個與之關(guān)聯(lián)的句柄(handle),可以通過這個句柄來訪問、操縱和檢測這個控件和檢測這個控件/窗體。對于輕量級的、底層的Windows窗體UI自動化測試程序來說,需要完成的工作主要有以下三類:找到目標(biāo)窗體/控件的句柄操作這個窗體/控件檢測這個窗體/控件2、 項目開發(fā)計劃2.1、計劃分項目階段本項目分為如下部分:資料搜集:搜集關(guān)于Win32API的資料與一些官方測試資料。需求分析:分析本項目的軟件需求并細(xì)化。軟件設(shè)計:設(shè)計軟件結(jié)構(gòu)。軟件編寫:使用不同語言編寫軟件。實驗分析:設(shè)計數(shù)據(jù)庫并進(jìn)行實驗。完成報告:完成最終試驗測試報告。2.2、計劃分項目工作內(nèi)容系統(tǒng)階段重點工作完成指標(biāo)完成時間前期工作1. 了解Win32API2. 需求分析1. 利用官方提供進(jìn)行WidowsUI2. 完成需求報告2015/12/2算法建立1. 項目設(shè)計2. 軟件編寫1. 完成項目設(shè)計報告書2. 編寫程序2015/12/7試驗測試1. 設(shè)計實驗2. 結(jié)果分析1. 完成報告2015/12/83、軟件設(shè)計說明書通過句柄獲取待測程序的一個窗口,按鈕,圖標(biāo),輸出設(shè)備,控件等。使用大量的Win32API調(diào)用來操作Windows窗體應(yīng)用程序。1. 使用System.Disgnostics.Process.Start()方法啟動程序。2. 獲得待測程序主窗體的句柄要獲得待測程序主窗體的句柄,可使用FindWindow() Win32 API函數(shù)來解決這個問題。C#要使用Win32 API函數(shù)FindWindow(),可通過.Net平臺的invoke(P/Invoke)機(jī)制,P/Invoke相關(guān)特性位于System.Runtime.InteropServices命名空間內(nèi)。C#簽名如下:DllImport(user32.dll, EntryPoint = FindWindow, CharSet = CharSet.Auto) static extern IntPtr FindWindow(string lpClassName, string lpWindowName);3. 獲得有名字控件的句柄C#簽名如下:DllImport(user32.dll, EntryPoint = FindWindowEx,CharSet = CharSet.Auto)9 static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);4. 獲得無名字控件的句柄獲得一沒有名字空間的句柄,可通過隱含索引來查找相應(yīng)控件。5. 發(fā)送字符給控件我們要發(fā)送一個VM_CHAR消息。當(dāng)按鍵按下時,VM_CHAR消息會發(fā)送給擁有鍵盤焦點的那個控件。實際上,VM_CHAR是一個Windows的常量符號,它定義為0x0102。wParam參數(shù)指定的是被按下按鍵的字符代碼。lParam參數(shù)指定的是不同的按鍵狀態(tài)碼,比如重復(fù)次數(shù)、掃描碼等。有了這些信息,就可以創(chuàng)建相應(yīng)的C#簽名: DllImport(user32.dll, EntryPoint = SendMessage, CharSet = CharSet.Auto) static extern void SendMessage1(IntPtr hWnd, uint Msg, int wParam, int lParam);6、鼠標(biāo)單擊一個控件PostMessage()和SendMessage()的參數(shù)列表完全一致,他們的不同是:SendMessage()會等相應(yīng)的Windows消息之后才會返回;PostMessage()不會。相應(yīng)的C#簽名:DllImport(user32.dll, EntryPoint = PostMessage, CharSet = CharSet.Auto)static extern bool PostMessage1(IntPtr hWnd, uint Msg, int wParam, int lParam);7. 處理消息對話框消息對話框是一個上層(top-level)窗體,使用FindWindow()函數(shù)捕獲它。8、處理菜單9、檢查應(yīng)用程序狀態(tài)10、 使用VM_GETTEXT和SendMessage()獲得控件狀態(tài)4、測試用例設(shè)計設(shè)計待測窗體: 待測程序是一個用來做顏色混合的應(yīng)用程序,設(shè)計的窗口如下:菜單欄的結(jié)構(gòu)如下:File Edit HelpNew Cut AboutSave Copy UpdateExit Paste5、軟件測試分析報告5.1 實驗過程:系統(tǒng):Windows10開發(fā)環(huán)境:VS20101. 安裝VS2010開發(fā)環(huán)境2. 編寫Form窗體,包括Textbox,ComboBox,Button,ListBox。其核心代碼為: private void button1_Click(object sender, EventArgs e) string tb = textBox1.Text; string cb = comboBox1.Text; if (tb = | cb = ) MessageBox.Show(You need 2 colors, Error); else if (tb = cb) listBox1.Items.Add(Result is + tb); else if (tb = red & cb = blue | tb = blue & cb = red) listBox1.Items.Add(Result is purple); else listBox1.Items.Add(Result is black); 3. 創(chuàng)建測試程序初始化測試程序5.2 實驗結(jié)果與分析Launching application undertestWarning: process may already existForm not yet foundForm not yet foundForm has been foundMain windows handle = 5637668Finding handle to textBox1Handle to textbox1 is 5506598Handle to combox1 is 4654626Handle to button1 is 5441374Handle to listbox1 is 723246Clicking button1Clicking away Error message boxForm has been foundTyping red and blue to applicationChecking the contents of textBox1Fetched 3charsTextBox1 contains = red Clicking on button1Checking listBox1 for purple0Test scenario result = PassHandle to menu is 672596591Handle to main help is 248775971Index to about is 265Handle to HelpItem2 is 519898823Index to HelpItem2SubItem2 is 269Exiting app in 4 seconds . . .DoneForm窗體顯示為:其中,得出分析:Main windows handle = 5637668獲得textbox控件句柄成功Handle to textbox1 is 5506598獲得Form中textbox控件句柄Handle to combox1 is 4654626獲得Form中Comobox控件句柄Handle to button1 is 5441374獲得Form中Button控件句柄Handle to listbox1 is 723246獲得Form中Listbox控件句柄Listbox中顯示“Result is purple”,測試代碼輸出“Test scenario result = Pass”表明本次WindowsUI測試成功。6、源程序測試端主要用于測試的代碼為static void Main(string args) try Console.WriteLine(nLaunching application undertest); string path = D:ProjectWindowsUITestWinAppWinAppbinDebugWinApp.exe; Process p = Process.Start(path); if (p != null) Console.WriteLine(Warning: process may already exist); IntPtr mwh = FindMainWindowsHandle(Form1,100,25); Console.WriteLine(Main windows handle = + mwh); Console.WriteLine(Finding handle to textBox1); IntPtr tb = FindWindowEx(mwh, IntPtr.Zero, null, ); IntPtr cb = FindWindowByIndex(mwh, 3); IntPtr butt = FindWindowEx(mwh, IntPtr.Zero, null, button1); IntPtr lb = FindWindowByIndex(mwh, 1); if (tb=IntPtr.Zero) throw new Exception(Unable to find textbox1); else Console.WriteLine(Handle to textbox1 is +tb); if (cb = IntPtr.Zero) throw new Exception(Unable to find combox1); else Console.WriteLine(Handle to combox1 is + cb); if (butt = IntPtr.Zero) throw new Exception(Unable to find button1); else Console.WriteLine(Handle to button1 is + butt); if (lb = IntPtr.Zero) throw new Exception(Unable to find listbox1); else Console.WriteLine(Handle to listbox1 is +lb); Console.WriteLine(Clicking button1); ClickOn(butt); Console.WriteLine(Clicking away Error message box); Thread.Sleep(1000); IntPtr mb = FindMessageBox(Error); if (mb = IntPtr.Zero) throw new Exception(Unable to find message box); IntPtr okButt = FindWindowByIndex(mb,1); if (okButt = IntPtr.Zero) throw new Exception(Unable to find OK button); ClickOn(okButt); Console.WriteLine(Typing red and blue to application); SendChars(tb, red); Console.WriteLine(Checking the contents of textBox1); uint WM_GETTEXT = 0x000D; byte buffer = new byte256; string text = null; int numFetched = SendMessage3(tb, WM_GETTEXT, 256, buffer); text = System.Text.Encoding.Unicode.GetString(buffer); Console.WriteLine(Fetched + numFetched + chars); Console.WriteLine(TextBox1 contains = + text); ClickOn(cb); SendChars(cb, bbblue); Console.WriteLine(Clicking on button1); ClickOn(butt); Console.WriteLine(Checking listBox1 for purple); Thread.Sleep(2000); uint LB_FINDSTRING = 0x018F; int result = SendMessage4(lb, LB_FINDSTRING, -1,Result is purple); Console.WriteLine(result); if (result = 0) Console.WriteLine(Test scenario result = Pass); else Console.WriteLine(Test scenario result = FAIL); IntPtr hMainMenu = GetMenu(mwh); Console.WriteLine(Handle to menu is +hMainMenu); IntPtr hHelp = GetSubMenu(hMainMenu, 2); Console.WriteLine(Handle to main help is + hHelp); int iAbout = GetMenuItemID(hHelp, 0); Console.WriteLine(Index to about is + iAbout); IntPtr hSub = GetSubMenu(hHelp, 2); Console.WriteLine(Handle to HelpItem2 is + hSub); int i
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年湖南省長沙市中考招生考試數(shù)學(xué)真題試卷(真題+答案)
- 預(yù)防肺炎主題班會課件
- 預(yù)防疾病安全課件
- 靜脈治療護(hù)士教育培訓(xùn)體系
- 《電子產(chǎn)品裝配與測試》課件-任務(wù)2 儀器的使用
- 預(yù)防兒童近視課件
- 預(yù)防傳染保健康課件
- 學(xué)校輔導(dǎo)員(班導(dǎo)師)管理及考評辦法
- 城市污水管網(wǎng)建設(shè)項目節(jié)能評估報告(參考模板)
- 2025年年云服務(wù)項目合作計劃書
- 2025新公安輔警招聘知識考試題庫及答案
- 2025輔警招聘考試題及答案
- 2025年中小學(xué)公開選拔校長筆試模擬試卷
- 鐵路行車安全培訓(xùn)課件
- 中文版兒童睡眠習(xí)慣問卷CSHQ 含評分維度
- 2025新譯林版英語八上單詞單(先鳥版)BD
- 小孩辦身份證的委托書范本
- MSOP(測量標(biāo)準(zhǔn)作業(yè)規(guī)范)測量SOP
- 保溫材料進(jìn)場質(zhì)量檢驗表
- DG-TJ 08-2122-2021 保溫裝飾復(fù)合板墻體保溫系統(tǒng)應(yīng)用技術(shù)標(biāo)準(zhǔn)
- GB∕T 23937-2020 工業(yè)硫氫化鈉
評論
0/150
提交評論