软件测试 实习报告Word文档格式.docx
- 文档编号:22636838
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:13
- 大小:39.47KB
软件测试 实习报告Word文档格式.docx
《软件测试 实习报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《软件测试 实习报告Word文档格式.docx(13页珍藏版)》请在冰豆网上搜索。
需求分析:
分析本项目的软件需求并细化。
软件设计:
设计软件结构。
软件编写:
使用不同语言编写软件。
实验分析:
设计数据库并进行实验。
完成报告:
完成最终试验测试报告。
2.2、计划分项目工作内容
系统阶段
重点工作
完成指标
完成时间
前期工作
1.了解Win32API
2.需求分析
1.利用官方提供进行WidowsUI
2.完成需求报告
2015/12/2
算法建立
1.项目设计
2.软件编写
1.完成项目设计报告书
2.编写程序
2015/12/7
试验测试
1.设计实验
2.结果分析
1.完成报告
2015/12/8
3、软件设计说明书
通过句柄获取待测程序的一个窗口,按钮,图标,输出设备,控件等。
使用大量的Win32API调用来操作Windows窗体应用程序。
1.使用System.Disgnostics.Process.Start()方法启动程序。
2.获得待测程序主窗体的句柄
要获得待测程序主窗体的句柄,可使用FindWindow()Win32API函数来解决这个问题。
C#要使用Win32API函数FindWindow(),可通过.Net平台的invoke(P/Invoke)机制,P/Invoke相关特性位于System.Runtime.InteropServices命名空间内。
C#签名如下:
[DllImport("
user32.dll"
EntryPoint="
FindWindow"
CharSet=CharSet.Auto)]
staticexternIntPtrFindWindow(stringlpClassName,stringlpWindowName);
3.获得有名字控件的句柄
FindWindowEx"
CharSet=CharSet.Auto)]9staticexternIntPtrFindWindowEx(IntPtrhwndParent,IntPtrhwndChildAfter,stringlpszClass,stringlpszWindow);
4.获得无名字控件的句柄
获得一没有名字空间的句柄,可通过隐含索引来查找相应控件。
5.发送字符给控件
我们要发送一个VM_CHAR消息。
当按键按下时,VM_CHAR消息会发送给拥有键盘焦点的那个控件。
实际上,VM_CHAR是一个Windows的常量符号,它定义为0x0102。
wParam参数指定的是被按下按键的字符代码。
lParam参数指定的是不同的按键状态码,比如重复次数、扫描码等。
有了这些信息,就可以创建相应的C#签名:
[DllImport("
SendMessage"
staticexternvoidSendMessage1(IntPtrhWnd,uintMsg,intwParam,intlParam);
6、鼠标单击一个控件
PostMessage()和SendMessage()的参数列表完全一致,他们的不同是:
SendMessage()会等相应的Windows消息之后才会返回;
PostMessage()不会。
相应的C#签名:
PostMessage"
staticexternboolPostMessage1(IntPtrhWnd,uintMsg,intwParam,intlParam);
7.处理消息对话框
消息对话框是一个上层(top-level)窗体,使用FindWindow()函数捕获它。
8、处理菜单
9、检查应用程序状态
10、使用VM_GETTEXT和SendMessage()获得控件状态
4、测试用例设计
设计待测窗体:
待测程序是一个用来做颜色混合的应用程序,设计的窗口如下:
菜单栏的结构如下:
FileEditHelp
NewCutAbout
SaveCopyUpdate
ExitPaste
5、软件测试分析报告
5.1实验过程:
系统:
Windows10
开发环境:
VS2010
1.安装VS2010开发环境
2.编写Form窗体,包括Textbox,ComboBox,Button,ListBox。
其核心代码为:
privatevoidbutton1_Click(objectsender,EventArgse)
{
stringtb=textBox1.Text;
stringcb=comboBox1.Text;
if(tb=="
<
entercolor>
"
||cb=="
pick>
)
MessageBox.Show("
Youneed2colors"
"
Error"
);
else
if(tb==cb)
listBox1.Items.Add("
Resultis"
+tb);
elseif(tb=="
red"
&
&
cb=="
blue"
||tb=="
cb=="
Resultispurple"
Resultisblack"
}
3.创建测试程序初始化测试程序
5.2实验结果与分析
Launchingapplicationundertest
Warning:
processmayalreadyexist
Formnotyetfound
Formhasbeenfound
Mainwindowshandle=5637668
FindinghandletotextBox1
Handletotextbox1is5506598
Handletocombox1is4654626
Handletobutton1is5441374
Handletolistbox1is723246
Clickingbutton1
ClickingawayErrormessagebox
Typing'
red'
and'
blue'
toapplication
CheckingthecontentsoftextBox1
Fetched3chars
TextBox1contains=red
Clickingonbutton1
CheckinglistBox1for'
purple'
Testscenarioresult=Pass
Handletomenuis672596591
Handletomainhelpis248775971
Indextoaboutis265
HandletoHelpItem2is519898823
IndextoHelpItem2SubItem2is269
Exitingappin4seconds...
Done
Form窗体显示为:
其中,得出分析:
获得textbox控件句柄成功
获得Form中textbox控件句柄
获得Form中Comobox控件句柄
获得Form中Button控件句柄
获得Form中Listbox控件句柄
Listbox中显示“Resultispurple”,测试代码输出“Testscenarioresult=Pass”
表明本次WindowsUI测试成功。
6、源程序
测试端主要用于测试的代码为
staticvoidMain(string[]args)
try
Console.WriteLine("
\nLaunchingapplicationundertest"
stringpath="
D:
\\Project\\WindowsUITest\\WinApp\\WinApp\\bin\\Debug\\WinApp.exe"
;
Processp=Process.Start(path);
if(p!
=null)
processmayalreadyexist"
IntPtrmwh=FindMainWindowsHandle("
Form1"
100,25);
Mainwindowshandle="
+mwh);
FindinghandletotextBox1"
IntPtrtb=FindWindowEx(mwh,IntPtr.Zero,null,"
IntPtrcb=FindWindowByIndex(mwh,3);
IntPtrbutt=FindWindowEx(mwh,IntPtr.Zero,null,"
button1"
IntPtrlb=FindWindowByIndex(mwh,1);
if(tb==IntPtr.Zero)
thrownewException("
Unabletofindtextbox1"
Handletotextbox1is"
+tb);
if(cb==IntPtr.Zero)
Unabletofindcombox1"
Handletocombox1is"
+cb);
if(butt==IntPtr.Zero)
Unabletofindbutton1"
Handletobutton1is"
+butt);
if(lb==IntPtr.Zero)
Unabletofindlistbox1"
Handletolistbox1is"
+lb);
Clickingbutton1"
ClickOn(butt);
ClickingawayErrormessagebox"
Thread.Sleep(1000);
IntPtrmb=FindMessageBox("
if(mb==IntPtr.Zero)
Unabletofindmessagebox"
IntPtrokButt=FindWindowByIndex(mb,1);
if(okButt==IntPtr.Zero)
UnabletofindOKbutton"
ClickOn(okButt);
toapplication"
SendChars(tb,"
CheckingthecontentsoftextBox1"
uintWM_GETTEXT=0x000D;
byte[]buffer=newbyte[256];
stringtext=null;
intnumFetched=SendMessage3(tb,WM_GETTEXT,256,buffer);
text=System.Text.Encoding.Unicode.GetString(buffer);
Fetched"
+numFetched+"
chars"
TextBox1contains="
+text);
ClickOn(cb);
SendChars(cb,"
bbblue"
Clickingonbutton1"
Thread.Sleep(2000);
uintLB_FINDSTRING=0x018F;
intresult=SendMessage4(lb,LB_FINDSTRING,-1,"
Console.WriteLine(result);
if(result>
=0)
Testscenarioresult=Pass"
Testscenarioresult=FAIL"
);
IntPtrhMainMenu=GetMenu(mwh);
Handletomenuis"
+hMainMenu);
IntPtrhHelp=GetSubMenu(hMainMenu,2);
Handletomainhelpis"
+hHelp);
intiAbout=GetMenuItemID(hHelp,0);
Indextoaboutis"
+iAbout);
IntPtrhSub=GetSubMenu(hHelp,2);
HandletoHelpItem2is"
+hSub);
intiSub=GetMenuItemID(hSub,1);
IndextoHelpItem2SubItem2is"
+iSub);
uintWM_COMMAND=0x0111;
//SendMessage2(mwh,WM_COMMAND,iSub,IntPtr.Zero);
Exitingappin4seconds..."
Thread.Sleep(4000);
IntPtrhFile=GetSubMenu(hMainMenu,0);
ClickOn(hFile);
intiExit=GetMenuItemID(hMainMenu,2);
IntPtrExit=GetSubMenu(hMainMenu,2);
ClickOn(Exit);
SendMessage2(mwh,WM_COMMAND,iExit,IntPtr.Zero);
Done"
catch(Exceptionex)
Fatalerror:
"
+ex.Message);
Console.ReadLine();
7、实习总结
本次实习是对WindowsUI的测试实习,测试windows窗体中的个功能是否实现,因为的是的程序比较简单,整的过程完成的还是比较快的。
遇到的问题也挺烦的,比如遇到的通过索引获得句柄索引表的顺序不知道,获得的句柄老是不对,测试不通过,调试的时候,老是在这个地方纠结,但最终还是解决了。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件测试 实习报告 软件 测试 实习 报告