About software testing, in fact, software testing and product testing QC very much the same.
In fact, software development and software testing are different.
First, the Software installation
Follow the prompts and check "install Microsoft Script Debugger" to fully install.
Second, the software start
Select the appropriate plugin to load for the test object and select "Blank test" in the Welcome window.
Iii. Bring your own resources
F1 can get a rich help document, the menu Help->product Feature movies contains a few examples of video, and in the Start menu QTP program directory you can see the practice sample program flight.
Iv. Conducting Tests
QTP uses VBScript as the test scripting language, so you need to have some understanding of it, such as data types, looping structures, and so on, which you will not repeat here.
Set the menu Automation->record and Run settings. In the test for Windows application, there are several options, "record and run test on any open windows-based application" for recording and running applications that appear on all systems, " Record and run only on "requires further designation of the recording and running program, divided into three types:
"Application opened by QuickTest" only Records and runs the program called by QTP, calling the method:
' Create Wscript Shell object Set shell = CreateObject ("Wscript.Shell") ' Start Notepad program through the Shell object's Run method Shell.run ' Notepad ' program can use absolute path, But the folder name cannot contain a space another way
Invokeapplication "E:\SVN\debug\demo1.exe" and
Systemutil.run "E:\nms\demo1.exe", "E:\nms\demo1.exe", "Open" "applications opened via the Desktop (by Windows shell)" Only programs that are started from the Start menu, the desktop, or from the Windows file browser are recorded.
"Application specified below" The program in the recording list.
When set up, you can do RECORD,QTP and the user's actions will be recorded. Use Run to reproduce. The recorded script can be edited directly, which makes it easy to adjust the details and add features, as well as capture objects. The function of QTP is not limited to this, it is not studied in depth. The following uses monkeys to test the various modules to learn the application of scripting language.
Five, Monkey test
Monkey tests are also called random tests, and the principle is to use test tools to randomly generate keyboard strokes and mouse click events, like a monkey pounding the keyboard. In this project development, the monkey test did find a lot of anomalies and errors, a large number of repeated runs by the computer to complete, saving a lot of manpower. The following code is used, some of which are not used, and are therefore commented out.
Set MyApp = CreateObject ("Wscript.Shell") MyApp. Run "C:\fa ke\flight4a.exe" Dialog ("NMS login"). Winedit ("Edit"). SetSelection 0,3dialog ("NMS login"). Winedit ("Edit"). Set "201" Dialog ("NMS login"). Winedit ("Edit_2"). SetSelection 0,2dialog ("NMS login"). Winedit ("Edit_2"). Set "7" Dialog ("NMS login"). Winbutton ("OK"). Clickwait (3) window ("Mysnmp"). Winlistview ("SysListView32"). Click 111,46 ' Start performance counter record ' Systemutil.run ' logman ', "Start perf_log" ' Take advantage of dotnetfactory to get screen height and width set var_createinstance = Dotnetfactory.createinstance ("System.Windows.Forms.Screen", "System.Windows.Forms") Width = Var_ CreateInstance.PrimaryScreen.WorkingArea.WidthHeight = Var_CreateInstance.PrimaryScreen.WorkingArea.Height ' MsgBox width & "," & height "Note: Workingarea does not include the taskbar, docking window, and docking toolbar ' get screen height and width by WMI object ' Set objWMIService = GetObject (" Winmgmts:\ "& StrComputer &" \root\cimv2 ") ' Set colitems = objWMIService.ExecQuery (' "SELECT * from Win32_DesktopMonitor",, () ' For each objitem in colitems ' Height = Objitem.screenheight ' Width = objitem . ScreenWidth ' Next ' MsgBox Width &, ' & Height ' Loop executes the test count for i = 1 to-j = 1 to 4 z = randomnumber (1,7) Window ( "Mysnmp"). Wintoolbar ("ToolbarWindow32"). Press Z If z = 5 then window ("Mysnmp"). Dialog ("Mysnmp"). Winbutton ("OK"). Click Elseif z = 6 then window ("Mysnmp"). Dialog ("Configuration"). Winbutton ("Cancel"). Click Elseif z = 7 then window ("Mysnmp"). Dialog ("restart"). Winbutton ("Cancel"). Click End If Wait (2) Next ' Initialize random number generator ' Randomize ' randomly pick 0 to screen width between integer ' Set x = Int ((Width * rnd+0)) ' randomly select 0 to screen height integer ' Set y = Int ((Height * rnd+0)) ' MsgBox x & ', ' & Y ' can also use randomnumber x = Randomnumber (0, Width) y = Randomnumber (0,h Eight) ' MsgBox x & ', ' & y ' through Extern access to Windows API functions ' Extern.declare micvoid, ' MouseEvent ', ' user32.dll ', ' Mouse_ev Ent ", Micinteger,micinteger, Micinteger, Micinteger, Micinteger ' move the mouse to the position ' extern.mouseevent 80+1,10, 100, 0, 0 ' left mouse click ' Extern.mouseeveNT 2+4,0,0,0,0 ' Extern.declare micinteger, "Windowfrompoint", "user32.dll", "Windowfrompoint", Micinteger,micinteger ' Msgbox extern.windowfrompoint (0,0) ' first wraps Windows API functions in C # and then accesses ' Set dotnetfactory ' in qtp via apiinstance = Dotnetfactory.createinstance ("Winapi.mouseapi", "C:\Documents and settings\administrator\ desktop \snmp\monkeytest2\ Monkeytest2\winapi.dll ") Set apiinstance = dotnetfactory.createinstance (" Winapi.mouseapi "," C:\Users\WY\Desktop\ Monkeytest2\monkeytest2\winapi.dll ") ' mouse moves to that location apiinstance.movemouse x, y ' records test information reporter.reportevent MicDone," MouseMove "," Mouse moves to: "& X &", "& Y" left mouse button click Window ("Mysnmp"). Activatewait (1) apiinstance.clickmouse "left", X, y, 0, 0 ' record test information reporter.reportevent micdone, "MouseClick", "Mouse click location:" & X & "," & y Strarray = Array ("1234567890", "abcdefghijklmnopqrstuvwxyz", "[email protected]#$&*") n = Randomnumber (0, 2) str = strarray (n) ' MsgBox str ' is called. Net Sendwait method of the SendKeys class to enter the string window ("Mysnmp"). Activatewait (1) Set sendkeyinstance = dotnetfactory.createinstance ("System.Windows.Forms.SendKeys", " System.Windows.Forms ") sendkeyinstance.sendwait str ' sendkeyinstance.sendwait str ' get current time str =time ' because the time string cannot be directly used as the file name, Windows file name does not allow ":", so use regular expressions to replace set regEx = New RegExp regex.pattern = ":" regex.ignorecase = True Regex.global = truestr = Regex.Replace (str, "") ' Set regEx1 = New RegExp ' Regex1.pattern =" "' Regex1.ignorecase = True ' Regex1.global = True ' str1 = Regex1.replace ( STR, "") ' str2 = Regex.Replace (str1,"") str2 = str &""& Randomnumber (0,1000) ' screenshot window (" Mysnmp "). Capturebitmap "C:\Users\WY\Desktop\MonkeyTest2" & str2 & ". png" ' Window ("Mysnmp"). Capturebitmap "C:\Documents and settings\administrator\ Desktop \snmp\monkeytest2" & str2 & ". png" ' Dialog ("Microsoft Visual C + + Debug "). Capturebitmap "C:\Users\WY\Desktop\Err_" &STR2 & ". png" Next ' End performance counter record ' Systemutil.run ' logman ', "Stop perf_log "Wait (") window ("Mysnmp"). Close ' Dialog ("Microsoft Visual C + + Debug"). Winbutton ("Abort (A)"). Clickdialog ("Mysnmp"). Winbutton ("No (N)"). Click this code provides performance logging, the key part of the screenshot function, the test content is to enter the software, random click on the Form button (Generate dialog box directly close dialog box), keyboard random tapping, software form random click. Taking into account the response of the program, wait is added waiting (no synchronization tool is used). Can be a more generic template (in fact it is a template from a book).
About software testing can be discussed together. End
QTP Quick Test Primer