A method, device and terminal device for generating parameters of a test case
Through variable classification and assignment strategy generation methods, the problem of poor compatibility of test cases in multiple software versions and multiple test environments is solved, adaptive parameter settings are realized, and testing efficiency and compatibility are improved.
Patent Information
- Application Number
- CN202010127419.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-02-28
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2040-02-28
AI Technical Summary
In the existing technology, under multiple software versions and multiple test environments, the compatibility of test cases is poor, resulting in low testing efficiency. Variable parameter values cannot be adaptively set, and manual initialization is required, resulting in low testing efficiency and poor compatibility.
Through variable classification, it is divided into the first type and the second type of variables. The first type of variables directly uses the solidified parameter values, and the second type of variables generates parameter values according to the preset assignment strategy, and adaptively sets the variable parameter values to ensure that the test cases are Normal operation under different software versions and test environments.
It improves the compatibility of test cases with different software versions and different test environments, reduces the user's manual initialization workload, and improves testing efficiency.
Smart Images

Figure CN111338958B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of software testing technology, and in particular, relates to a method for generating parameters of a test case and a terminal device. Background Art
[0002] With the rapid iteration and update of software products, parallel testing of multiple software versions and multiple test environments has become very common, which means uncertainty in test parameters.
[0003] In order to ensure the accuracy of the test, the relevant technology is to directly initialize the parameter values of the variables involved in the test case before each test case is executed. Although this can ensure the normal progress of the test process, once the parameter value is initialized before the test case is executed, the parameter value of the variable cannot be changed during the test case execution. When the same test case needs to be executed under different conditions, it is necessary to manually change the parameter value of each variable, which makes the test case extremely incompatible with different software versions and different test environments, and the test efficiency is greatly reduced. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a test case parameter generation method and a terminal device, which can solve the problem of poor compatibility of test cases with different software versions and different test environments.
[0005] A first aspect of an embodiment of the present application provides a method for generating parameters of a test case, comprising:
[0006] During the test case execution process, if a variable to be assigned is detected, the variable type of the variable to be assigned is identified;
[0007] If the variable to be assigned belongs to the first category of variables, obtaining a first parameter value corresponding to the variable to be assigned, and assigning the first parameter value to the variable to be assigned;
[0008] If the variable to be assigned belongs to the second category of variables, an assignment strategy corresponding to the variable to be assigned is obtained, a second parameter value corresponding to the variable to be assigned is obtained according to the assignment strategy, and the second parameter value is assigned to the variable to be assigned.
[0009] In a first possible implementation manner of the first aspect, obtaining the assignment strategy corresponding to the variable to be assigned includes:
[0010] Obtain a first mapping table corresponding to the test case, and obtain the assignment strategy corresponding to the to-be-assigned variable according to the first mapping table, wherein the first mapping table records the to-be-assigned variables belonging to the second category of variables, and a mapping relationship between the to-be-assigned variables and the assignment strategy.
[0011] On the basis of the first possible implementation manner, in a second possible implementation manner of the first aspect, obtaining a first mapping table corresponding to the test case includes:
[0012] Identify the environment type of the test environment in which the test case is located, and obtain version information of the test object of the test case;
[0013] The first mapping table is screened out from a mapping table library according to the environment type and version information, wherein the mapping table library includes a plurality of mapping tables.
[0014] On the basis of the first possible implementation manner and the second possible implementation manner, in a third possible implementation manner of the first aspect, obtaining a second parameter value corresponding to the variable to be assigned according to the assignment strategy includes:
[0015] If the assignment strategy corresponding to the variable to be assigned is the first strategy, identifying the environment type of the test environment where the test case is located;
[0016] Obtain a third parameter value corresponding to the environment type, and use the third parameter value as the second parameter value.
[0017] On the basis of the first possible implementation manner and the second possible implementation manner, in a fourth possible implementation manner of the first aspect, obtaining a second parameter value corresponding to the variable to be assigned according to the assignment strategy includes:
[0018] If the assignment strategy corresponding to the variable to be assigned is the second strategy, locate the associated variable corresponding to the variable to be assigned, and obtain the fourth parameter value of the associated variable;
[0019] The fourth parameter value is processed to obtain a fifth parameter value, and the fifth parameter value is used as the second parameter value.
[0020] On the basis of the first possible implementation manner and the second possible implementation manner, in a fourth possible implementation manner of the fifth aspect, obtaining the second parameter value corresponding to the variable to be assigned according to the assignment strategy includes:
[0021] If the assignment strategy corresponding to the variable to be assigned is the third strategy, a sixth parameter value corresponding to the variable to be assigned is obtained, and the sixth parameter value is used as the second parameter value.
[0022] On the basis of the fourth possible implementation manner, in a sixth possible implementation manner of the fifth aspect, the processing the fourth parameter value to obtain the fifth parameter value includes:
[0023] Calculating the sum of the fourth parameter value and the first difference value, and using the obtained sum as the fifth parameter value;
[0024] On the basis of the fourth possible implementation manner, in a seventh possible implementation manner of the fifth aspect, the processing the fourth parameter value to obtain the fifth parameter value includes:
[0025] A first parameter value range corresponding to the fourth parameter value is obtained, a parameter value is selected within the first parameter value range, and the selected parameter value is used as the fifth parameter value.
[0026] A second aspect of an embodiment of the present application provides a test case parameter generation device, including:
[0027] A variable type identification module is used to identify the variable type of the variable to be assigned if a variable to be assigned is detected during the execution of the test case;
[0028] A first assignment module, configured to obtain a first parameter value corresponding to the variable to be assigned if the variable to be assigned belongs to the first category of variables, and assign the first parameter value to the variable to be assigned;
[0029] The second assignment module is used to obtain the assignment strategy corresponding to the variable to be assigned if the variable to be assigned belongs to the second category of variables, obtain the second parameter value corresponding to the variable to be assigned according to the assignment strategy, and assign the second parameter value to the variable to be assigned.
[0030] A third aspect of an embodiment of the present application provides a terminal device, which includes a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the computer program, it implements the steps of the parameter generation method of the test case as described in any one of the first aspects above.
[0031] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, comprising: storing a computer program, characterized in that when the computer program is executed by a processor, the steps of the parameter generation method for a test case as described in any one of the first aspects above are implemented.
[0032] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the parameter generation method of the test case described in any one of the first aspects above.
[0033] Compared with the prior art, the embodiments of the present application have the following beneficial effects: variables are classified according to their attributes, variables that can be pre-fixed are classified into first-category variables, and corresponding fixed parameter values are pre-set; variables whose parameter values may change in different tests are classified into second-category variables, and corresponding parameter values, i.e., assignment strategies, are preset for the characteristics of each second-category variable. During the execution of test cases, when variables that need to be assigned are encountered, the first-category variables can be directly assigned according to the pre-stored fixed parameter values, while the second-category variables are processed according to the assignment strategies to obtain corresponding parameter values for variable assignment. Therefore, during the execution of each test case, the embodiments of the present application can adaptively select or set the parameter values of the variables to ensure the normal operation of the test under the current software version and test environment, without the need for the user to manually initialize each time, and have stronger compatibility and higher testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0035] Figure 1 It is a schematic diagram of the implementation flow of the parameter generation method of the test case provided in Example 1 of the present application;
[0036] Figure 2 It is a schematic diagram of the implementation flow of the parameter generation method of the test case provided in the second embodiment of the present application;
[0037] Figure 3 It is a schematic diagram of the implementation flow of the parameter generation method of the test case provided in Example 3 of the present application;
[0038] Figure 4 It is a schematic diagram of the implementation flow of the parameter generation method of the test case provided in the fourth embodiment of the present application;
[0039] Figure 5 It is a schematic diagram of the implementation flow of the parameter generation method of the test case provided in Example 5 of the present application;
[0040] Figure 6 It is a structural diagram of a parameter generation device for a test case provided in Example 6 of the present application;
[0041] Figure 7 This is a schematic diagram of the terminal device provided in Example 7 of the present application. DETAILED DESCRIPTION
[0042] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0043] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0044] To facilitate the understanding of the present application, a brief description of the embodiments of the present application is first given here. Since a large number of variables may be involved in the execution of the test case, and whether the parameter values of these variables are set accurately and usably is the basis for ensuring the normal execution of the test case, in order to ensure the smooth execution of each test case and the accuracy of the test, the relevant technology is to manually assign values to all variables that may be involved in the execution of the test case before the test case is executed, so as to initialize all variable parameter values. Although this can ensure the normal progress of the software testing process, under the conditions of multiple software versions and multiple test environments, if the same test case needs to be used for software testing, it is necessary to manually modify the parameter values of each variable before each test application is executed. The workload is large and the test efficiency is low, and it is impossible to achieve compatibility testing of different software versions and different test environments, and the compatibility is extremely poor.
[0045] Considering that not all variables need to be changed according to different software versions and different test environments, for example, in some test cases, the same value can be used for the "number of login attempts" in software tests under different software versions and different test environments. Correspondingly, there will be some variables whose parameter values need to be changed according to the actual software version, test environment conditions and actual test case execution conditions. For example, when conducting software throughput tests under different test environments, it is necessary to determine the corresponding maximum number of requests based on the actual test environment conditions to ensure the accuracy and reliability of the throughput test. For example, after the software version is updated, the maximum resource occupancy rate of the updated software is tested. At this time, it is necessary to determine the maximum number of concurrent tasks based on the actual software version to ensure that the software's resource occupancy reaches the maximum value. At this time, the parameter values of the variables may change to a certain extent during different software testing processes.
[0046] Based on the above principles, in order to improve the compatibility of test cases with different software versions and different test environments and improve test efficiency, the embodiment of the present application first classifies variables according to the attributes of the variables, and divides the variables that do not need to be changed according to different software versions and different test environments, and can be solidified in advance into first-class variables, and sets the corresponding solidified parameter values in advance according to actual needs, and divides the variables whose parameter values may change in different software tests into second-class variables, and presets the corresponding assignment strategies according to the characteristics of the parameter changes of each second-class variable. During the execution of the test case, when encountering a variable that needs to be assigned, first identify the type of the variable, and directly assign the first-class variable according to the pre-stored parameter value, and for the second-class variable, the variable is processed according to the assignment strategy to obtain the corresponding parameter value. Therefore, during the execution of different test cases, the embodiment of the present application will adaptively generate the parameter value of the variable to ensure normal testing under the current software version and test environment, without the need for the user to manually initialize each time. When facing tests under different software versions and different test environments, the compatibility is stronger and the test efficiency is higher.
[0047] Some terms that may be involved in the embodiments of this application are explained as follows:
[0048] The assignment strategy refers to the assignment scheme for each variable to be assigned in the second category of variables, so that the assigned variables can meet the requirements of the current software version, the current test environment, and the actual test case execution, and ensure the normal execution of the test case. Among them, the specific assignment strategy content can be set by the technician according to the relationship between each variable in the actual second category of variables and the software version, the test environment, and the actual test case execution requirements. It is not limited here, and can also refer to the third to fifth embodiments of this application and other related embodiments.
[0049] A mapping table is used to record the mapping relationship between each variable to be assigned and the assignment strategy in the second category of variables. Depending on the actual assignment strategy, in some embodiments, the mapping table can also record some other variable names related to the variables to be assigned, such as the parameters of the third to fifth embodiments of the present application and other related embodiments.
[0050] At the same time, the execution subject of the parameter generation method of the test case in the embodiment of the present application is a terminal device that can run the test case and execute the assignment strategy in the embodiment of the present application to assign variables, wherein the specific terminal device type is not limited here and can be selected or set by technical personnel according to actual needs, including but not limited to servers and computers.
[0051] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish descriptions, and cannot be understood as indicating or suggesting relative importance. It should also be understood that although the terms "first", "second", etc. are used to describe various elements in some embodiments of the present application in the text, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element. For example, the first table can be named as the second table, and similarly, the second table can be named as the first table without departing from the scope of the various described embodiments. The first table and the second table are both tables, but they are not the same table.
[0052] The parameter generation method for the test case of the embodiment of the present application is described in detail as follows:
[0053] Figure 1 The following is a flowchart of a method for generating parameters for a test case provided in Example 1 of the present application, which is described in detail as follows:
[0054] S101, during the execution of the test case, if a variable to be assigned is detected, the variable type of the variable to be assigned is identified.
[0055] In the embodiments of the present application, the variables to be assigned refer to variables that need to be assigned. According to the different actual test case designs, there will be certain differences in the specific number of variables to be assigned and the corresponding variable names, etc., which need to be determined by the actual test case situation.
[0056] From the above description, it can be seen that the embodiment of the present application will classify variables in advance according to the relationship between the variables and the actual test software version, the test environment, and the test case execution. Therefore, after detecting the variables that need to be assigned, the embodiment of the present application will first identify the corresponding variable type according to the variable name of the variable to be assigned.
[0057] S102: If the variable to be assigned belongs to the first category of variables, obtain a first parameter value corresponding to the variable to be assigned, and assign the first parameter value to the variable to be assigned.
[0058] When the variable to be assigned belongs to the first category of variables, it means that the variable to be assigned can directly perform a solidified parameter value assignment. Therefore, the embodiment of the present application will directly read the first parameter value corresponding to the variable to be assigned and perform the assignment operation.
[0059] Among them, it should be noted that the type of the same variable may be different for different test cases. For example, in some test cases, the "number of login attempts" is only to test whether the software can log in normally. At this time, the size of the "number of login attempts" itself is not important. Therefore, in these test cases, the "number of login attempts" can be a first-class variable, and in other test cases, the "number of login attempts" can also be used to test whether the account security verification mechanism can be triggered normally after multiple login failures. At this time, with the different software versions and test environments, the numerical requirements of the "number of login attempts" may also be different. For example, in some test environments with higher risks, the "number of login attempts" needs to be set relatively small, while in test environments with lower risks, it can be set relatively large. Therefore, in these test cases, the "number of login attempts" belongs to the second-class variable. Therefore, the specific division of variable types needs to be set in advance by technical personnel according to the actual situation of the test cases.
[0060] S103, if the variable to be assigned belongs to the second category of variables, obtain an assignment strategy corresponding to the variable to be assigned, obtain a second parameter value corresponding to the variable to be assigned according to the assignment strategy, and assign the second parameter value to the variable to be assigned.
[0061] When the variable to be assigned belongs to the second category of variables, it means that the parameter value of the variable to be assigned needs to be determined based on the actual test software version, test environment and test case execution. Therefore, the embodiment of the present application will query the corresponding assignment strategy according to the variable name of the variable to be assigned, and operate according to the specific assignment strategy to obtain the second parameter value corresponding to the variable to be assigned, thereby realizing the final variable assignment.
[0062] In order to quickly locate the assignment strategy corresponding to the variable to be assigned, as an optional embodiment of the present application, the query operation on the assignment strategy includes:
[0063] A first mapping table corresponding to the test case is obtained, and an assignment strategy corresponding to the variables to be assigned is obtained according to the first mapping table. The first mapping table records the variables to be assigned belonging to the second category of variables, and a mapping relationship between the variables to be assigned and the assignment strategy.
[0064] In an embodiment of the present application, each variable to be assigned and the corresponding assignment strategy are stored in the same mapping table in advance, and the corresponding mapping relationship is set, so that when S103 performs an assignment strategy query, it only needs to query the corresponding assignment strategy from the first mapping table according to the name of the variable to be assigned.
[0065] As a specific implementation method for obtaining the first mapping table in the above-mentioned embodiment of the present application, considering that under different software versions and test environments, the parameter value requirements corresponding to the variables to be assigned may be different, that is, the corresponding assignment strategies may be different. For example, when performing software throughput tests under different test environments in the above-mentioned examples, it is necessary to determine the corresponding maximum number of requests according to the actual test environment to ensure the accuracy and reliability of the throughput test. Therefore, in order to meet the requirements of the actual software version and test environment for assigning variables, so as to ensure the normal execution of the test case under the current software version and test environment, such as Figure 2 As shown, the operation of selecting the first mapping table in the second embodiment of the present application includes:
[0066] S201, identifying the environment type of the test environment where the test case is located, and obtaining version information of the test object of the test case.
[0067] In an embodiment of the present application, various test environments and software versions that the test case may face are determined in advance, and combinations of environment types and version information are performed to achieve analysis of various possible scenarios. Corresponding assignment strategies are then set for the actual parameter value requirements of the assigned variables under each combination of environment type and version information, and the variables to be assigned and the corresponding assignment strategies under each combination are stored as a mapping table, respectively, to obtain multiple mapping tables that can adapt to the combination requirements of different environment types and version information. At the same time, in order to facilitate the management of mapping tables, all mapping tables are placed in the same mapping table library for easy query.
[0068] Based on the above operations, the embodiment of the present application will first identify the environment type of the test environment and the version information of the test object software. During the actual test case execution, the environment type information is passed in as a global parameter. Therefore, only the global parameter needs to be obtained here. Different global parameters correspond to different environment types. At the same time, the version information can be directly obtained from the software information of the test object software, which will not be described in detail here.
[0069] S202: Filter out a first mapping table from a mapping table library according to the environment type and version information, where the mapping table library includes a plurality of mapping tables.
[0070] After the actual environment type and version information are obtained, the mapping table library is matched based on the actual environment type and version information to filter out the required first mapping table.
[0071] In order to improve the compatibility of test cases with different software versions and different test environments and improve test efficiency, the embodiment of the present application first classifies variables according to the attributes of the variables, that is, whether the variable parameter values need to change with the test software version, the test environment and the actual test case execution situation, and classifies the variables that do not need to change according to different software versions and different test environments, and can be fixed in advance as first-class variables, and sets the corresponding fixed parameter values in advance according to actual needs, and classifies the variables whose parameter values may change in different software tests into second-class variables, and presets the corresponding assignment strategies according to the characteristics of the parameter changes of each second-class variable. During the execution of the test case, when encountering a variable that needs to be assigned, first identify the type of the variable, and directly assign the first-class variable according to the pre-stored parameter value, and for the second-class variable, the variable is processed according to the assignment strategy to obtain the corresponding parameter value. Therefore, during the execution of different test cases, the embodiment of the present application will adaptively generate the parameter value of the variable to ensure normal testing under the current software version and test environment, without the need for the user to manually initialize each time, and when facing tests under different software versions and different test environments, the compatibility is stronger and the test efficiency is higher.
[0072] As a specific implementation method of obtaining the second parameter value corresponding to the variable to be assigned according to the assignment strategy in the above-mentioned embodiment 1 of the present application, Figure 3 As shown, the specific operation of obtaining the second parameter value in the third embodiment of the present application includes:
[0073] S301: If the assignment strategy corresponding to the variable to be assigned is the first strategy, identify the environment type of the test environment where the test case is located.
[0074] Taking into account that in actual applications, some variables to be assigned may only be related to the test environment and have nothing to do with the version information of the test object software, in order to ensure the effective assignment of parameter values of such variables to be assigned, the embodiment of the present application will set corresponding parameter values according to the actual requirements of such variables to be assigned under different environment types, thereby achieving accurate assignment of such variables to be assigned.
[0075] For example, assuming that the purpose of software testing is to test whether the software can normally trigger the account security verification mechanism when multiple login failures occur, and that the triggering mechanisms for account security verification for different software versions in actual design are the same, then the "number of login attempts" is a variable to be assigned that is only related to the environment type. For example, when the test environment is a public development network or other environment type with higher risks, a smaller "number of login attempts" is required to punish the account security verification mechanism. When the test environment is a private encrypted network or other environment type with lower risks, a larger "number of login attempts" is required to punish the account security verification mechanism. Therefore, different "number of login attempts" parameter values can be set in advance for environment types with different risk levels, and when the assignment strategy corresponding to the variable to be assigned is the first strategy, the environment type of the current test environment can be directly identified for subsequent assignment.
[0076] S302: Obtain a third parameter value corresponding to the environment type, and use the third parameter value as the second parameter value.
[0077] After obtaining the third parameter value corresponding to the environment type, the embodiment of the present application will directly use the third parameter value as the second parameter value to ensure accurate assignment of the variable to be assigned.
[0078] As another specific implementation method of obtaining the second parameter value corresponding to the variable to be assigned according to the assignment strategy in the first embodiment of the present application, Figure 4 As shown, the specific operation of obtaining the second parameter value in the fourth embodiment of the present application includes:
[0079] S401: If the assignment strategy corresponding to the variable to be assigned is the fourth strategy, identify the version information of the test case test object.
[0080] Corresponding to the above-mentioned third embodiment of the present application, considering that in actual applications, some variables to be assigned may only be related to the version of the test object software, but have nothing to do with the test environment. Therefore, in order to ensure the effective assignment of parameter values of such variables to be assigned, the embodiment of the present application will set corresponding parameter values according to the actual requirements of such variables to be assigned under different software versions, thereby achieving accurate assignment of such variables to be assigned.
[0081] For example, when conducting a comprehensive functional test on the software, the specific "total number of functions" that need to be tested is determined by the version of the current test software and has nothing to do with the environment type. Therefore, the corresponding "total number of functions" parameter value can be set for each version information in advance, and when the assignment strategy corresponding to the variable to be assigned is the fourth strategy, the version information of the current test object software is directly identified for subsequent assignment.
[0082] S402: Obtain a seventh parameter value corresponding to the version information, and use the seventh parameter value as a second parameter value.
[0083] After determining the version information, the corresponding seventh parameter value can be found based on the version information. The embodiment of the present application will directly use the seventh parameter value as the second parameter value to ensure accurate assignment of the variable to be assigned.
[0084] As another specific implementation method of obtaining the second parameter value corresponding to the variable to be assigned according to the assignment strategy in the above-mentioned first embodiment of the present application, it is considered that during the execution of the test case, some variables to be assigned may be affected by other variables in addition to the test environment and software version. For example, assuming that the software client needs to be load tested by the number of logged-in users, the "number of logged-in users" is a variable affected by the software version. At the same time, in order to ensure that there are certain differences between simulated users when generating simulated users, it is also necessary to generate attributes such as user name and age of each simulated user. At this time, in order to ensure the age difference between simulated users, the larger the "number of logged-in users", the larger the corresponding age selection interval application setting. Therefore, at this time, the "age value range" is a variable to be assigned that is affected by the "number of logged-in users". In order to ensure the accuracy of the assignment of these variables to be assigned that are affected by other variables in the execution of other actual test cases, on the basis of the above-mentioned embodiments of the present application, such as Figure 5 As shown, the specific operation of obtaining the second parameter value in the fifth embodiment of the present application includes:
[0085] S501: If the assignment strategy corresponding to the variable to be assigned is the second strategy, locate the associated variable corresponding to the variable to be assigned, and obtain a fourth parameter value of the associated variable.
[0086] In an embodiment of the present application, the variables to be assigned that may be affected by the above-mentioned other variables will be analyzed in advance, and the associated variables corresponding to these variables to be assigned (that is, the variables that can affect the variables to be assigned) will be determined and stored. When the assignment strategy is the second strategy, the associated variables actually corresponding to the variables to be assigned will be found first, and then the associated variables will be located from the variables generated during the execution of the test case, and the actual fourth parameter value of the associated variable will be obtained.
[0087] As a specific embodiment of the present application, in order to locate the associated variable and obtain the fourth parameter value of the associated variable, in the embodiment of the present application, each step of the test case has a unique identifier, and the information to be recorded in each step is set as the data attribute of this unique identifier. For example, if the unique identifier of the database query step is 1, then the returned result is used as the data attribute with the unique identifier of 1. Among them, the data attribute format of each step can be specified in advance, for example, the step of the http request can have the following attributes: url (request address), header (request header), body (request body), method (request method), data (reply returned by the request). Database operations can have the following attributes: execsql (execution statement), data (execution result).
[0088] On this basis, in order to locate the associated variable and obtain the fourth parameter value, the step where the associated variable is located can be located by querying the data attribute content corresponding to the unique identifier, and then the data attribute content of the step can be parsed to obtain the corresponding fourth parameter value.
[0089] S502: Process the fourth parameter value to obtain a fifth parameter value, and use the fifth parameter value as the second parameter value.
[0090] After obtaining the fourth parameter value of the associated variable, the fourth parameter value is processed according to the preset parameter value processing method of the variable to be assigned, so as to obtain the corresponding fifth parameter value, thereby realizing the subsequent accurate assignment operation. The specific processing method of the fourth parameter value is not limited here, and can be selected or set by the technician according to the actual relationship between the variable to be assigned and the associated variable.
[0091] As a specific implementation method for processing the fourth parameter value in the fifth embodiment of the present application, it is found in actual applications that there may be a direct numerical association or an indirect numerical association between the variable to be assigned and the associated variable. For example, in the above example, when generating simulated users, if it is necessary to number each simulated user in sequence, each new simulated user is generated, and its number is obtained by numerical addition and subtraction operations based on the number of the previous simulated user. At this time, the "user numbers" between different simulated users are directly associated. For example, in the above example, the "age value range" is affected by the "number of logged-in users", and the "age" of the simulated user must be selected from the "age value range". Therefore, at this time, the "age" of each simulated user and the "number of logged-in users" are indirectly numerically associated. Therefore, in order to effectively respond to these two numerical association situations, the two operations of processing the fourth parameter value in the embodiment of the present application include:
[0092] The sum of the fourth parameter value and the first difference value is calculated, and the obtained sum is used as the fifth parameter value.
[0093] In the embodiment of the present application, the corresponding first difference value is set in advance for the variables to be assigned and the associated variables with direct numerical association according to the actual association situation, and the fourth parameter value difference value is summed on the basis of the first difference value to obtain the final fifth parameter value. Among them, the first difference value can be either a positive number or a negative number, and the specific size of the first difference value is not limited here, and can be set by the technician according to the actual situation of the variables to be assigned.
[0094] A first parameter value range corresponding to the fourth parameter value is obtained, a parameter value is selected within the first parameter value range, and the selected parameter value is used as the fifth parameter value.
[0095] Similarly, the embodiment of the present application will pre-set the corresponding parameter value range for the variables to be assigned and the associated variables with indirect numerical association according to the actual association situation, and then select the corresponding first parameter value range according to the actual fourth parameter value, and perform the fifth parameter value within the first parameter value range. Among them, the specific corresponding relationship between the fourth parameter value and the first parameter value range, and the value-taking method within the first parameter value range, are not limited here, and can be set by the technician according to actual needs, for example, it can be set to random selection. When the embodiment of the present application is applied to the above-mentioned example, the "number of logged-in users" embodiment of the present application will pre-set different "age value ranges" for different "number of logged-in users", and then select the "age value range" according to the actual "number of logged-in users", and randomly select an age value from it as the "age" of the simulated user.
[0096] As an embodiment of the present application, considering that in actual situations, even if it is the same associated variable, its influence on the variable to be assigned may be different when the parameter value is different, so in order to meet the parameter value generation requirements of the variable to be assigned under different parameter value sizes of the same associated variable, so as to ensure the accurate assignment of the variable to be assigned, in the embodiment of the present application, two operations for processing the fourth parameter value include:
[0097] If the fourth parameter value is greater than the first parameter threshold, the sum of the fourth parameter value and the first difference value is calculated, and the obtained sum is used as the fifth parameter value.
[0098] If the fourth parameter value is less than or equal to the first parameter threshold, a parameter value is selected within the first parameter value range, and the selected parameter value is used as the fifth parameter value.
[0099] Among them, the setting method of the first difference value, the first parameter value range, and the method of selecting the parameter value, etc., can refer to the description of the previous embodiment and will not be repeated here. At the same time, the embodiment of the present application does not limit the specific size of the first parameter threshold, which can be set by technical personnel based on the association relationship between the actual associated variable and the variable to be assigned.
[0100] As another specific implementation method of obtaining the second parameter value corresponding to the variable to be assigned according to the assignment strategy in the first embodiment of the present application, considering that in actual applications, for some variables to be assigned, it may be known that they are not first-class variables, but the user cannot temporarily determine the relationship between them and the test environment and test version, and cannot determine whether they have corresponding associated variables. In order to ensure the normal execution of the test case in this case, the operation of obtaining the second parameter in the embodiment of the present application includes:
[0101] If the assignment strategy corresponding to the variable to be assigned is the third strategy, the sixth parameter value corresponding to the variable to be assigned is obtained, and the sixth parameter value is used as the second parameter value.
[0102] In an embodiment of the present application, for variables to be assigned whose relationship with the test environment and test version cannot be determined temporarily by the user and which do not belong to the first category of variables, the assignment strategy will be set to the third strategy, that is, a fixed first parameter value will be directly set for these variables to be assigned, and when the third strategy is executed, the sixth parameter value corresponding to the variable to be assigned will be directly assigned as the second parameter value.
[0103] In the embodiment of the present application, by setting a specific parameter value mapping, on the one hand, the normal progress of the test case can be guaranteed, and on the other hand, the user can perform operations such as debugging on some variables to be assigned. At the same time, considering that the user may mistakenly set the variable to be assigned that was originally a first-class variable to a second-class variable, thereby causing the variable data to be stored incorrectly and unable to be tested normally, through the operation of the embodiment of the present application, error compatibility for this situation can be achieved to ensure the normal operation of the test.
[0104] Corresponding to the method of the above embodiment, Figure 6 A structural block diagram of a parameter generation device for a test case provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown. Figure 6 The exemplary test case parameter generation device may be an execution subject of the test case parameter generation method provided in the aforementioned first embodiment.
[0105] Reference Figure 6 , the parameter generating device of the test case includes:
[0106] The variable type identification module 61 is used to identify the variable type of the variable to be assigned if a variable to be assigned is detected during the execution of the test case.
[0107] The first assignment module 62 is configured to obtain a first parameter value corresponding to the variable to be assigned if the variable to be assigned belongs to the first category of variables, and assign the first parameter value to the variable to be assigned.
[0108] The second assignment module 63 is used to obtain the assignment strategy corresponding to the variable to be assigned if the variable to be assigned belongs to the second category of variables, obtain the second parameter value corresponding to the variable to be assigned according to the assignment strategy, and assign the second parameter value to the variable to be assigned.
[0109] Furthermore, the second assignment module 63 includes:
[0110] A table acquisition module is used to obtain a first mapping table corresponding to the test case, and obtain the assignment strategy corresponding to the variable to be assigned according to the first mapping table. The first mapping table records the variables to be assigned belonging to the second category of variables, and the mapping relationship between the variables to be assigned and the assignment strategy.
[0111] Furthermore, the table acquisition module includes:
[0112] The parameter acquisition module is used to identify the environment type of the test environment in which the test case is located, and to obtain the version information of the test object of the test case.
[0113] The table screening module is used to screen the first mapping table from a mapping table library according to the environment type and version information, wherein the mapping table library includes a plurality of mapping tables.
[0114] Furthermore, the second assignment module 63 further includes:
[0115] The environment type identification module is used to identify the environment type of the test environment where the test case is located if the assignment strategy corresponding to the variable to be assigned is the first strategy.
[0116] The first parameter acquisition module is used to acquire a third parameter value corresponding to the environment type, and use the third parameter value as the second parameter value.
[0117] Furthermore, the second assignment module 63 further includes:
[0118] The second parameter acquisition module is used to locate the associated variable corresponding to the variable to be assigned and acquire a fourth parameter value of the associated variable if the assignment strategy corresponding to the variable to be assigned is the second strategy.
[0119] The third parameter acquisition module is used to process the fourth parameter value to obtain a fifth parameter value, and use the fifth parameter value as the second parameter value.
[0120] Furthermore, the third parameter acquisition module includes:
[0121] The parameter calculation module is used to calculate the sum of the fourth parameter value and the first difference value, and use the obtained sum as the fifth parameter value.
[0122] Furthermore, the third parameter acquisition module further includes:
[0123] The parameter selection module is used to obtain a first parameter value range corresponding to the fourth parameter value, select a parameter value within the first parameter value range, and use the selected parameter value as the fifth parameter value.
[0124] Furthermore, the second assignment module 63 further includes:
[0125] The fourth parameter acquisition module is used to obtain a sixth parameter value corresponding to the variable to be assigned if the assignment strategy corresponding to the variable to be assigned is the third strategy, and use the sixth parameter value as the second parameter value.
[0126] Furthermore, the second assignment module 63 further includes:
[0127] A version acquisition module is used to identify the version information of the test case test object if the assignment strategy corresponding to the variable to be assigned is the fourth strategy.
[0128] The fifth parameter acquisition module is used to acquire a seventh parameter value corresponding to the version information, and use the seventh parameter value as the second parameter value.
[0129] The process of each module realizing its own function in the parameter generation device of the test case provided in the embodiment of the present application can be specifically referred to in the above Figure 1 The description of the first embodiment is not repeated here.
[0130] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0131] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0132] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0133] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0134] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0135] The parameter generation method of the test case provided in the embodiment of the present application can be applied to terminal devices such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc. The embodiment of the present application does not impose any restrictions on the specific type of the terminal device.
[0136] Figure 7 Schematic diagram of the structure of a terminal device provided by an embodiment of the present application. Figure 7 As shown, the terminal device 7 of this embodiment includes: at least one processor 70 ( Figure 7 Only one is shown in the figure), a memory 71, in which a computer program 72 that can be run on the processor 70 is stored. When the processor 70 executes the computer program 72, the steps of the parameter generation method embodiment of each test case described above are implemented, such as Figure 1Alternatively, when the processor 70 executes the computer program 72, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Figure 6 The functions of modules 61 to 64 are shown.
[0137] The terminal device 7 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will appreciate that Figure 7 It is only an example of the terminal device 7 and does not constitute a limitation on the terminal device 7. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include an input sending device, a network access device, a bus, etc.
[0138] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0139] In some embodiments, the memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory 71 may also be used to temporarily store data that has been sent or is to be sent.
[0140] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0141] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0142] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0143] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0144] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0145] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0146] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for generating parameters of a test case, characterized in that: include: During the test case execution process, if a variable to be assigned is detected, the variable type of the variable to be assigned is identified; If the variable to be assigned belongs to the first category of variables, obtaining a first parameter value corresponding to the variable to be assigned, and assigning the first parameter value to the variable to be assigned; If the variable to be assigned belongs to the second category of variables, obtaining an assignment strategy corresponding to the variable to be assigned, obtaining a second parameter value corresponding to the variable to be assigned according to the assignment strategy, and assigning the second parameter value to the variable to be assigned; The obtaining, according to the assignment strategy, a second parameter value corresponding to the variable to be assigned includes: If the assignment strategy corresponding to the variable to be assigned is the second strategy, locate the associated variable corresponding to the variable to be assigned, and obtain the fourth parameter value of the associated variable; Processing the fourth parameter value to obtain a fifth parameter value, and using the fifth parameter value as the second parameter value; The processing of the fourth parameter value to obtain a fifth parameter value includes: For the variable to be assigned and the associated variable that have a direct numerical association, calculate the sum of the fourth parameter value and the first difference value, and use the obtained sum as the fifth parameter value; The processing of the fourth parameter value to obtain a fifth parameter value includes: For the variables to be assigned and the associated variables that have indirect numerical association, the first parameter value range corresponding to the fourth parameter value is obtained, a parameter value is selected within the first parameter value range, and the selected parameter value is used as the fifth parameter value.
2. The method for generating parameters of a test case according to claim 1, characterized in that: The obtaining the assignment strategy corresponding to the variable to be assigned includes: Obtain a first mapping table corresponding to the test case, and obtain the assignment strategy corresponding to the to-be-assigned variable according to the first mapping table, wherein the first mapping table records the to-be-assigned variables belonging to the second category of variables, and a mapping relationship between the to-be-assigned variables and the assignment strategy.
3. The method for generating test case parameters according to claim 2, wherein: The obtaining of a first mapping table corresponding to the test case includes: Identify the environment type of the test environment in which the test case is located, and obtain version information of the test object of the test case; The first mapping table is screened out from a mapping table library according to the environment type and version information, wherein the mapping table library includes a plurality of mapping tables.
4. The method for generating parameters of a test case according to any one of claims 1 to 3, characterized in that: The obtaining, according to the assignment strategy, a second parameter value corresponding to the variable to be assigned includes: If the assignment strategy corresponding to the variable to be assigned is the first strategy, identifying the environment type of the test environment where the test case is located; Obtain a third parameter value corresponding to the environment type, and use the third parameter value as the second parameter value.
5. A test case parameter generation device, characterized in that: include: A variable type identification module is used to identify the variable type of the variable to be assigned if a variable to be assigned is detected during the execution of the test case; A first assignment module, configured to obtain a first parameter value corresponding to the variable to be assigned if the variable to be assigned belongs to the first category of variables, and assign the first parameter value to the variable to be assigned; A second assignment module is used for obtaining an assignment strategy corresponding to the variable to be assigned if the variable to be assigned belongs to the second category of variables, obtaining a second parameter value corresponding to the variable to be assigned according to the assignment strategy, and assigning the second parameter value to the variable to be assigned; The second assignment module comprises: A second parameter acquisition module, configured to locate an associated variable corresponding to the variable to be assigned and acquire a fourth parameter value of the associated variable if the assignment strategy corresponding to the variable to be assigned is the second strategy; A third parameter acquisition module, used for processing the fourth parameter value to obtain a fifth parameter value, and using the fifth parameter value as the second parameter value; The third parameter acquisition module includes: A parameter calculation module, for calculating the sum of the fourth parameter value and the first difference value for the to-be-assigned variable and the associated variable having a direct numerical association, and using the obtained sum value as the fifth parameter value; The parameter selection module is used to obtain the first parameter value range corresponding to the fourth parameter value for the to-be-assigned variable and the associated variable with indirect numerical association, select a parameter value within the first parameter value range, and use the selected parameter value as the fifth parameter value.
6. A terminal device, characterized in that: The terminal device includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the steps of the method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
