[0059]In order to make the above objects, features and advantages of the present invention more comprehensible, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0060] The invention is applicable to numerous general purpose and special purpose computing system environments or configurations. For example: personal computer, server computer, handheld or portable device, tablet type device, multiprocessor system, distributed computing environment including any of the above systems or devices, etc.
[0061] The invention may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
[0062] One of the core concepts of the embodiments of the present invention is to establish an interface element library and an action element library, the interface element library stores interface elements of the software under test, and the action element library stores action parameters for operating the interface elements, The action parameters include action names and action execution scripts; and according to the predefined test logic, extract corresponding interface elements and action elements from the interface element library and action element library to generate test cases; then convert the test cases into Automated test scripts, finally analyze and execute the test scripts, and complete corresponding operations on the software under test; the present invention adopts the method of pre-establishing interface element libraries and action element libraries, so that the method of the present invention can be directly called when generating test scripts The script language in the interface element library and the action element library no longer requires software developers to manually write test scripts, which greatly improves the efficiency of software testing in software testing and can further improve the versatility of test scripts.
[0063] refer to figure 1 , which shows a flow chart of Embodiment 1 of a software testing method of the present invention, which may include the following steps:
[0064] Step 101: Establish an interface element library and an action element library, the interface element library stores the interface elements of the software under test, the action element library stores action parameters for operating the interface elements, and the action parameters include action names and Action execution script;
[0065] In practical applications, before testing the software, the software developer first establishes the interface element library, and the interface elements include the name, type and identification of the interface elements. In this embodiment, by establishing the interface element The library can avoid repeated recording of the same interface elements in different test cases, and can improve the reusability of interface elements; element;
[0066] At the same time, software developers also need to establish an action element library for storing action parameters for operating the interface elements. The action parameters include the name of the action on the interface element, and the action execution script corresponding to the action name, which may also include the type of said action name, saving a lot of work in recording scripts;
[0067] Step 102: According to the predefined test logic, extract corresponding interface elements and action elements from the interface element library and action element library, and generate test cases;
[0068] In practice, this step can be realized by extracting corresponding interface elements and action elements from the interface element library and action element library according to the specific steps of test execution, and generating Test cases; in practical applications, test cases in the software testing process can be composed of three parts: test input data, expected output results, and corresponding test execution steps;
[0069] Step 103: converting the test case into an automated test script, parsing and executing the automated test script, and completing corresponding operations on the software under test;
[0070] Wherein, the automated test script is a script program that can be used to test the software generated according to the test case. These script programs can be used to execute the test process of the software, and can simulate keyboard input, mouse clicks, etc. on the software under test. operate.
[0071] It can be understood that using the method of Embodiment 1 of the present invention can save the writing time of the test script by establishing the interface element library and the action element library, and the generated test script can be parsed and executed by the test tool without manual modification by software developers Or editing, reducing the human error that occurs in the programming process, greatly improving the software testing efficiency in the software testing process; in addition, the action execution script in the described action element storehouse is aimed at concrete action rather than test case, has improved action greatly. The shareability of execution scripts improves the maintainability and manageability of scripts; moreover, by establishing the interface element library, the interface elements of the software under test are fully shared and effectively managed, saving the need to grab interface elements. substantial development costs.
[0072] refer to figure 2 , showing a flow chart of Embodiment 2 of a software testing method of the present invention, which may include the following steps:
[0073] Step 201: Establish an interface element library and an action element library, the interface element library stores the interface elements of the software under test, the action element library stores action parameters for operating the interface elements, and the action parameters include action names and Action execution script;
[0074] In practical applications, before testing the software, the software developer first establishes the interface element library, the interface element includes the name, type and identification of the interface element, and the name of the interface element in the embodiment of the present invention is That is, the name of the control, and the identification is the definition of the tool language, which is the scripting language describing the name of the interface element;
[0075] It should be noted that those skilled in the art can easily know that the name of the interface element can also be the name of other fields, so the present invention does not limit the name of the interface element;
[0076] At the same time, software developers also need to establish an action element library for storing action parameters for operating the interface elements. The action execution script corresponding to the action noun may also include the type of the action name;
[0077] Step 202: Extract corresponding interface elements and action elements from the interface element library and action element library according to the predefined test logic;
[0078] It should be noted that the test logic can be understood as a test process, including multiple test sub-logic, each test sub-logic can be understood as a test sub-process for a certain window of the software under test, according to the multiple sub-logic Corresponding interface elements and action elements may be extracted from the interface element library and action element library;
[0079] Preferably, the interface elements and action elements are interface elements and action elements in a window of the tested software;
[0080] Step 203: Generate a test case template according to the interface elements and action elements;
[0081] Combining the corresponding interface elements and action names into a test case template, preferably, the test case template is displayed through the interface in the form of a two-dimensional input form;
[0082] Step 204: In the test case template, respectively define the test input data and expected output results required by each test sub-logic;
[0083] At the two-dimensional input form in the test case template, the test input data and expected output results required by each test sub-logic can be defined, and the process of defining the test input data can be understood as the assignment process of interface elements and action elements, By assigning a value, the defined test input data content can be matched with the interface element library and the action element library;
[0084] Step 205: combining the test input data and expected output results to form a test case;
[0085] After the definition of each test sub-logic is completed, the defined test input data and expected output results are combined to form a test case;
[0086] Step 206: converting the test case into a test script;
[0087] Preferably, the implementation of this step may include the following sub-steps:
[0088] Sub-step 2061: read the interface element name, action name, test input data and expected output results in the test case;
[0089] After the test case design is completed, read the interface element name, action name, test input data and expected output results in the test case line by line;
[0090] Sub-step 2062: Match the interface element name and action name in the interface element library and action element library respectively to obtain the corresponding interface element identifier and action execution script;
[0091] Matching the read interface element name and action name respectively in the interface element library and the action element library to obtain an interface element identifier corresponding to the interface element name and an action execution script corresponding to the action name;
[0092] Sub-step 2063: combine the interface element names and identifiers into a mapping file;
[0093] Combining the interface elements and identifiers into a mapping file, the mapping file is a text file that records the interface elements, and can record the identifiers and types of the interface elements, and the format of the content of the mapping file has been standardized and defined; The above-mentioned mapping file can be a Map file, and those skilled in the art can easily know that where and how the correspondence between the interface elements and the corresponding scripting languages are stored does not affect the implementation of the embodiments of the present invention, so this Invention does not limit it;
[0094] Sub-step 2064: combine the interface element name, action execution script, test input data and expected output result to generate an intermediate script;
[0095] Combine interface element names, action execution scripts, test input data, and expected output results to generate an intermediate script; the intermediate script is a scripting language that has been standardized. It can be seen that the scripting language is a descriptive language, and the scripting language has been clearly defined. Grammar and composition phrases, which can be directly run during the testing process of the software under test;
[0096] Sub-step 2065: replace the interface elements in the intermediate script through the mapping file, and dynamically obtain the automated test script;
[0097] Run the intermediate script, replace the interface elements in the intermediate script in combination with the mapping file, and dynamically obtain the automated test script;
[0098] Step 207: Analyzing and executing the automated test script, and completing corresponding operations on the software under test;
[0099] Analyzing and executing the automated test script, simulating actual operations such as keyboard input and mouse click on the software under test, and completing the process of the software test.
[0100] A specific example is used to further illustrate the software testing process of the present invention.
[0101]In practical applications, before testing the software, the software developer first establishes the interface element library, the interface element includes the name, type and identification of the interface element, and the name of the interface element in the embodiment of the present invention is That is, the name of the control, and the identification is the definition of the tool language, which is the scripting language describing the name of the interface element;
[0102] S1: Establish an interface element library;
[0103] refer to image 3 , showing a schematic diagram of an interface element library in a specific example of the present invention; wherein, the control name can be: department code, cost object code, man-hour type, etc., and the identification is the definition of the control name in the tool script ,E.g image 3 "name=txtEdit (2)" shown in, and the type of the control name, such as the type of the department code is "KDText";
[0104] S2: Establish an action element library;
[0105] At the same time, software developers also need to establish an action element library for storing action parameters for operating the interface elements. The action parameters include the name of the action for operating the interface elements. Referring to FIG. The schematic diagram of the action element storehouse; The name of the action element is "action word" shown in Figure 4, for example, "T adds", "T saves", etc., and the corresponding action execution script (that is, as shown in the figure "script") is "T, @formname, @formname, CLICK, 'Coords=27*-23'", type is default;
[0106] S3: According to the predefined test logic, extract corresponding interface elements and action elements from the interface element library and action element library, and generate a test case template according to the interface elements and action elements;
[0107] refer to Figure 5 , showing that according to image 3 and a schematic diagram of a test case template generated by the interface element library and the action element library shown in Figure 4, the test case template can be displayed in the form of a two-dimensional input form;
[0108] S4: In the test case template, respectively define test input data and expected output results required by each test sub-logic;
[0109] Software developers can respectively define the test input data and expected output results required by each test sub-logic in the two-dimensional input form, that is, assign values to the interface elements and action elements. For example, in the figure, give the control name "Department The value of "code" is defined as 12, and the "working hours type" is "machine working hours", etc., that is to define the test input data and expected output results required by each test sub-logic;
[0110] S5: Combining the test input data and expected output results to form a test case;
[0111] refer to Image 6 , shows a schematic diagram of a test case in a software testing method of the present invention. It can be understood that the test sub-logic corresponds to the test components shown in the figure, and multiple test components form a Image 6 The test case shown;
[0112] S6: Read interface element names, action names, test input data and expected output results in the test case;
[0113] S7: matching the interface element name and action name in the interface element library and action element library respectively, to obtain corresponding interface element identifiers and action execution scripts;
[0114] S8: Combining the interface element names and identifiers into a mapping file;
[0115] refer to Figure 7 , showing a schematic diagram of a mapping file that saves the corresponding relationship between the interface elements and the corresponding scripting language. The name of the mapping file is: Manufacturing Test Group\1.01.Daily Cost Module\B01.Actual Working Hours Entry.Map; it can be understood What's more, the mapping file can be a Map file;
[0116] S9: combining the name of the interface element, the action execution script, the test input data and the expected output result to generate an intermediate script;
[0117] After test case definition is finished, can generate intermediate script according to described test case, above-mentioned steps S6 to S9 are the process of generating intermediate script; Refer to Figure 8 , showing that the Image 6 The schematic diagram of the interface when the test case shown is converted to an intermediate script; also refer to Figure 9 , showing a schematic diagram of an intermediate script in a specific example of the present invention, the name of the intermediate script is: manufacturing test group\1.01. daily cost module\B01.actual man-hour entry.SDD;
[0118] S10: Read and execute the intermediate script line by line;
[0119] refer to Figure 10 , showing a schematic diagram of the interface when the intermediate script is executed, for example, the data read into the intermediate script is:
[0120] T frmEdit ComDo CLICK
[0121] T frmEdit KDSel SelectPartialMatch General Consumption Purpose
[0122] S11: Match the read frmEdit, ComDo, and KDSel in the interface element library, and obtain the identifications of frmEdit, ComDo, and KDSel in the interface elements:
[0123] frmEdit=Type=Window; Name=frmEdit
[0124] KDSel=Type=ComboListBox; ObjectIndex=0
[0125] ComDo=Type=ComboBox; Name=ComDo
[0126] It should be noted that, in the process of executing the automated test script, since the action name has already been defined, the action names——SelectPartialMatch and CLICK can be respectively converted into: Click;
[0127] S12: Execute the intermediate script, and convert the read interface element names and action names into automated test scripts that can simulate keyboard input and mouse clicks:
[0128] For example: Window SetContext, "Name=frmEdit", ""
[0129] ComboBox Click, "Name=ComDo", ""
[0130] ComboListBox Click, "ObjectIndex = 0", "Text = General Consumption", "Purpose"
[0131] refer to Figure 11 , showing a schematic diagram of the test script generated in a specific example of the present invention;
[0132] S13: Execute the automated test script, and complete actual operations such as keyboard input and mouse click on the software under test.
[0133] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. Because of the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0134] refer to Figure 12 , which shows a structural block diagram of a software testing device embodiment of the present invention, which may include the following modules:
[0135] The establishment module 1201 is used to establish an interface element library and an action element library, the interface element library stores the interface elements of the software under test, and the action element library stores action parameters for operating the interface elements, and the action parameters include Action name and action execution script;
[0136] An extraction module 1202, configured to extract interface elements and action elements required by the test logic from the interface element library and action element library according to the predefined test logic;
[0137] A test case generation module 1203, configured to generate a test case according to the interface elements and action elements;
[0138] Conversion test script module 1204, for converting the test case into an automated test script;
[0139] The parsing and execution module 1205 is configured to parse and execute the automated test script, and complete corresponding operations on the software under test.
[0140] In this embodiment, when the test case generation module generates a test case, it needs to extract the corresponding interface elements and action elements from the building module, and then combine the corresponding interface elements and action elements to generate a test case template , the software developer designs a test case on the test case template, and converts the test case into a test script, and the parsing execution module executes the test script, which can simulate actual operations such as keyboard input and mouse click on the software under test .
[0141] refer to Figure 13 , which shows a structural block diagram of a preferred embodiment of a software testing device of the present invention, which may include the following modules:
[0142] The establishment module 1301 is used to establish an interface element library and an action element library, the interface element library stores the interface elements of the software under test, and the action element library stores action parameters for operating the interface elements, and the action parameters include Action name and action execution script;
[0143] An extraction module 1302, configured to extract interface elements and action elements required by the test logic from the interface element library and action element library according to the predefined test logic;
[0144] A test case generation module 1303, configured to generate a test case according to the interface elements and action elements;
[0145] Generate a template submodule 13031, used to generate a test case template according to the interface elements and action elements;
[0146] The definition sub-module 13032 is used to respectively define the test input data and expected output results required by each test sub-logic in the test case template;
[0147] The combination sub-module 13033 is used to combine the test sub-logic to form a test case.
[0148] Preferably, the interface element includes the name, type and identification of the interface element.
[0149] Preferably, the interface element is a control, the name of the interface element is the name of the control, and the identifier of the interface element is the definition of the control in the tool language.
[0150] Conversion test script module 1304, for converting the test case into an automated test script;
[0151]The reading sub-module 13041 is used to read interface element names, action names, test input data and expected output results in the test case;
[0152] The matching sub-module 13042 is configured to match the interface element name and action name in the interface element library and action element library respectively, and obtain corresponding interface element identifiers and action execution scripts;
[0153] Generate a mapping file submodule 13043, used to combine the interface element names and identifiers into a mapping file;
[0154] Generate an intermediate script submodule 13044, which is used to combine the interface element name, action execution script, test input data and expected output results to generate an intermediate script;
[0155] The test script generation sub-module 13045 is used to replace the interface elements in the intermediate script through the mapping file to dynamically obtain the automated test script.
[0156] The parsing and execution module 1305 is configured to parse and execute the automated test script, and complete corresponding operations on the software under test.
[0157] refer to Figure 14 , showing the application Figure 13 The flow chart of software testing in the preferred embodiment shown may include the following steps:
[0158] Step 1401: The establishment module establishes an interface element library and an action element library, the interface element library stores the interface elements of the software under test, the action element library stores action parameters for operating the interface elements, and the action parameters include actions name and action to execute the script;
[0159] Step 1402: The extraction module extracts the interface elements and action elements required by the test logic from the interface element library and the action element library according to the predefined test logic;
[0160] Step 1403: the generating template submodule generates a test case template according to the interface elements and action elements;
[0161] Step 1404: define sub-modules in the test case template, respectively define the test input data and expected output results required by each test sub-logic;
[0162] Step 1405: The combination sub-module combines the test sub-logic to form a test case;
[0163] Step 1406: The reading submodule reads the interface element name, action name, test input data and expected output results in the test case;
[0164] Step 1407: The matching submodule matches the interface element name and action name in the interface element library and action element library respectively, and obtains the corresponding interface element identifier and action execution script;
[0165] Step 1408: the generating mapping file submodule combines the interface element names and identifiers into a mapping file;
[0166] Step 1409: Generate an intermediate script submodule to generate an intermediate script by combining the interface element name, action execution script, test input data and expected output results;
[0167] Step 14010: The submodule of generating test scripts replaces the interface elements in the intermediate scripts through the mapping file, and dynamically obtains the automated test scripts;
[0168] Step 14011: The parsing and execution module parses and executes the automated test script, and completes corresponding operations on the software under test.
[0169] As for the device embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and for the related parts, please refer to the part of the description of the method embodiment.
[0170] A software testing method and a software testing device provided by the present invention have been described above in detail. In this paper, specific examples are used to illustrate the principle and implementation of the present invention. The description of the above embodiments is only used to help understanding The method of the present invention and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation and scope of application. In summary, the content of this specification should not be construed as a limitation of the invention.