Automated test selection with Visual Basic 6.0
HK_VON's Blog
Automated testing with Visual Basic 6.0 (Sai Bao Software Review Center
1 Wizard and Template A wide range of wizards in Visual Basic can be used. One of the very useful guiders is the Data Form Wizard, which can create a data window that can connect Access or ODBC databases, which can be set to view a single record separately or batch data records in the form of table, so A test tool for checking the contents of the database can be quickly customized and easy to use. The form template can not only quickly create a standard window, but also with these windows to generate source code, these automatically generated code can be partially or fully applied to a window customized to test, which is very effective for improving test efficiency. of. In addition, some other wizards such as data object wizards, ActiveX Control Window Wizards can achieve minimal coding efforts to create and configure some useful test objects. 2 Visual Data Manager Visual Data Manager can quickly connect to the ODBC or OLEDB data source to view database structures, data tables, views, and other basic objects. Use it to check the background database to implement the database application test. That is to say, if the measured application contains a database in SQL Server, Sybase, Oracle, and Access, you can check all of these databases by visualizing data managers without having to log in to the DBMS interface separately. By Visual Basic as a generic front desk database manager to manage a background database accessible with ODBC or OLEDB, save the testing time of the test engineer and may spend the training time that can be familiar with these database products. Visual Data Manager supports white box test through database input and test SQL statements. Use it to modify background data, even create new data objects such as data tables, store procedures, and data views. Some SQL statements that are used to test data (typically used to retrieve defects for duplicate data rows and exposure integrity) can be created and executed here if necessary. 3 Object Browser Object Browser Object Browser is another very useful Visual Basic tool, through it to check the properties and methods of the object output, and various necessary parameters; testers can use this information to create verification and feature of these objects Sex test, especially for object-oriented tests, very useful and very effective. Object browser can display a custom COM object, which lists the properties, methods, and events of the object, and this object can be developed with any language that supports COM object models. Setting up an object-related information in an object browser and viewing a test person who lacks test training for a short time, of course, to establish a Visual Basic test script to test the properties, methods, events, and events need to do Some write code work. Four Visual Basic's Application Examples of Automated Test Work The following is some examples of using Visual Basic to implement test automation or related work in actual testing, such as recording test results information, simple GUI testing. 1 Using the Text File Record Test Information Example 1Open "Testlog.txt" for Input AS # 1 'Opens the record file Print # 1, FileDateTime ("c: /windows/calc.exe")' record the date and time created by the test program Print # 1, Filelen ("C: /Windows/calc.exe") 'records the length of the test program Print # 1, curdir' records the current directory path Print # 1, Environment ("windir") record the current windows directory path Print # 1, now 'record test start date and time
...... 'Record Test Procedure Information Close # 1' Close Record File In the test process, a job that is often done in the test is to find an error message to check the application's login file. These login files are usually text files, and for any Programming languages are easy to open and read these files with basic file operation functions. The other work is to record the test process information and test results, which is essentially mentioned above to use the same function function: a simple record method is to write a test result into a text file. The code shown in Example 1 is to implement these recording functions. 2 GUI function test example 2 shell ("c: /Windows/calc.exe") 'Start calculator for i = 1 to 100' Set calculation cycle sendKeys I & "{ }", True 'send hit button action to calculation NEXT I 'Calculates the value SendKeys "=", true' in black box test, and implement the test script to write test scripts to simulate the daily operation input of the test script. The shell function and sendKeys function using Visual Basic can simply effectively implement some GUI function tests. The display code of Example 2 opened a Windows calculator, and then sent a keystroke action to simulate the user input, calculate the sum of a series of values (1 to 100); the startup program calls the SHELL function of Visual Basic, the SendKeys instruction is used to send hits Key to an application to simulate user input and calculation results. 3 Reading and setting the Registry Information Example 3 DIM ASTRSETTINGS () AS String 'Defines Variable LstSettings.clear' Clear List Box Content ASTRSETTINGS = GetallSettings (TestAppName, TXTSECTION) 'Call the dedicated function Return to the VB' dedicated location Registry Information for iCount = 0 to Ubound (ASTRSETTINGS) 'Displayed in the list box by looping in the list box LstSettings.addItem Astrsettings (ICOUNT, 0) & ":" _ & ASTRSETTINGS (ICOUNT, 1) Next ICOUNT Note: TestAme is a test application The name of the program has a lot of time to check the registry. The registration table is a place where the application installation settings, options and other important information. Visual Basic 6.0 includes a new functional function that returns information from the registry key value location dedicated to the Visual Basic application software. These functions are simply set and returned to these registry key values, which is especially useful for the application developed with Visual Basic. Example 3 The code returns all registry information in the location "HKEY_CURRENT_USER / VB AND VBA Program Settings /" in the registry and displays this information in a list box named LSTSETTINGS. To access the registry information of other locations, you need to call the Windows API function. The five sizes can be seen, in order to make up for the shortcomings of the current automated test tool, select some test scripts or test aids in actual work in actual work, and Visual Basic 6.0 is easy to learn due to its powerful function. Easy, there is a wide range of user bases, and it is one of the tools applied to test automation.