A testing method, device, equipment and storage medium
The test items are determined through the human-computer interactive interface and the main loop variable and traversal number are automatically selected, which solves the problem that the entry parameter variable cannot be accurately controlled in the existing technology, and achieves the flexibility and comprehensiveness of the test.
Patent Information
- Application Number
- CN202110539751.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-18
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2041-05-18
AI Technical Summary
The prior art cannot accurately control the incoming parameter variables in program testing, resulting in insufficient testing flexibility, especially when there are many incoming parameter variables, each variable cannot be controlled in a targeted manner.
The test items are determined through the human-computer interactive interface, including variable names, traversal methods and variable value determination methods, and the main loop variable name and traversal number are automatically selected, and the variables are assigned in combination with file references and user-specified methods to achieve accurate control of variables.
Improves the flexibility of testing and can accurately test each variable in a targeted manner, ensuring the comprehensiveness and integrity of the test without frequent modification of the test code.
Smart Images

Figure CN115373966B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a testing method, apparatus, device, and storage medium. Background Art
[0002] Currently, when testing programs on a test platform, files or variables can be used as input parameters. This means that the program can be tested by reading file contents or variable values for data-driven testing. However, since not all file contents require input parameters, the code must specify which parameters are required and which are not. Furthermore, the code must specify the number of iterations of the program under test, requiring frequent modification of the test code based on the input parameters and iteration count. When there are many input variables, it is impossible to precisely control each variable in a targeted manner.
[0003] Therefore, how to accurately control the input parameter variables during program testing and improve testing flexibility is a problem that technical personnel in this field need to solve. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a testing method, apparatus, device, and storage medium to accurately control the input parameters during program testing and improve testing flexibility. The specific solution is as follows:
[0005] To achieve the above objectives, the present application provides a testing method, comprising:
[0006] Obtain at least one test item determined by the user based on the human-computer interaction interface; each test item includes: a variable name; a traversal method, a variable value, and a variable value determination method corresponding to the variable name; and identification information of whether the variable name is designated as a main loop variable name;
[0007] If it is determined based on the identification information that none of the variable names in each test item is designated as the main loop variable name, then judging based on the variable value determination method whether there is a test item that determines the variable value by file reference; if so, selecting the variable name with the largest number of variable values from the test item as the main loop variable name, and determining the number of variable values of the main loop variable name as the number of traversals;
[0008] Each test item is taken as an item to be tested, and the variable name in the item to be tested is assigned a value according to the variable value determination method in the item to be tested, and the assigned variable name is passed into the program to be tested for program testing according to the traversal times and the traversal method in the item to be tested.
[0009] Preferably, assigning values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes:
[0010] If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by file reference, and the item to be tested includes at least one variable name, then in the reference file corresponding to the item to be tested, a character string that is identical to the variable name in the item to be tested is searched, and the data value corresponding to the character string in the reference file is used to assign a value to the variable name in the item to be tested.
[0011] Preferably, assigning values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes:
[0012] If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a user-specified method, and the item to be tested includes a variable name, assigning a value to the variable name in the item to be tested using the data value input by the user based on the human-computer interaction interface;
[0013] or
[0014] If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a user-specified method, and the item to be tested includes at least two variable names and the variable values corresponding to the at least two variable names are the same, then the data value input by the user based on the human-computer interaction interface is used to assign a value to the variable name in the item to be tested.
[0015] Preferably, assigning values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes:
[0016] If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a file reference method and a user-specified method, and the item to be tested includes a variable name, then in the reference file corresponding to the item to be tested, a character string identical to the variable name in the item to be tested is searched, and after assigning a value to the variable name in the item to be tested using the data value corresponding to the character string in the reference file, the variable name in the item to be tested is assigned a value using the data value input by the user based on the human-computer interaction interface.
[0017] Preferably, assigning values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes:
[0018] Each test item also includes: a repetition mark indicating whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request; if, based on the repetition mark in the item to be tested, it is determined that the variable name in the item to be tested needs to be repeatedly assigned the same value, the variable name in the item to be tested is repeatedly assigned the same value according to the variable value determination method in the item to be tested.
[0019] Preferably, after the variable names after the assignment are passed into the program to be tested for program testing, the method further includes:
[0020] Record program test results, compare the program test results with expected results, obtain comparison results, and store and visualize the comparison results.
[0021] Preferably, it also includes:
[0022] If it is determined based on the identification information that variable names in N test items are designated as the main loop variable name, a variable name with the largest number of variable values is selected from the N test items as the main loop variable name.
[0023] Preferably, it also includes:
[0024] If it is determined based on the variable value determination method that there is no test item that determines the variable value by file reference, then the variable name with the largest number of variable values is selected from all test items as the main loop variable name.
[0025] In another aspect, the present application further provides a testing device, comprising:
[0026] An acquisition module is configured to acquire at least one test item determined by a user based on a human-computer interaction interface; each test item includes: a variable name; a traversal method, a variable value, and a variable value determination method corresponding to the variable name; and identification information of whether the variable name is designated as a main loop variable name;
[0027] a determination module configured to, if it is determined based on the identification information that none of the variable names in each test item is designated as the main loop variable name, determine, based on the variable value determination method, whether there is a test item that determines variable values by file reference; and if so, select, from the test item, a variable name with the largest number of variable values as the main loop variable name, and determine the number of variable values of the main loop variable name as the number of traversals;
[0028] The test module is used to treat each test item as an item to be tested, assign values to the variable names in the item to be tested according to the variable value determination method in the item to be tested, and pass the assigned variable names into the program to be tested for program testing according to the traversal times and the traversal method in the item to be tested.
[0029] Preferably, the test module includes:
[0030] The first assignment unit is used to, if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by file reference, and the item to be tested includes at least one variable name, then search for a character string that is identical to the variable name in the item to be tested in the reference file corresponding to the item to be tested, and use the data value corresponding to the character string in the reference file to assign a value to the variable name in the item to be tested.
[0031] Preferably, the test module includes:
[0032] The second assignment unit is used to assign a value to the variable name in the item to be tested using the data value input by the user based on the human-computer interaction interface if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by the user specified method, and the item to be tested includes a variable name; or if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by the user specified method, the item to be tested includes at least two variable names and the variable values corresponding to the at least two variable names are the same, then assign a value to the variable name in the item to be tested using the data value input by the user based on the human-computer interaction interface.
[0033] Preferably, the test module includes:
[0034] The third assignment unit is used to, if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by a file reference method and a user-specified method, and the item to be tested includes a variable name, then search for a character string that is the same as the variable name in the item to be tested in the reference file corresponding to the item to be tested, use the data value corresponding to the character string in the reference file to assign a value to the variable name in the item to be tested, and then use the data value input by the user based on the human-computer interaction interface to assign a value to the variable name in the item to be tested.
[0035] Preferably, the test module includes:
[0036] The fourth assignment unit, used for each test item, also includes: a repetition mark indicating whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request; if, based on the repetition mark in the item to be tested, it is determined that the variable name in the item to be tested needs to be repeatedly assigned the same value, then the variable name in the item to be tested is repeatedly assigned the same value according to the variable value determination method in the item to be tested.
[0037] Preferably, it also includes:
[0038] The recording module is used to record program test results, compare the program test results with expected results, obtain comparison results, and store and visualize the comparison results.
[0039] Preferably, the determining module further includes:
[0040] The first determining unit is configured to select a variable name with the largest number of variable values from the N test items as the main loop variable name if it is determined based on the identification information that variable names in N test items are designated as the main loop variable name.
[0041] Preferably, the determining module further includes:
[0042] The second determining unit is configured to select a variable name with the largest number of variable values from all test items as the main loop variable name if it is determined based on the variable value determining method that there is no test item that determines the variable value by file reference.
[0043] On the other hand, the present application also provides an electronic device, which includes a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the aforementioned testing method.
[0044] On the other hand, the present application further provides a storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are loaded and executed by a processor, the aforementioned testing method is implemented.
[0045] As can be seen, this application allows users to determine at least one test item based on a human-computer interaction interface; each test item includes: a variable name; the traversal method, variable value, and variable value determination method corresponding to the variable name; and identification information about whether the variable name is designated as the main loop variable name. That is, the user can specify each of the above information based on the human-computer interaction interface, and in particular, can independently specify the main loop variable name. The number of variable values of the main loop variable name is the number of traversals for the current test. If the user does not specify the main loop variable, then the test item can be selected based on the variable value determination method, and the variable name with the largest number of variable values from the selected test item is selected as the main loop variable name. The number of variable values of the main loop variable name is then determined as the number of traversals, completing the automatic determination of the main loop variable name and the number of traversals. Each test item is then treated as a test item, and the variable name in the test item is assigned a value according to the variable value determination method in the test item. According to the traversal number and the traversal method in the test item, the assigned variable name is passed to the program under test for program testing. Among them, the variable corresponding to the main loop variable name is the main loop variable, and the number of input parameters of other variables needs to be consistent with the number of input parameters of the main loop variable. Since testing as many parameters as possible can avoid test omissions, choosing the variable name with the largest number of variable values as the main loop variable name can test more parameter values, thereby ensuring the comprehensiveness and completeness of the test. Since the user has specified the traversal method, variable value and variable value determination method corresponding to each variable name, each variable can be controlled separately during the actual test, thereby achieving targeted and accurate testing of each variable. At the same time, the user can complete the changes of various information in the test item based on the human-computer interaction interface, so there is no need to frequently modify the test code, which improves the flexibility of the test.
[0046] Correspondingly, the testing device, equipment and storage medium provided in this application also have the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0048] Figure 1 A schematic diagram of a physical architecture applicable to this application is provided for this application;
[0049] Figure 2 Flowchart of the first test method provided for this application;
[0050] Figure 3 A schematic diagram of a human-computer interaction interface provided for this application;
[0051] Figure 4 Flowchart of the second test method provided for this application;
[0052] Figure 5 Flowchart of the third test method provided for this application;
[0053] Figure 6 A schematic diagram of the correspondence between variable names and variable values provided in this application;
[0054] Figure 7 A schematic diagram of a test device provided in this application;
[0055] Figure 8 A server structure diagram provided for this application;
[0056] Figure 9 This is a terminal structure diagram provided for this application. DETAILED DESCRIPTION
[0057] Currently, when testing a program, you need to specify in the code which parameters are required and which are not. You also need to specify the number of iterations of the program under test. Therefore, the test code needs to be frequently modified based on the parameters and iterations. When there are many parameters, it is impossible to precisely control each variable.
[0058] In view of the above-mentioned problems currently existing, this application proposes a testing solution that can accurately control the input parameter variables during program testing and improve testing flexibility.
[0059] To facilitate understanding, the physical framework to which this application applies is first introduced.
[0060] like Figure 1 As shown, Figure 1 This is a diagram of the physical architecture applicable to this application. Figure 1In the present invention, a system or program with a testing function can be run on a server, which obtains test tasks (including the program to be tested, related test cases, etc.), test items corresponding to the test tasks, etc. from other terminal devices through the network. After obtaining at least one test item, the server first determines which variable name in which test item is designated as the main loop variable name based on the identification information in each test item. If the main loop variable name is not specified, it determines whether there is a test item that determines the variable value by file reference based on the variable value determination method in each test item; if so, the variable name with the largest number of variable values is selected from the test item as the main loop variable name, and the number of variable values of the main loop variable name is determined as the number of traversals; each test item is used as the item to be tested, and the variable name in the item to be tested is assigned a value according to the variable value determination method in the item to be tested, and the variable name after the assignment is passed to the program to be tested according to the number of traversals and the traversal method in the item to be tested for program testing, thereby realizing the automatic determination of the main loop variable name and the number of traversals, as well as the precise control of each variable.
[0061] As shown in the figure, the server can establish communication connections with multiple devices, and the server obtains test tasks, test items corresponding to the test tasks, etc. from these devices. Figure 1 A variety of terminal devices are shown in FIG. In actual scenarios, more or fewer types of terminal devices may participate in the test process. The specific number and type depend on the actual scenario and are not limited here. In addition, Figure 1 One server is shown in the figure, but in actual scenarios, multiple servers may be involved, and the specific number of servers depends on the actual scenario.
[0062] It should be noted that the testing method provided in this embodiment can be performed offline or online.
[0063] It is understood that the above-mentioned system or program with testing functions can also be run on personal terminal devices or as a cloud service program. The specific operating mode depends on the actual scenario and is not limited here. The terminal device can be a fixed terminal or a mobile terminal. For example, the fixed terminal can be a desktop computer, etc., and the mobile terminal can be a smartphone, iPad, laptop, wearable device, vehicle-mounted device, etc.
[0064] In combination with the above commonalities, please refer to Figure 2 , Figure 2 This is a flow chart of the first test method provided in the embodiment of this application. Figure 2 As shown, the test method may include the following steps:
[0065] S201: Obtain at least one test item determined by a user based on a human-computer interaction interface.
[0066] Each test item includes: a variable name; a traversal method, a variable value, and a variable value determination method corresponding to the variable name; and identification information indicating whether the variable name is designated as the main loop variable name.
[0067] The various test items displayed on the human-computer interaction interface can be referred to Figure 3 ,refer to Figure 3 As shown, the variable value determination method in a test item can be: user-specified method, file reference method, or a combination of user-specified method and file reference method.
[0068] If the variable value determination method is user-specified, the variable name field can contain one or more variable names. When a single variable name is entered, the variable value field can contain multiple values. This means that the single variable name in the test item can be assigned to all of the entered values. When multiple variable names are entered, the variable value field can contain a single value. This means that all of the variable names in the test item are assigned to the same value.
[0069] If the variable value is determined only by file reference, then the variable name input field can be filled with one or more variable names, and the variable value input field is not filled in (that is, the input field is empty). This means: the variable values that can be assigned to these one or more variable names can be queried in the reference file corresponding to the current test item.
[0070] If both user-specified and file-reference methods are used to determine variable values, the variable values provided by the file are used first. In this case, the variable name field can contain a single variable name, and the variable value field can contain multiple variable values. This means that the test item will first be searched for available values for this variable name in the reference file corresponding to the current test item. If all variable values in the reference file have been tested, the test will continue using the variable values entered in the variable value field.
[0071] It should be noted that when the variable value determination method includes the user-specified method, since it is necessary to determine the correspondence between the variable name and the variable value, it is necessary to clarify the following two situations: (1) one variable name corresponds to different variable values; (2) multiple variable names correspond to the same variable value. Of course, if the correspondence between the variable name and the variable value can be specified in the human-computer interaction interface, then when the variable value determination method includes the user-specified method, the correspondence between the variable name and the variable value can be specified with different tags. For example: if the user specifies variable names A and B, then the variable value corresponding to A can be presented as 10 in the variable value input field. A , the variable value corresponding to B can be displayed as 13 in the variable value input column BIn this way, each variable name is used as a label for its corresponding variable value, so that the corresponding relationship between variable name and variable value can be specified. If variable name A corresponds to multiple variable values, you can fill in the variable value input column: A , 12 A , 13 A wait.
[0072] You can set the entry rules for the variable name and value fields. For example, separate multiple variable names with commas, and separate multiple variable values with commas.
[0073] The traversal method for variable names can be sequential or random. For example, sequential or random traversal can be performed on the variable values entered in the variable value input field corresponding to a variable name. Alternatively, sequential or random traversal can be performed on the variable values corresponding to a variable name in a reference file, such as an Excel spreadsheet. If a test item includes multiple variable names, all variable names follow the same traversal method.
[0074] based on Figure 3 The human-computer interaction interface shown can indicate the rules and related prompts that need to be followed when filling in information. Specifically, the filling format and related prompts can be displayed in the variable name and variable value input fields. For example: the filling format and related prompts in the variable name input field: a, b or c without "[%%]". The filling format and related prompts in the variable value input field: multiple variable values are separated by ",", [%random()%] or [%random(string(5))%] can generate random variable values.
[0075] Figure 3 Each item in the test corresponds to a test item, and usually a variable name is set in an item. Figure 3 Click the Delete button to delete the relevant information in the current item.
[0076] S202. If it is determined that the variable names in each test item are not designated as main loop variable names, determine whether there is a test item that determines the variable value by file reference; if so, execute S203; if not, execute S204.
[0077] A variable name corresponds to a variable, which can be a global variable. The variable corresponding to the main loop variable name is the main loop variable, and the number of times other variables are entered must be consistent with the number of times the main loop variable is entered. For example: a test item only includes one variable name. If the variable name is designated as the main loop variable name, and the variable value of the variable name has 10 values, that is, the variable name needs to be entered 10 times, then no matter how many variable values the variable names in other test items have, they also need to be entered 10 times. If the variable values of each variable name in other test items are less than 10, then the same variable value is repeated to reach 10. If the variable values of each variable name in other test items exceed 10, then the first 10 variable values are selected in order.
[0078] The identification information of whether the variable name is designated as the main loop variable name can be represented by 0 or 1. 0 means that it is not designated as the main loop variable name, and 1 means that it is designated as the main loop variable name. Other identification information can also be used, such as: F (for not designated) and T (for designated). Figure 3 As shown in the figure, if the user checks "Main Loop Parameters", the main loop variable is selected in the current test item. If the user does not check "Main Loop Parameters", the main loop variable is not selected in the current test item. Of course, the user can also fill in the main loop variable name they specify after checking "Main Loop Parameters". If the user does not fill in the main loop variable name they specify after checking "Main Loop Parameters" or fills in the name incorrectly, the variable name with the largest number of variable values in the current test item will be selected as the main loop variable name. If the current test item only includes one variable name, it can be directly determined as the main loop variable name.
[0079] It should be noted that whether selecting the main loop variable or the variable value, the reference file is given high priority.
[0080] When both the user-specified method and the file reference method coexist in a test item and the main loop variable needs to be selected, the selection is made directly based on the reference file. When both the user-specified method and the file reference method coexist in a test item and the variable value needs to be selected, the selection is made based on the reference file first, and then based on the user-specified method.
[0081] S203: Select the variable name with the largest number of variable values from the test items that determine variable values by file reference as the main loop variable name, and determine the number of variable values of the main loop variable name as the number of traversals.
[0082] If the variable name in each test item is not specified as the main loop variable name, refer to Figure 3, that is, the user has not checked the "Main Loop Parameters" in any test item, then determine whether there is a test item in all current test items that determines the variable value by file reference, because the reference file has a high priority.
[0083] If any of the current test items use file references to determine variable values, the system determines which variable name has the most values. This variable name will be used as the main loop variable name to cover as many parameter values as possible. If both user-specified and file reference methods coexist in a single test item, the number of values for a given variable name includes both the number of data values in the referenced file and the number of data values specified by the user.
[0084] S204: Select the variable name with the largest number of variable values from all test items as the main loop variable name, and determine the number of variable values of the main loop variable name as the number of traversals.
[0085] If none of the current test items uses file references to determine variable values, meaning the current test does not reference a file, the program will determine which variable name has the most values among all the test items. This variable name will be used as the main loop variable name to cover as many parameter values as possible.
[0086] S205: Take each test item as an item to be tested, assign values to the variable names in the item to be tested according to the variable value determination method in the item to be tested, and pass the assigned variable names into the program to be tested for program testing according to the traversal times and the traversal method in the item to be tested.
[0087] After determining the variables to be tested, their values, traversal methods, and traversal times, you can write corresponding test cases to test the program. The program to be tested can be an interface call program, a page jump program, etc.
[0088] Since the user can independently specify each variable, its value, traversal method, and traversal count in this embodiment, each variable can be controlled separately during the test process, thereby accurately testing each variable in a targeted manner and improving test flexibility. In addition, if the user does not specify the traversal count, the background can automatically determine the traversal count.
[0089] It can be seen that this embodiment allows the user to determine at least one test item based on the human-computer interaction interface; each test item includes: a variable name; a traversal method, a variable value, and a variable value determination method corresponding to the variable name; identification information of whether the variable name is designated as the main loop variable name, and when the user does not specify the main loop variable name, the variable name with the largest number of variable values is selected as the main loop variable name so that more parameter values can be tested, thereby ensuring the comprehensiveness and integrity of the test. Since the user has specified the traversal method, variable value, and variable value determination method corresponding to each variable name, each variable can be controlled accordingly during actual testing, thereby achieving targeted and accurate testing of each variable. At the same time, the user can complete the changes to various information in the test item based on the human-computer interaction interface, so there is no need to frequently modify the test code, which improves the flexibility of the test.
[0090] See Figure 4 , Figure 4 This is a flow chart of the second test method provided in the embodiment of this application. Figure 4 As shown, the test method may include the following steps:
[0091] S401, obtaining at least one test item determined by a user based on a human-computer interaction interface;
[0092] S402, determine whether there is a test item with a main loop variable name specified in each test item; if so, execute S403; if not, execute S404;
[0093] S403, select the variable name with the largest number of variable values from the test items designated with the main loop variable name as the main loop variable name, and execute S407;
[0094] S404, determine whether there is a test item that determines the variable value by file reference; if so, execute S405; if not, execute S406;
[0095] S405 , selecting the variable name with the largest number of variable values from the test items that determine variable values by file reference as the main loop variable name, and executing S407 ;
[0096] S406. Select the variable name with the largest number of variable values from all test items as the main loop variable name, and execute S407.
[0097] S407, determining the number of variable values of the main loop variable name as the number of traversals;
[0098] S408: Take each test item as an item to be tested, assign values to the variable names in the item to be tested according to the variable value determination method in the item to be tested, and pass the assigned variable names into the program to be tested for program testing according to the traversal times and the traversal method in the item to be tested.
[0099] In this embodiment, if there are test items that are assigned main loop variable names (at this time, the number N of test items that are assigned main loop variable names is greater than or equal to 1 and less than the total number of test items), then the variable name with the largest number of variable values is selected from the test items that are assigned main loop variable names as the main loop variable name to cover as many parameter values as possible.
[0100] If no test item specifies a main loop variable name (i.e., no variable name in any test item is specified as a main loop variable name), then determine whether there is a test item that determines variable values by file reference. If there is a test item that determines variable values by file reference among all current test items, then determine which variable name has the largest number of variable values among the test items that determine variable values by file reference. The variable name with the largest number of variable values is determined as the main loop variable name to cover as many parameter values as possible.
[0101] If none of the current test items uses file references to determine variable values, that is, the current test does not reference a file, then determine which variable name has the most variable values among all test items. This variable name is then used as the main loop variable name to cover as many parameter values as possible.
[0102] It can be seen that this embodiment allows the user to specify the main loop variable name in the human-computer interaction interface, and can also automatically determine the main loop variable name and thus determine the number of traversals when the user does not specify the main loop variable name. Since the user has already specified the traversal method, variable value, and variable value determination method corresponding to each variable name, each variable can be controlled accordingly during actual testing, thereby achieving targeted and accurate testing of each variable. At the same time, the user can complete the modification of various information in the test item based on the human-computer interaction interface, so there is no need to frequently modify the test code, which improves the flexibility of the test.
[0103] Based on any of the above embodiments, it should be noted that since the variable value determination method in a test item can be: user-specified method, file reference method, or a coexistence of user-specified method and file reference method; the number of variable names and variable values in a test item is also fixed, so when assigning values to variable names, it is necessary to refer to these situations accordingly.
[0104] In a specific embodiment, the variable name in the item to be tested is assigned a value according to the variable value determination method in the item to be tested, including: if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by file reference, and the item to be tested includes at least one variable name, then in the reference file corresponding to the item to be tested, a character string that is the same as the variable name in the item to be tested is searched, and the data value corresponding to the character string in the reference file is used to assign a value to the variable name in the item to be tested.
[0105] The reference file can be an Excel spreadsheet, so you can directly query the table header to determine the variable names that need to be assigned. The data value list corresponding to a table header is the variable values corresponding to the corresponding variable name. Of course, not all data values in the reference file need to be entered as parameters. The data values corresponding to the variable names specified by the user in the human-computer interaction interface will be extracted as parameters.
[0106] In a specific embodiment, assigning values to variable names in the item to be tested according to a variable value determination method in the item to be tested includes: if, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined in a user-specified manner, and the item to be tested includes one variable name, then assigning a value to the variable name in the item to be tested using a data value input by the user based on a human-computer interaction interface. Alternatively, if, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined in a user-specified manner, the item to be tested includes at least two variable names, and the variable values corresponding to the at least two variable names are the same, then assigning a value to the variable name in the item to be tested using the data value input by the user based on the human-computer interaction interface.
[0107] Among them, if the variable value of the item to be tested is determined by the user in a specified manner, then it is necessary to determine the correspondence between the variable value and the variable name specified by the user based on the human-computer interaction interface. To facilitate the determination of this correspondence, this embodiment defines: when the user specifies a variable name based on the human-computer interaction interface, multiple variable values can be specified to indicate that: this variable name in the test item can be assigned to the multiple variable values filled in. When the user specifies multiple variable names based on the human-computer interaction interface, only one variable value can be specified to indicate that: these multiple variable names in the test item correspond to the same variable value. Of course, if the user specifies the correspondence between the variable value and the variable name based on the human-computer interaction interface, then it is not subject to the limitations of this embodiment.
[0108] For example: the user specifies variable names A and B, and specifies that the variable value corresponding to A is 10 A , the variable value corresponding to B is 13 BThat is, use each variable name as a label for its corresponding variable value, thereby specifying the correspondence between the variable name and the variable value. If a variable name corresponds to multiple variable values, you can mark each variable value. For example: the variable value corresponding to variable name A is 11 A , 12 A , 13 A wait.
[0109] In a specific embodiment, the variable name in the item to be tested is assigned a value according to the variable value determination method in the item to be tested, including: if, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a file reference method and a user-specified method, and the item to be tested includes a variable name, then in the reference file corresponding to the item to be tested, a character string that is identical to the variable name in the item to be tested is searched, and after assigning a value to the variable name in the item to be tested using the data value corresponding to the character string in the reference file, the variable name in the item to be tested is assigned a value using the data value input by the user based on the human-computer interaction interface.
[0110] Among them, if it is determined that the variable value of the item to be tested is determined by file reference and user specification, then it is also necessary to determine the correspondence between the variable value and the variable name specified by the user based on the human-computer interaction interface. To facilitate the determination of this correspondence, this embodiment defines: in this case, the user can only specify one variable name based on the human-computer interaction interface, and can specify multiple variable values, to indicate: this variable name in the test item can be assigned to these multiple variable values specified by the human-computer interaction interface, as well as the corresponding data values in the reference file. Of course, if the user specifies the correspondence between the variable value and the variable name based on the human-computer interaction interface, then it is not subject to the limitations of this embodiment. For details, please refer to the relevant introduction above.
[0111] Based on any of the above embodiments, it should be noted that each test item may also include other information content. For example, each test item may also include a repeat mark indicating whether a variable name needs to be repeatedly assigned the same value when it is called multiple times in a request. This indicates whether the same variable value is assigned these times when a certain variable name needs to be called multiple times in a request.
[0112] In a specific embodiment, the variable names in the item to be tested are assigned values according to the variable value determination method in the item to be tested, including: each test item also includes: a repetition mark indicating whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request; if, based on the repetition mark in the item to be tested, it is determined that the variable name in the item to be tested needs to be repeatedly assigned the same value, then the variable name in the item to be tested is repeatedly assigned the same value according to the variable value determination method in the item to be tested.
[0113] It should be noted that the "repeated assignment of the same value when a variable name is called multiple times in a request" mentioned here is different from "repeated assignment of a variable value when a variable value is repeatedly tested". Figure 3 Check "Do not repeat variable values in the request body" in the "Variable values in the request body" section. If this option is checked, different values will be assigned to a variable name when it is called multiple times in a request. If this option is not checked, the same value will be assigned to a variable name when it is called multiple times in a request.
[0114] Based on any of the above embodiments, it should be noted that after the assigned variable name is passed into the program to be tested for program testing, it also includes: recording the program test results, comparing the program test results with the expected results, obtaining the comparison results, and storing and visualizing the comparison results.
[0115] Expected results can also be represented by variables to facilitate comparison of program test results with expected results. If the comparison results indicate that the program test results are incorrect, the relevant details such as the parameters and functions that caused the error can be displayed.
[0116] The following describes a test solution provided by this application through a specific application scenario example. The test solution includes: a test server and a test client.
[0117] See Figure 5 , the test plan includes the following steps:
[0118] S501: A user determines at least one test item based on a human-computer interaction interface of a test client;
[0119] S502: The test client sends at least one test item to the test server;
[0120] S503: The test server obtains the test items and determines the main loop variable name and traversal times based on the relevant information in all the test items;
[0121] S504: The test server finely controls each variable based on the relevant information in all test items to perform program testing;
[0122] S505: After the test is completed, the test server returns the test results to the test client;
[0123] S506: The test client displays the test results.
[0124] Among them, the specific working process of each step in this embodiment can refer to the corresponding content disclosed in the aforementioned embodiment, and will not be repeated here.
[0125] In this embodiment, each test item includes: variable name; traversal method, variable value and variable value determination method corresponding to the variable name; identification information of whether the variable name is designated as the main loop variable name; and a repeat flag of whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request. Figure 3 .
[0126] This embodiment combines reference files and autonomous variable assignment. There can be multiple autonomously assigned variables and multiple reference files, and they are all presented to users in the form of global variables. Users can add multiple global variables. These global variables can be file-driven or manually entered variable values-driven. Of course, multiple files can be used together to drive data. Among them, if multiple files are used together to drive data, similar data can be divided into the same file in advance according to the business scenario, thereby obtaining multiple files. For example: divide data according to region, occupation, age, etc., so that the data can be classified into multiple files for calling tests.
[0127] Users can add or delete items in the human-computer interaction interface, such as Figure 3 . User clicks Figure 3 Click the Upload button in the toolbar and upload a reference file (such as an Excel table). At the same time, fill in the variable name that matches the file in the variable name input field (the so-called matching means that the file header name and the variable name are the same).
[0128] After the user completes each item and submits it, the test server will read the header in the reference file and compare it with the variable name specified by the user. If they are confirmed to be the same, the file content under the header will be mapped to the variable name specified by the user. Figure 6 , Figure 6 Each row of data in the Variable Name field indicates the variable value corresponding to the variable name.
[0129] To determine the main loop variable, the test server can calculate the length (i.e., the number of characters) of the variable value. If using a variable value from a reference file, the length is calculated based on the number of lines in the file. If using a user-assigned variable, the length is calculated based on the number of delimiters (","), e.g., "," plus one. Therefore, if the user does not specify a main loop variable, the test server can independently select and determine the main loop variable. However, if the user does specify a main loop variable, the user-specified length is used.
[0130] When the execution engine in the test server confirms the main loop variable, other non-variables follow the traversal times of the main loop variable and are tested according to the specific information in the corresponding item (such as the traversal method of random traversal or sequential traversal, whether there are repeated assignments in a request body, etc.), so as to achieve the purpose of fine control of each variable.
[0131] This embodiment can determine the main loop variable based on the number of rows of data in the file and / or the number of variable values assigned by the user without the user specifying the main loop variable. It has the ability to actively identify the number of variable values and can flexibly drive the data of the use case according to the item set by the user. After determining the above-mentioned main loop variable, the number of traversals of the main loop variable, and each item, the execution engine can be informed through a unified data format (such as json format). The refined control of the traversal during the test is completed by the execution engine. Since each variable is given a traversal method (such as sequential traversal or random traversal), the entire test process can be defined by the user so that each variable follows the traversal method set in the corresponding item.
[0132] It can be seen that this embodiment implements complex data-driven operations in a low-code platform, and file-driven and autonomous variables are flexibly called in the test without losing flexibility. During the execution of a test case of a certain program to be tested, the traversal method of the main loop variable and the traversal method of the non-main loop variable can be different and can coexist. With variables as the control granularity, the driving method, traversal method and number of traversals of the test case are managed in a refined manner. The flexibility of data-driven scenarios is increased, and data-driven problems in complex scenarios can be solved through user configuration.
[0133] See Figure 7 , Figure 7 A schematic diagram of a test device provided in an embodiment of the present application includes:
[0134] The acquisition module 701 is used to acquire at least one test item determined by the user based on the human-computer interaction interface; each test item includes: a variable name; a traversal method corresponding to the variable name, a variable value, and a variable value determination method; and identification information of whether the variable name is designated as a main loop variable name;
[0135] Determination module 702 is configured to, if it is determined based on the identification information that none of the variable names in each test item is designated as a main loop variable name, determine based on the variable value determination method whether there is a test item that determines variable values by file reference; if so, select the variable name with the largest number of variable values from the test item as the main loop variable name, and determine the number of variable values in the main loop variable name as the traversal count;
[0136] The test module 703 is used to treat each test item as an item to be tested, assign values to the variable names in the item to be tested according to the variable value determination method in the item to be tested, and pass the assigned variable names into the program to be tested for program testing according to the traversal times and the traversal method in the item to be tested.
[0137] In a specific embodiment, the test module includes:
[0138] The first assignment unit is used to, if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by file reference, and the item to be tested includes at least one variable name, then search for a character string that is the same as the variable name in the item to be tested in the reference file corresponding to the item to be tested, and use the data value corresponding to the character string in the reference file to assign a value to the variable name in the item to be tested.
[0139] In a specific embodiment, the test module includes:
[0140] The second assignment unit is configured to, if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by a user-specified method, and the item to be tested includes a variable name, assign a value to the variable name in the item to be tested using a data value input by the user based on the human-computer interaction interface. Alternatively, if it is determined based on the variable value determination method in the item to be tested that the variable value of the item to be tested is determined by a user-specified method, the item to be tested includes at least two variable names, and the variable values corresponding to the at least two variable names are the same, assign a value to the variable name in the item to be tested using the data value input by the user based on the human-computer interaction interface.
[0141] In a specific embodiment, the test module includes:
[0142] The third assignment unit is used to, if based on the variable value determination method in the item to be tested, determine that the variable value of the item to be tested is determined by a file reference method and a user-specified method, and the item to be tested includes a variable name, then search for a character string that is the same as the variable name in the item to be tested in the reference file corresponding to the item to be tested, use the data value corresponding to the character string in the reference file to assign a value to the variable name in the item to be tested, and then use the data value input by the user based on the human-computer interaction interface to assign a value to the variable name in the item to be tested.
[0143] In a specific embodiment, the test module includes:
[0144] The fourth assignment unit, used for each test item, also includes: a repetition mark indicating whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request. If, based on the repetition mark in the item to be tested, it is determined that the variable name in the item to be tested needs to be repeatedly assigned the same value, the variable name in the item to be tested is repeatedly assigned the same value according to the variable value determination method in the item to be tested.
[0145] In a specific embodiment, it also includes:
[0146] The recording module is used to record program test results, compare the program test results with expected results, obtain comparison results, and store and visualize the comparison results.
[0147] In a specific embodiment, the determining module further includes:
[0148] The first determining unit is configured to select a variable name with the largest number of variable values from the N test items as the main loop variable name if it is determined based on the identification information that variable names in the N test items are designated as the main loop variable name.
[0149] In a specific embodiment, the determining module further includes:
[0150] The second determining unit is configured to select a variable name with the largest number of variable values from all test items as a main loop variable name if it is determined based on the variable value determining method that there is no test item that determines the variable value by file reference.
[0151] Among them, for more specific working processes of each module and unit in this embodiment, reference can be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0152] It can be seen that this embodiment provides a testing device that allows the user to specify the main loop variable name in the human-computer interaction interface, and can automatically determine the main loop variable name when the user does not specify the main loop variable name, thereby determining the number of traversals. Since the user has specified the traversal method, variable value, and variable value determination method corresponding to each variable name, each variable can be controlled separately during actual testing, thereby achieving targeted and accurate testing of each variable. At the same time, the user can complete the changes of various information in the test item based on the human-computer interaction interface, so there is no need to frequently modify the test code, which improves the flexibility of the test.
[0153] Furthermore, the embodiment of the present application also provides an electronic device. The electronic device can be Figure 8 The server 50 shown may also be Figure 9 Terminal 60 is shown. Figure 8 and Figure 9 Each of the diagrams is a structural diagram of an electronic device according to an exemplary embodiment, and the contents in the diagrams cannot be considered as any limitation on the scope of use of the present application.
[0154] Figure 8 This is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server 50 may specifically include: at least one processor 51, at least one memory 52, a power supply 53, a communication interface 54, an input / output interface 55, and a communication bus 56. The memory 52 is used to store a computer program, which is loaded and executed by the processor 51 to implement the relevant steps of the test method disclosed in any of the aforementioned embodiments.
[0155] In this embodiment, the power supply 53 is used to provide operating voltage for each hardware device on the server 50; the communication interface 54 can create a data transmission channel between the server 50 and external devices. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 55 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0156] In addition, the memory 52, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon include an operating system 521, a computer program 522 and data 523, etc. The storage method can be temporary storage or permanent storage.
[0157] The operating system 521 is used to manage and control the hardware devices and computer programs 522 on the server 50, enabling the processor 51 to operate and process data 523 in the memory 52. The operating system 521 can be Windows Server, NetWare, Unix, Linux, or other operating systems. In addition to computer programs capable of performing the test methods disclosed in any of the aforementioned embodiments, the computer programs 522 can also include computer programs capable of performing other specific tasks. Data 523 can include data such as test tasks as well as application developer information.
[0158] Figure 9 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. The terminal 60 may specifically include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.
[0159] Generally, the terminal 60 in this embodiment includes a processor 61 and a memory 62 .
[0160] Among them, the processor 61 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 61 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 61 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 61 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 61 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0161] The memory 62 may include one or more computer-readable storage media, which may be non-transitory. The memory 62 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 62 is at least used to store the following computer program 621, wherein, after the computer program is loaded and executed by the processor 61, it can implement the relevant steps in the test method performed by the terminal side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 62 may also include an operating system 622 and data 623, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 622 may include Windows, Unix, Linux, etc. The data 623 may include but is not limited to test tasks and test items.
[0162] In some embodiments, the terminal 60 may further include a display screen 63 , an input / output interface 64 , a communication interface 65 , a sensor 66 , a power supply 67 , and a communication bus 68 .
[0163] Those skilled in the art will understand that Figure 9 The structure shown in the figure does not constitute a limitation on the terminal 60, and the terminal 60 may include more or fewer components than shown in the figure.
[0164] Furthermore, embodiments of the present application also disclose a storage medium storing computer-executable instructions. When the computer-executable instructions are loaded and executed by a processor, the test method disclosed in any of the aforementioned embodiments is implemented. The specific steps of this method can be found in the corresponding contents disclosed in the aforementioned embodiments and will not be further described here.
[0165] It should be pointed out that the above is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
[0166] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0167] This document uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A testing method, characterized in that: include: Obtaining at least one test item determined by a user based on a human-computer interaction interface; Each test item includes: a variable name; a traversal method, a variable value, and a variable value determination method corresponding to the variable name; identification information of whether the variable name is designated as the main loop variable name; If it is determined based on the identification information that none of the variable names in each test item is designated as the main loop variable name, then based on the variable value determination method, it is determined whether there is a test item that determines the variable value by file reference; if so, the variable name with the largest number of variable values is selected from the test item as the main loop variable name, and the number of variable values of the main loop variable name is determined as the number of traversals; if not, the variable name with the largest number of variable values is selected from all test items as the main loop variable name; Each test item is used as an item to be tested, a variable name in the item to be tested is assigned a value according to the variable value determination method in the item to be tested, and the variable name after the assignment is passed into the program to be tested for program testing according to the traversal number and the traversal method in the item to be tested; The step of assigning values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes: Each test item also includes: a repetition mark indicating whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request; if, based on the repetition mark in the item to be tested, it is determined that the variable name in the item to be tested needs to be repeatedly assigned the same value, the variable name in the item to be tested is repeatedly assigned the same value according to the variable value determination method in the item to be tested.
2. The method according to claim 1, characterized in that The assigning of values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes: If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by file reference, and the item to be tested includes at least one variable name, then in the reference file corresponding to the item to be tested, a character string that is identical to the variable name in the item to be tested is searched, and the data value corresponding to the character string in the reference file is used to assign a value to the variable name in the item to be tested.
3. The method according to claim 1, characterized in that The assigning of values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes: If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a user-specified method, and the item to be tested includes a variable name, assigning a value to the variable name in the item to be tested using the data value input by the user based on the human-computer interaction interface; or If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a user-specified method, and the item to be tested includes at least two variable names and the variable values corresponding to the at least two variable names are the same, then the data value input by the user based on the human-computer interaction interface is used to assign a value to the variable name in the item to be tested.
4. The method according to claim 1, wherein The assigning of values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes: If, based on the variable value determination method in the item to be tested, it is determined that the variable value of the item to be tested is determined by a file reference method and a user-specified method, and the item to be tested includes a variable name, then in the reference file corresponding to the item to be tested, a character string identical to the variable name in the item to be tested is searched, and after assigning a value to the variable name in the item to be tested using the data value corresponding to the character string in the reference file, the variable name in the item to be tested is assigned a value using the data value input by the user based on the human-computer interaction interface.
5. The method according to any one of claims 1 to 4, characterized in that After the variable name after the assignment is passed into the program to be tested for program testing, the following is also included: Record program test results, compare the program test results with expected results, obtain comparison results, and store and visualize the comparison results.
6. The method according to any one of claims 1 to 4, characterized in that Also includes: If it is determined based on the identification information that variable names in N test items are designated as the main loop variable name, a variable name with the largest number of variable values is selected from the N test items as the main loop variable name.
7. A testing device, characterized in that: include: An acquisition module, configured to acquire at least one test item determined by a user based on a human-computer interaction interface; Each test item includes: a variable name; a traversal method, a variable value, and a variable value determination method corresponding to the variable name; identification information of whether the variable name is designated as the main loop variable name; a determination module configured to, if it is determined based on the identification information that none of the variable names in each test item is designated as the main loop variable name, determine, based on the variable value determination method, whether there is a test item that determines the variable value by file reference; if so, select the variable name with the largest number of variable values from the test item as the main loop variable name, and determine the number of variable values of the main loop variable name as the number of traversals; if not, select the variable name with the largest number of variable values from all test items as the main loop variable name; A test module is configured to treat each test item as an item to be tested, assign values to variable names in the item to be tested according to a variable value determination method in the item to be tested, and, according to the traversal number and the traversal method in the item to be tested, pass the assigned variable names into the program to be tested for program testing; The step of assigning values to the variable names in the item to be tested according to the variable value determination method in the item to be tested includes: Each test item also includes: a repetition mark indicating whether the variable name needs to be repeatedly assigned the same value when it is called multiple times in a request; if, based on the repetition mark in the item to be tested, it is determined that the variable name in the item to be tested needs to be repeatedly assigned the same value, the variable name in the item to be tested is repeatedly assigned the same value according to the variable value determination method in the item to be tested.
8. An electronic device, characterized in that: The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Program debugging method and device capable of repeatedly acquiring test data
CN110597705A
System testing method and related device
CN110750446A