軟件測(cè)試 實(shí)習(xí)報(bào)告.doc_第1頁(yè)
軟件測(cè)試 實(shí)習(xí)報(bào)告.doc_第2頁(yè)
軟件測(cè)試 實(shí)習(xí)報(bào)告.doc_第3頁(yè)
軟件測(cè)試 實(shí)習(xí)報(bào)告.doc_第4頁(yè)
軟件測(cè)試 實(shí)習(xí)報(bào)告.doc_第5頁(yè)
已閱讀5頁(yè),還剩8頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

軟件測(cè)試實(shí)習(xí)報(bào)告 班級(jí): 軟件122 學(xué)號(hào): 12477218 姓名: 孫劍峰 指導(dǎo)老師: 王暉 實(shí)習(xí)時(shí)間: 15.11.30-15.12.4 1、 需求分析說(shuō)明書(shū)軟件行業(yè)的產(chǎn)業(yè)化發(fā)展對(duì)軟件的質(zhì)量及其開(kāi)發(fā)效率都提出了較高要 求,而軟件測(cè)試作為軟件開(kāi)發(fā)項(xiàng)目管理中軟件質(zhì)量保證的關(guān)鍵,正發(fā)揮著越來(lái)越重要的作用,自動(dòng)化測(cè)試作為提高軟件測(cè)試效率的重要手段也被更多的軟件開(kāi)發(fā)者所 重視。本文根據(jù)Windows平臺(tái)下UI自動(dòng)化測(cè)試的需求,基于.NET框架,采用數(shù)據(jù)驅(qū)動(dòng)模型設(shè)計(jì)并實(shí)現(xiàn)了一套UI自動(dòng)化測(cè)試系 統(tǒng)。使用底層的Windows自動(dòng)化測(cè)試技術(shù)通過(guò)用戶界面(UI)來(lái)測(cè)試應(yīng)用程序。這些技術(shù)涉及Win32API函數(shù)的調(diào)用(比如FindWindow()函數(shù))以及向待測(cè)程序(AUT)發(fā)送Windows消息(比如WM_LBUTTONUP)。所有的Windows控件本質(zhì)上都是一個(gè)窗體(window)。每個(gè)控件/窗體都有一個(gè)與之關(guān)聯(lián)的句柄(handle),可以通過(guò)這個(gè)句柄來(lái)訪問(wèn)、操縱和檢測(cè)這個(gè)控件和檢測(cè)這個(gè)控件/窗體。對(duì)于輕量級(jí)的、底層的Windows窗體UI自動(dòng)化測(cè)試程序來(lái)說(shuō),需要完成的工作主要有以下三類:找到目標(biāo)窗體/控件的句柄操作這個(gè)窗體/控件檢測(cè)這個(gè)窗體/控件2、 項(xiàng)目開(kāi)發(fā)計(jì)劃2.1、計(jì)劃分項(xiàng)目階段本項(xiàng)目分為如下部分:資料搜集:搜集關(guān)于Win32API的資料與一些官方測(cè)試資料。需求分析:分析本項(xiàng)目的軟件需求并細(xì)化。軟件設(shè)計(jì):設(shè)計(jì)軟件結(jié)構(gòu)。軟件編寫:使用不同語(yǔ)言編寫軟件。實(shí)驗(yàn)分析:設(shè)計(jì)數(shù)據(jù)庫(kù)并進(jìn)行實(shí)驗(yàn)。完成報(bào)告:完成最終試驗(yàn)測(cè)試報(bào)告。2.2、計(jì)劃分項(xiàng)目工作內(nèi)容系統(tǒng)階段重點(diǎn)工作完成指標(biāo)完成時(shí)間前期工作1. 了解Win32API2. 需求分析1. 利用官方提供進(jìn)行WidowsUI2. 完成需求報(bào)告2015/12/2算法建立1. 項(xiàng)目設(shè)計(jì)2. 軟件編寫1. 完成項(xiàng)目設(shè)計(jì)報(bào)告書(shū)2. 編寫程序2015/12/7試驗(yàn)測(cè)試1. 設(shè)計(jì)實(shí)驗(yàn)2. 結(jié)果分析1. 完成報(bào)告2015/12/83、軟件設(shè)計(jì)說(shuō)明書(shū)通過(guò)句柄獲取待測(cè)程序的一個(gè)窗口,按鈕,圖標(biāo),輸出設(shè)備,控件等。使用大量的Win32API調(diào)用來(lái)操作Windows窗體應(yīng)用程序。1. 使用System.Disgnostics.Process.Start()方法啟動(dòng)程序。2. 獲得待測(cè)程序主窗體的句柄要獲得待測(cè)程序主窗體的句柄,可使用FindWindow() Win32 API函數(shù)來(lái)解決這個(gè)問(wèn)題。C#要使用Win32 API函數(shù)FindWindow(),可通過(guò).Net平臺(tái)的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. 獲得無(wú)名字控件的句柄獲得一沒(méi)有名字空間的句柄,可通過(guò)隱含索引來(lái)查找相應(yīng)控件。5. 發(fā)送字符給控件我們要發(fā)送一個(gè)VM_CHAR消息。當(dāng)按鍵按下時(shí),VM_CHAR消息會(huì)發(fā)送給擁有鍵盤焦點(diǎn)的那個(gè)控件。實(shí)際上,VM_CHAR是一個(gè)Windows的常量符號(hào),它定義為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)單擊一個(gè)控件PostMessage()和SendMessage()的參數(shù)列表完全一致,他們的不同是:SendMessage()會(huì)等相應(yīng)的Windows消息之后才會(huì)返回;PostMessage()不會(huì)。相應(yīng)的C#簽名:DllImport(user32.dll, EntryPoint = PostMessage, CharSet = CharSet.Auto)static extern bool PostMessage1(IntPtr hWnd, uint Msg, int wParam, int lParam);7. 處理消息對(duì)話框消息對(duì)話框是一個(gè)上層(top-level)窗體,使用FindWindow()函數(shù)捕獲它。8、處理菜單9、檢查應(yīng)用程序狀態(tài)10、 使用VM_GETTEXT和SendMessage()獲得控件狀態(tài)4、測(cè)試用例設(shè)計(jì)設(shè)計(jì)待測(cè)窗體: 待測(cè)程序是一個(gè)用來(lái)做顏色混合的應(yīng)用程序,設(shè)計(jì)的窗口如下:菜單欄的結(jié)構(gòu)如下:File Edit HelpNew Cut AboutSave Copy UpdateExit Paste5、軟件測(cè)試分析報(bào)告5.1 實(shí)驗(yàn)過(guò)程:系統(tǒng):Windows10開(kāi)發(fā)環(huán)境:VS20101. 安裝VS2010開(kāi)發(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)建測(cè)試程序初始化測(cè)試程序5.2 實(shí)驗(yàn)結(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”,測(cè)試代碼輸出“Test scenario result = Pass”表明本次WindowsUI測(cè)試成功。6、源程序測(cè)試端主要用于測(cè)試的代碼為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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論