ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:39.27KB ,
资源ID:9894760      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9894760.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(软件测试实习报告.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

软件测试实习报告.docx

1、软件测试实习报告软件测试实习报告 班级: 软件122 学号: 12477218 姓名: 孙剑峰 指导老师: 王晖 实习时间: 15.11.30-15.12.4 1、 需求分析说明书软件行业的产业化发展对软件的质量及其开发效率都提出了较高要 求,而软件测试作为软件开发项目管理中软件质量保证的关键,正发挥着越来越重要的作用,自动化测试作为提高软件测试效率的重要手段也被更多的软件开发者所 重视。本文根据Windows平台下UI自动化测试的需求,基于.NET框架,采用数据驱动模型设计并实现了一套UI自动化测试系 统。使用底层的Windows自动化测试技术通过用户界面(UI)来测试应用程序。这些技术涉及

2、Win32API函数的调用(比如FindWindow()函数)以及向待测程序(AUT)发送Windows消息(比如WM_LBUTTONUP)。所有的Windows控件本质上都是一个窗体(window)。每个控件/窗体都有一个与之关联的句柄(handle),可以通过这个句柄来访问、操纵和检测这个控件和检测这个控件/窗体。对于轻量级的、底层的Windows窗体UI自动化测试程序来说,需要完成的工作主要有以下三类:找到目标窗体/控件的句柄操作这个窗体/控件检测这个窗体/控件2、项目开发计划2.1、计划分项目阶段本项目分为如下部分:资料搜集:搜集关于Win32API的资料与一些官方测试资料。需求分析:

3、分析本项目的软件需求并细化。软件设计:设计软件结构。软件编写:使用不同语言编写软件。实验分析:设计数据库并进行实验。完成报告:完成最终试验测试报告。2.2、计划分项目工作内容系统阶段重点工作完成指标完成时间前期工作1.了解Win32API2.需求分析1.利用官方提供进行WidowsUI2.完成需求报告2015/12/2算法建立1.项目设计2.软件编写1.完成项目设计报告书2.编写程序2015/12/7试验测试1.设计实验2.结果分析1.完成报告2015/12/83、软件设计说明书通过句柄获取待测程序的一个窗口,按钮,图标,输出设备,控件等。使用大量的Win32API调用来操作Windows窗体

4、应用程序。 1. 使用System.Disgnostics.Process.Start()方法启动程序。2. 获得待测程序主窗体的句柄要获得待测程序主窗体的句柄,可使用FindWindow() Win32 API函数来解决这个问题。C#要使用Win32 API函数FindWindow(),可通过.Net平台的invoke(P/Invoke)机制,P/Invoke相关特性位于System.Runtime.InteropServices命名空间内。C#签名如下:DllImport(user32.dll, EntryPoint = FindWindow, CharSet = CharSet.Auto

5、) 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. 获得无名字控件的句柄获得一没有名

6、字空间的句柄,可通过隐含索引来查找相应控件。5. 发送字符给控件我们要发送一个VM_CHAR消息。当按键按下时,VM_CHAR消息会发送给拥有键盘焦点的那个控件。实际上,VM_CHAR是一个Windows的常量符号,它定义为0x0102。wParam参数指定的是被按下按键的字符代码。lParam参数指定的是不同的按键状态码,比如重复次数、扫描码等。有了这些信息,就可以创建相应的C#签名: DllImport(user32.dll, EntryPoint = SendMessage, CharSet = CharSet.Auto) static extern void SendMessage1(

7、IntPtr hWnd, uint Msg, int wParam, int lParam);6、鼠标单击一个控件PostMessage()和SendMessage()的参数列表完全一致,他们的不同是:SendMessage()会等相应的Windows消息之后才会返回;PostMessage()不会。相应的C#签名:DllImport(user32.dll, EntryPoint = PostMessage, CharSet = CharSet.Auto)static extern bool PostMessage1(IntPtr hWnd, uint Msg, int wParam, int

8、 lParam);7. 处理消息对话框消息对话框是一个上层(top-level)窗体,使用FindWindow()函数捕获它。8、处理菜单9、检查应用程序状态10、使用VM_GETTEXT和SendMessage()获得控件状态4、测试用例设计设计待测窗体: 待测程序是一个用来做颜色混合的应用程序,设计的窗口如下:菜单栏的结构如下:File Edit HelpNew Cut AboutSave Copy UpdateExit Paste5、软件测试分析报告5.1 实验过程:系统:Windows10开发环境:VS20101. 安装VS2010开发环境2. 编写Form窗体,包括Textbox,C

9、omboBox,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 &

10、cb = red) listBox1.Items.Add(Result is purple); else listBox1.Items.Add(Result is black); 3. 创建测试程序初始化测试程序5.2 实验结果与分析Launching application undertestWarning: process may already existForm not yet foundForm not yet foundForm has been foundMain windows handle = 5637668Finding handle to textBox1Handle t

11、o 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 button1Check

12、ing 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 t

13、o 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

14、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.WriteLin

15、e(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

16、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(Han

17、dle 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(Err

18、or); 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(

19、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

20、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

21、); 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 iA

22、bout = GetMenuItemID(hHelp, 0); Console.WriteLine(Index to about is + iAbout); IntPtr hSub = GetSubMenu(hHelp, 2); Console.WriteLine(Handle to HelpItem2 is + hSub); int iSub = GetMenuItemID(hSub, 1); Console.WriteLine(Index to HelpItem2SubItem2 is + iSub); uint WM_COMMAND = 0x0111; /SendMessage2(mwh

23、, WM_COMMAND, iSub, IntPtr.Zero); Console.WriteLine(Exiting app in 4 seconds . . . ); Thread.Sleep(4000); IntPtr hFile = GetSubMenu(hMainMenu, 0); ClickOn(hFile); int iExit = GetMenuItemID(hMainMenu, 2); Thread.Sleep(2000); IntPtr Exit = GetSubMenu(hMainMenu, 2); ClickOn(Exit); SendMessage2(mwh, WM_COMMAND, iExit, IntPtr.Zero); Console.WriteLine(Done); catch(Exception ex) Console.WriteLine(Fatal error: + ex.Message); Console.ReadLine(); 7、实习总结本次实习是对WindowsUI的测试实习,测试windows窗体中的个功能是否实现,因为的是的程序比较简单,整的过程完成的还是比较快的。遇到的问题也挺烦的,比如遇到的通过索引获得句柄索引表的顺序不知道,获得的句柄老是不对,测试不通过,调试的时候,老是在这个地方纠结,但最终还是解决了。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1