Case execution method and device, computer equipment and storage medium
By extracting and processing the execution parameters of the automated test platform, calculating the target parameters and executing the test steps, the complex problems of using cases execution parameters extraction and calculation operations in the prior art are solved, and more efficient parameter calculation capabilities and wider applications are achieved. Scene.
Patent Information
- Application Number
- CN202411044139.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2025-02-25
AI Technical Summary
When the existing automated test platform is executed in the use case, the parameter extraction and calculation operations are complex, resulting in complex and high cost of platform operations.
By obtaining target test cases, extracting and processing execution parameters, calculating target parameters using processing rules, and then executing test steps to improve parameter calculation capabilities.
The use case execution process is simplified, the parameter calculation capability of the automated test platform is improved, labor costs are reduced, and application scenarios are expanded.
Smart Images

Figure CN119512922A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a use case execution method, apparatus, computer equipment and storage medium. Background Art
[0002] In the field of software automated testing, parameterization capability is an important indicator of whether an automated testing platform is excellent. Rich and varied parameterization capabilities can cover more business scenarios of the software and complete more test case orchestrations, thereby saving more manpower regression testing costs. In the current automated testing platform, context parameter extraction and parameter calculation for some use case executions require adding parameter extraction and parameter calculation components at each step, and some dependencies need to be repeatedly introduced, making the use case execution operation of the automated testing platform complex. Summary of the invention
[0003] Based on this, it is necessary to provide a use case execution method, apparatus, computer device and storage medium that can improve the parameter calculation capability of the platform in response to the above technical problems.
[0004] In order to solve the above technical problems, in a first aspect, a use case execution method is provided, the method comprising:
[0005] Obtain a target test case, where the target test case at least includes a first target test step and a second target test step;
[0006] Obtaining execution parameters of the first target test step;
[0007] Processing the execution parameter based on the first processing rule to obtain a first target input parameter, and executing the first target test step based on the first target input parameter;
[0008] Get the return value of the first target test step, process the return value according to the second processing rule, obtain the second target input parameter, and execute the second target test step based on the second target input parameter.
[0009] In one embodiment, obtaining the execution parameter of the first target test step includes:
[0010] Obtaining environment parameters corresponding to the target test case execution environment, and storing the environment parameters corresponding to the target test case execution environment in a parameter system;
[0011] Obtain the test case parameters required for executing the target test case, and store the test case parameters required for executing the target test case in the parameter system;
[0012] Obtain the context parameters required for the target test case execution, and store the context parameters required for the target test case execution in the parameter system.
[0013] In one embodiment, the execution parameter is processed based on the first processing rule to obtain a first target input parameter, and the first target test step is performed based on the first target input parameter, including:
[0014] Determine whether the execution parameters include the first expression;
[0015] If included, obtaining the first environment parameter, the first use case parameter, and the first context parameter corresponding to the first expression, and calculating the first calculation result corresponding to the first expression based on the first environment parameter, the first use case parameter, and the first context parameter;
[0016] The first calculation result is returned to the parameter system as the first target input parameter of the first target test step and stored; the first target test step is executed based on the first target input parameter.
[0017] In one embodiment, obtaining a return value of a first target test step, processing the return value according to a second processing rule to obtain a second target input parameter, and executing the second target test step based on the second target input parameter includes:
[0018] Determine whether the return value includes the second expression;
[0019] If included, obtaining the second environment parameter, the second use case parameter, and the second context parameter corresponding to the second expression, and calculating the second calculation result corresponding to the second expression based on the second environment parameter, the second use case parameter, and the second context parameter;
[0020] The second calculation result is stored in the second target input parameter return parameter system as the second target test step;
[0021] In response to receiving the second target test step execution instruction, obtaining the second target input parameter from the parameter system to execute the second target test step.
[0022] In one embodiment, determining whether the return value includes the second expression includes:
[0023] Obtain the expected input parameter of the target test case execution step, and obtain the second expression corresponding to the expected input parameter;
[0024] Determine whether the return value includes the second expression corresponding to the expected input parameter;
[0025] If included, calculate the second calculation result corresponding to the second expression;
[0026] If not included, the parameters in the return value are extracted and stored in the parameter system.
[0027] In one embodiment, the target test case further includes a third target test step, the third target test step is an assertion test step, and the method includes:
[0028] Get the expected value of the assertion of the third target test step;
[0029] determining whether the assertion expected value of the third target test step includes the third expression;
[0030] If included, obtaining a third environment parameter, a third use case parameter, and a third context parameter corresponding to the third expression, and calculating a third calculation result corresponding to the third expression based on the third environment parameter, the third use case parameter, and the third context parameter;
[0031] Using the third calculation result as the target assertion expected value, and comparing the target assertion expected value with the actual execution result of the third target test step to obtain a comparison result;
[0032] Get the assertion test step status based on the comparison result.
[0033] In one embodiment, the method further comprises:
[0034] Identify the first expression, the second expression, and the third expression;
[0035] The input box is located. The input box extracts the expression corresponding to the identifier by identifying the identifier, and passes the expression corresponding to the identifier to the calculation engine for calculation.
[0036] In order to solve the above technical problem, in a second aspect, a use case execution device is provided, the device comprising:
[0037] An acquisition module is used to acquire a target test case, the target test case includes at least a first target test step and a second target test step; and acquire an execution parameter of the first target test step;
[0038] A processing module is used to process the execution parameters based on the first processing rule to obtain the first target input parameter, and execute the first target test step based on the first target input parameter; obtain the return value of the first target test step, process the return value according to the second processing rule to obtain the second target input parameter, and execute the second target test step based on the second target input parameter.
[0039] In order to solve the above technical problem, in the third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: the processor implements the steps of the method described in the first aspect when executing the computer program.
[0040] In order to solve the above technical problem, in a fourth aspect, the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0041] Different from the prior art, the use case execution method in the present application obtains a target test case, and the target test case includes at least a first target test step and a second target test step; obtains the execution parameters of the first target test step; processes the execution parameters based on a first processing rule to obtain a first target input parameter, and executes the first target test step based on the first target input parameter; obtains the return value of the first target test step, processes the return value according to a second processing rule to obtain a second target input parameter, and executes the second target test step based on the second target input parameter. In this way, the return value of the target test step whose execution order is before the second target test step can be processed to obtain the corresponding target input parameter, and the obtained target input parameter can be used as the input parameter of the subsequent step to participate in the execution of the subsequent test step, which can improve the parameter calculation capability of the platform and has a wider range of application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A flowchart of a method for executing a use case in the prior art;
[0043] Figure 2 A flowchart of a use case execution method in an embodiment;
[0044] Figure 3 is an architectural diagram of a test platform in one embodiment;
[0045] Figure 4 A diagram of a computing platform architecture in one embodiment;
[0046] Figure 5 A schematic diagram of a flow chart of a step for obtaining a status of an assertion test step in an embodiment;
[0047] Figure 6 A schematic diagram of a flow chart of expression recognition calculation in another embodiment;
[0048] Figure 7 A flowchart of a use case execution method in another embodiment;
[0049] Figure 8 A structural block diagram of a use case execution device in an embodiment;
[0050] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0052] See also Figure 1 In the prior art, a test case is divided into multiple test steps for execution, as shown in the figure, including step 1, step 2, step 3 and step 4. Figure 1 It can be seen that each test step execution requires variable extraction and reference to variables from the context variables of the KV structure. Executing test cases in this way will make the test case execution operation very complicated.
[0053] In view of the above technical problems, in one embodiment, Figure 2 As shown, a use case execution method is provided, the method comprising the following steps:
[0054] Step 201, obtaining a target test case, where the target test case at least includes a first target test step and a second target test step.
[0055] A test case is a set of test inputs, execution conditions, and expected results compiled for a specific purpose, in order to test a program path or verify whether a specific requirement is met. Test cases and test case-related data can be obtained, and the test case-related data can include test case titles, test case steps, test case parameters, test case expected results, etc. The target test case of the present application includes multiple target test steps in a sequence, and the multiple target test steps in a sequence include at least a first target test step and a second target test step.
[0056] It can be understood that the first target test step and the second target test step of the present application can be test case steps in a continuous order or in a non-continuous order.
[0057] Step 202, obtaining execution parameters of the first target test step.
[0058] Before obtaining the execution parameters of the first target test step, it also includes: obtaining the environmental parameters corresponding to the target test case execution environment, and storing the environmental parameters corresponding to the target test case execution environment in the parameter system; obtaining the use case parameters required for the target test case execution, and storing the use case parameters required for the target test case execution in the parameter system; obtaining the context parameters required for the target test case execution, and storing the context parameters required for the target use case execution in the parameter system.
[0059] The target test case may be applied in a variety of test environments, so the present application is set to obtain the environmental parameters of the target test case execution environment before the target test case is executed, so that when the target test case execution environment changes, the environmental parameters corresponding to the environment required for the target test case execution can be quickly obtained from the parameter system.
[0060] In actual applications, there are some parameter values whose values remain unchanged during the execution of the target test case. These parameters do not need to be processed accordingly according to different target test case steps. This application calls such parameters use case parameters. Before the target test case is executed, the use case parameters can be extracted and stored in the parameter system. When any subsequent target test step execution requires the use case parameters, they only need to be obtained from the parameter system.
[0061] Before obtaining the execution parameters of the first target test step, it is also necessary to obtain the context parameters required for the execution of the target test case. The context parameters here are obtained by extracting parameters from the information of the target test case. Exemplarily, they can be extracted based on the attribute information corresponding to each target test step in the target test case. Specifically, they can include conditional step judgment parameters, assertion expected value parameters, result extraction rules and other parameters, and the extracted context parameters are stored in the parameter system.
[0062] For examples, see Figure 3 , the figure shows the test platform architecture diagram of the present application, the test platform is used to execute the target test case, the test platform architecture mainly includes three parts: the use case step, the parameter system and the calculation engine, wherein the use case step (target test step) includes the attribute divisions such as step information, condition judgment, step parameter, result extraction rule, assertion expectation value, etc., the parameter system includes context parameter thread variable, use case parameter thread variable, environment parameter thread variable, corresponding storage environment parameter, use case parameter, context parameter. According to the result extraction rule (second processing rule), the return value of the target test step is processed, and the calculation engine, i.e., the jex l engine, receives the return value for processing and returns the processed calculation result to the use case step side (target test step side).
[0063] For example, it is assumed that in one embodiment, the context parameters are stored in the parameter system in the form of a parameter list. The specific parameter list is shown in Table 1 below:
[0064]
[0065]
[0066] Table 1
[0067] For example, Table 1 above is the context parameters extracted from the execution of any target test step. Assuming that the current step is the payment step, the actual payment amount of the passenger needs to be obtained as the input parameter of the current step, and the context parameters need to be calculated. For example, if the actual payment amount needs to be calculated, the actual payment amount calculation formula can be obtained, and the actual payment amount = A*B*C–D. Substitute the above parameters into the actual payment calculation formula for calculation to obtain the calculation result of the actual payment amount.
[0068] It is understandable that the parameter system of the present application may include multiple data blocks or multiple thread variables, and multiple threads or multiple data blocks are used to store different types of parameters, namely, environment parameters, use case parameters, and context parameters in the present application. The present application does not limit the specific form of the parameter system.
[0069] Step 203: Process the execution parameters based on the first processing rule to obtain the first target input parameter, and execute the first target test step based on the first target input parameter.
[0070] When the first target test step starts to execute, the system will issue the execution parameters of the first target test step. After receiving the execution parameters of the first target test step issued by the system, it will be determined whether the execution parameters issued by the system are the first target input parameters required for the execution of the first target test step. If the execution parameters issued by the system are the first target input parameters required for the execution of the first target test step, the execution parameters issued by the system are directly applied to execute the first target test step. If the execution parameters issued by the system are not the first target input parameters required for the execution of the first target test step, it is necessary to process the execution parameters issued by the system to obtain the first target input parameters, and then execute the first target test step based on the first target input parameters.
[0071] Specifically, processing the execution parameters based on the first processing rule includes: determining whether the execution parameters include the first expression; if included, obtaining the first environment parameter, the first use case parameter, and the first context parameter corresponding to the first expression, and calculating the first calculation result corresponding to the first expression based on the first environment parameter, the first use case parameter, and the first context parameter; and storing the first calculation result in the return parameter system as the first target input parameter of the first target test step.
[0072] The first processing rule here is to determine whether the execution parameters include the first expression, and to perform corresponding processing on the execution parameters according to the determination result. The first expression refers to the calculation formula required to obtain the first target input parameter. If it is determined that the execution parameters include the first expression, then according to the parameters in the first expression, the specific values of the parameters in the first expression are obtained from the parameter system, and the specific values of the parameters are substituted into the first expression for calculation to obtain the first calculation result. The first calculation result here is the first target input parameter, and the first target test step is executed based on the first target input parameter. If it is determined that the execution parameters do not include the first expression, the execution parameters are extracted, and the extracted parameters are stored in the parameter system.
[0073] Step 204, obtain the return value of the first target test step, process the return value according to the second processing rule, obtain the second target input parameter, and execute the second target test step based on the second target input parameter.
[0074] Before the second target test step starts to execute, it is necessary to obtain the second target input parameter required for the execution of the second target test step. It can be determined whether the return value of the first target test step is the second target input parameter required for the execution of the first target test step. If the return value is the second target input parameter, the return value is directly used as the second target input parameter to execute the second target test step. If the return value is not the second target input parameter required for the execution of the second target test step, it is necessary to process the return value according to the second processing rule to obtain the second target input parameter, and then execute the second target test step based on the second target input parameter.
[0075] Specifically, processing the return value according to the second processing rule includes: determining whether the return value includes a second expression; if included, obtaining the second environment parameters, second use case parameters, and second context parameters corresponding to the second expression, and calculating the second calculation result corresponding to the second expression based on the second environment parameters, second use case parameters, and second context parameters; and storing the second calculation result in the system as the second target input parameter return parameter of the second target test step.
[0076] In response to receiving the second target test step execution instruction, obtaining the second target input parameter from the parameter system to execute the second target test step.
[0077] The second processing rule here is to determine whether the return value includes the second expression, and to perform corresponding processing on the return value according to the determination result. The second expression refers to the calculation formula required to obtain the second target input parameter. If it is determined that the return value includes the second expression, then according to the parameters in the calculation formula of the second expression, the specific values of the parameters in the second expression are obtained from the parameter system, and the specific values of the parameters are substituted into the second expression for calculation to obtain the second calculation result. The second calculation result here is the second target input parameter, and the second target test step is executed based on the second target input parameter. If it is determined that the return value does not include the second expression, the return value is parameter extracted, and the extracted parameters are stored in the parameter system.
[0078] Among them, judging whether the return value includes the second expression includes: obtaining the expected input parameters of the target test case execution step, and obtaining the second expression corresponding to the expected input parameters; judging whether the return value includes the second expression corresponding to the expected input parameters; if included, calculating the second calculation result corresponding to the second expression; if not included, extracting the parameters in the return value, and storing the parameters in the return value in the parameter system.
[0079] That is, the second expression in the present application is a calculation formula for the expected input parameters corresponding to the unexecuted use case test step. If the return value of the execution step includes the second expression corresponding to the expected input parameters, the specific values of the parameters in the calculation formula are obtained from the parameter system, and the specific values of the parameters are substituted into the second expression for calculation to obtain the second calculation result. If the return value does not include the expression corresponding to the expected input parameters, the parameters of the return value are directly extracted, and the extracted parameters are directly stored in the parameter system, so that the required parameter values can be directly obtained from the parameter system later.
[0080] Different from the method in the prior art of directly storing the data extraction results in the return value after the execution of the use case test step in the system, in the present application, data can also be extracted from the return value after the step is executed, and then the data extracted according to the return value can be continued to be calculated, and the calculation results can be stored in the context parameter thread variable, so that the subsequent test execution steps can directly obtain their corresponding target parameters from the context parameter thread variable. In this way, the parameters in the parameter system are calculated and passed into other test steps as input parameters, which has a wide range of application scenarios.
[0081] It should be noted that the parameters applied to each target test step in the present application are stored in each thread variable in the parameter system according to the compatibility of the parameters with multiple thread variables, namely the context parameter thread variable, use case parameter thread variable, and environment parameter thread variable shown in the present application, so that the parameters required for the execution of the target test case can be directly obtained from the parameter system later.
[0082] Among them, thread variables (thread l oca l) is a class in Java that provides thread local variables. These variables are different from ordinary variables because each thread has its own, independent storage. A thread can change the variables in its own thread without affecting the variables in other threads. The accuracy of parameter acquisition can be improved by storing parameters in each thread variable in the parameter system according to the compatibility of the parameters with multiple thread variables.
[0083] See also Figure 4 The computing architecture in this application mainly includes a step component layer, a jex l engine computing layer and a data layer. The step component layer corresponds to the use case step in the test platform architecture. In the step component layer, each target use case test step is divided into step parameters, result extraction parameters, conditional judgment, step assertion and other attributes according to the attribute information of each target use case test step. The jex l engine computing layer corresponds to the computing engine in the test platform architecture. The jex l Express i on (expression engine) and jex l Scr i pt (expression engine) of the jex l engine are used to perform expression operations and script operations respectively. Not only can basic arithmetic operations be performed, but also Java classes can be referenced for complex operations, which greatly improves the parameterization capability of the platform. The parameter system corresponds to the parameter system in the test platform architecture, and a data layer for storing context parameters, use case parameters and environment parameters is set in the parameter system.
[0084] In one embodiment, the target test case also includes a third target test step, which is an assertion test step, and the method includes: obtaining an assertion expected value of the third target test step; determining whether the assertion expected value of the third target test step includes a third expression; if included, obtaining third environment parameters, third use case parameters, and third context parameters corresponding to the third expression, and calculating a third calculation result corresponding to the third expression based on the third environment parameters, third use case parameters, and third context parameters; using the third calculation result as the target assertion expected value, and comparing the target assertion expected value with the actual execution result of the third target test step to obtain a comparison result; and obtaining the assertion test step status according to the comparison result.
[0085] The third processing rule here is to determine whether the assertion expected value includes the third expression, and to perform corresponding processing on the assertion expected value according to the determination result. The third expression refers to the calculation formula required to calculate the target assertion expected value of the assertion test step. If it is determined that the assertion expected value includes the third expression, then according to the parameters in the third expression, the specific values of the parameters in the third expression are obtained from the parameter system, and the specific values of the parameters are substituted into the third expression for calculation to obtain the third calculation result. The third calculation result here is the target assertion expected value of the assertion test step, and the actual execution result of the third target test step is obtained. The target assertion expected value is compared with the actual execution result of the third target test step to obtain the comparison result; the assertion test step status is obtained according to the comparison result. The status of the assertion test step includes assertion success and assertion failure.
[0086] If the assertion expected value of the third target test step does not include the third expression, it is considered that the assertion expected value does not need to be calculated to obtain the target assertion expected value. The target assertion expected value can be directly extracted from the assertion expected value, and the target assertion expected value is compared with the actual execution result of the third target test step to obtain a comparison result; the assertion test step status is obtained according to the comparison result.
[0087] In the present application, it is provided that the target assertion expected value of the assertion test step can be calculated by obtaining the corresponding parameters from the parameter system, which simplifies the operation flow of the assertion test step in terms of parameter acquisition and makes the execution of the example more convenient.
[0088] In a specific embodiment, see Figure 5 , assuming that the assertion logic of the assertion test step is that the company's commission for each order shall not exceed 18%, and the assertion rule entered into the test platform is {{(A*B*CD) / A*B*C}}<0.18. The test platform extracts the expression (A*B*CD) / A*B*C} by identifying the {{}} identifier. The jex l calculation engine references thread variables (context parameter thread variables, use case parameter thread variables, and environment parameter thread variables) to calculate the expression and obtain the calculation result of 0.097. The assertion component obtains the final assertion rule of 0.097<0.18 based on the result calculated by the jex l calculation engine, and the assertion result is true.
[0089] In one embodiment, the present application further provides for identifying the first expression, the second expression and the third expression; positioning the input box, the input box extracts the expression corresponding to the identifier by identifying the identifier, and passes the expression corresponding to the identifier to the calculation engine for calculation.
[0090] In one embodiment, if Figure 6 As shown, the process of expression recognition calculation is as follows:
[0091] First, the step component management (step component layer) saves the component text information to the database, and then extracts the expression or script with representation in the regular expression, transfers the recognized expression to the jex l calculation engine for calculation, and after obtaining the calculation result, inputs the calculation result to the step component layer. The step component layer replaces the content marked with {{}} with the calculation result, and then executes the target test step.
[0092] Regular expression, also known as regular expression (Regular Expression, often abbreviated as regex, regexp or RE in code), is a text pattern, including common characters (for example, letters from a to z) and special characters (called "metacharacters"), and is a concept in computer science. Regular expression uses a single string to describe and match a series of strings that match a certain syntactic rule, and is usually used to retrieve and replace text that meets a certain pattern (rule).
[0093] In this application, all input values of conditional judgments, step parameters, result extraction rules, assertion expected values, and step information in the step component layer support parameter calculation, that is, using characters such as {{}} to extract expressions or scripts and pass them into the Jex L engine for calculation.
[0094] First, the platform can parse the expressions and script text information marked by characters such as {{}} in each component of each target test step and pass them into the jex l engine. The jex l engine references the thread variables of context parameters, use case parameters, and environment parameters and brings them into the expression or script for calculation. The jex l engine returns the calculated results to each component of the step, and each component implements the function in combination with the results calculated by the jex l engine. For example, if the parameter is "{{a+b}} yuan", it will be extracted through regular expressions, a+b will be calculated, and then the calculated result c will be replaced with "{{a+b}}" to obtain "c yuan".
[0095] By setting conditional judgments, step parameters, result extraction rules, assertion expected values, step information and other text information at the step component layer, expressions or scripts can be extracted and calculated through character identifiers such as {{}}. There is no need to add additional calculation components under the steps and repeatedly introduce various dependencies. It is easy to use and understand.
[0096] It is understandable that the identifiers in the present application are not limited to the form of {{}}, and can also be identified by other characters such as ~xxx~, $xxx$, etc. This depends on whether the identification characters will be repeated in the tested data. For example, if the test data for normal business contains a string of characters such as "$23 to $29", it is not advisable to use $xxx$ for identification.
[0097] Among them, in this application, a custom java method is written for expression or script calling, so as to pass the expression corresponding to the identifier into the calculation engine for calculation.
[0098] For example, we use custom Java code to encrypt strings with SHA256, because some interfaces need to pass in parameter values encrypted with SHA256 or some data table values are encrypted. When asserting data, some return value extraction data often needs to be encrypted first.
[0099]
[0100]
[0101] This code first gets the MessageD i gest instance of the SHA-256 algorithm, then uses the digest method of the instance to generate the hash value of the input string, and finally converts the resulting byte array into a hexadecimal string.
[0102] Enter expressions or scripts in the input boxes of the target test step input parameter, target test step return value extraction rule, and assertion expected value to call the method. Assuming that the address needs to be encrypted, the following shows the usage of two scenarios:
[0103] Directly enter the address name "Zhejiang Hangzhou" and use: {{ParamUt il:encrypt i on256("Zhejiang Hangzhou")}}
[0104] Enter the parameter name for calculation. Assuming that there is a parameter in the parameter system called address and its corresponding value is "Hangzhou, Zhejiang", the usage is: {{ParamUt il:encrypt i on256(address)}}
[0105] In this way, the platform can recognize the corresponding expression and call the custom encryption method (encryption256(String value)) to encrypt the string, and replace the encrypted result with {{ParamUt il:encryption256("Hangzhou, Zhejiang")}} or {{ParamUt il:encryption256(address)}}.
[0106] In this application, more complex calculation scenarios are performed by referencing Java methods (custom and non-custom), covering more complex automated test cases. The platform parameter calculation capability is greatly improved, and there is no need to add calculation components under the target test step. In any input box of the target test step, double curly brackets {{xxx}} and other characters are used to identify expressions or scripts to achieve parameter calculation and result replacement, eliminating the need to add calculation components and various cumbersome dependency calls.
[0107] In a specific embodiment, Figure 7 As shown, before the test case is executed, the public parameters corresponding to the execution environment will be loaded into the environment parameter thread variable. The public parameters here refer to the environment parameters corresponding to the target test case execution environment. The environment parameters refer to the external factors that affect the system performance, including ambient temperature, running speed, position mode, etc. The obtained environment parameters are added to the environment parameter thread variable in the parameter system for storage.
[0108] Load the use case parameters of the current use case, that is, load the use case parameters required for the target test case execution. Here, the use case parameters refer to the parameters that run through the entire use case and are not controlled by the result extraction value. Add the obtained use case parameters to the use case parameter thread variable in the parameter system for storage.
[0109] After the environment parameters and use case parameters are stored in the corresponding environment parameter thread variables and use case parameter thread variables, the step execution input parameters are passed in (the execution parameters of the first target test step are obtained), and the first target test step is executed according to the execution parameters of the first target test step.
[0110] Exemplarily, after obtaining the input step execution parameter (execution parameter of the first target test step), the input step execution parameter (execution parameter of the first target test step) is parsed to determine whether the input step execution parameter (execution parameter of the first target test step) contains an expression (determine whether the execution parameter includes the first expression). If it does, then the numerical values corresponding to the first environment parameter, the first use case parameter, and the first context parameter that are the same as the character elements in the first expression are obtained from the parameter system according to each character element in the first expression, and these numerical values and expressions are transmitted to the calculation engine. The calculation engine can be a jex l calculation engine or a java calculation engine. After receiving the numerical value and expression, the calculation engine brings the numerical value into the first expression for calculation to obtain the first calculation result (jex l expression calculation table and replaces the expression with the calculation result), and returns the first calculation result (first target input parameter) to the first target test step to participate in the execution of the first target test. At the same time, the first calculation result is added to the context parameter in the parameter system. After obtaining the first target input parameter, the step n is executed based on the first target input parameter. Here, the use case step n refers to the stage of the interface call of the first use case step, not the target test step of the next order of the first target test step. The data extraction of the use case step return value is to extract the data of the return value obtained after the first target test step is executed. Further, according to the extraction rule, it is judged whether the data after the use case step return value extraction contains an expression, that is, it is judged whether the return value includes the second expression. If it does not contain an expression, the data after the use case step return value extraction is stored in the context parameter in the parameter system. If it does, the second environment parameter, the second use case parameter, and the second context parameter corresponding to the character element in the second expression are obtained from the parameter system according to each character element in the second expression. The numerical values and expressions are transmitted to the calculation engine for calculation, and the second calculation result (jex l expression calculation and the expression is replaced by the calculation result) is obtained. The second calculation result (second target input parameter) is returned to the second target test step to participate in the execution of the second target test. At the same time, the second calculation result is added to the context parameter in the parameter system.
[0111] When the next step is the use case step assertion execution, determine whether the assertion expected value of the third target test step includes the third expression; if included, obtain the third environment parameter, the third use case parameter, and the third context parameter corresponding to the third expression, and calculate the third calculation result corresponding to the third expression based on the third environment parameter, the third use case parameter, and the third context parameter (jex l expression calculation and replace the expression with the calculation result); use the third calculation result as the target assertion expected value, and compare the target assertion expected value (illustrated assertion expected value) with the actual execution result (actual value) of the third target test step to obtain a comparison result; obtain the assertion test step status according to the comparison result to determine whether the assertion is successful.
[0112] Continue to execute subsequent target test steps until all target test steps included in the target test case are executed and the execution result of the target test case is obtained.
[0113] In this implementation, the process is different from other web page testing platforms in that after the step return value data is extracted, before the step parameters are used, and before the assertion comparison, all current parameters in the parameter system can be taken for parameter calculation, thereby constructing more complex data and verifying more business scenarios.
[0114] It can be understood that the present application uses the example that the calculation of expressions involves environment parameters, use case parameters and context parameters. In actual applications, when calculating expressions, not all parameters in the expressions will be applied to context parameters, use case parameters and environment parameters. The present application describes that each parameter in each expression involves context parameters, use case parameters and environment parameters. In actual applications, the expression calculation may only apply context parameters and environment parameters, or only apply use case parameters, environment parameters, etc., and the calculation is based on the actual expression.
[0115] It should be understood that although Figure 2 , Figure 7 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , Figure 7 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0116] In one embodiment, Figure 8 As shown, a use case execution device is provided, including: an acquisition module 80 and a processing module 81, wherein:
[0117] The acquisition module 80 is used to acquire a target test case, where the target test case includes at least a first target test step and a second target test step; and acquire an execution parameter of the first target test step;
[0118] Processing module 81 is used to process the execution parameters based on the first processing rule to obtain the first target input parameter, and execute the first target test step based on the first target input parameter; obtain the return value of the first target test step, process the return value according to the second processing rule to obtain the second target input parameter, and execute the second target test step based on the second target input parameter.
[0119] In one embodiment, another implementation of the use case execution method that can be implemented by the above device includes the following specific steps:
[0120] The method of obtaining the execution parameters of the first target test step includes:
[0121] Obtaining environment parameters corresponding to the target test case execution environment, and storing the environment parameters corresponding to the target test case execution environment in a parameter system;
[0122] Obtain the test case parameters required for executing the target test case, and store the test case parameters required for executing the target test case in the parameter system;
[0123] Obtain the context parameters required for the target test case execution, and store the context parameters required for the target test case execution in the parameter system.
[0124] In one embodiment, another implementation of the use case execution method that can be implemented by the above device includes the following specific steps:
[0125] Processing the execution parameter based on the first processing rule to obtain the first target input parameter, and executing the first target test step based on the first target input parameter includes:
[0126] Determine whether the execution parameters include the first expression;
[0127] If included, obtaining the first environment parameter, the first use case parameter, and the first context parameter corresponding to the first expression, and calculating the first calculation result corresponding to the first expression based on the first environment parameter, the first use case parameter, and the first context parameter;
[0128] The first calculation result is returned to the parameter system as the first target input parameter of the first target test step and stored; the first target test step is executed based on the first target input parameter.
[0129] In one embodiment, another implementation of the use case execution method that can be implemented by the above device includes the following specific steps:
[0130] Obtaining a return value of the first target test step, processing the return value according to a second processing rule to obtain a second target input parameter, and executing the second target test step based on the second target input parameter includes:
[0131] Determine whether the return value includes the second expression;
[0132] If included, obtaining the second environment parameter, the second use case parameter, and the second context parameter corresponding to the second expression, and calculating the second calculation result corresponding to the second expression based on the second environment parameter, the second use case parameter, and the second context parameter;
[0133] The second calculation result is stored in the second target input parameter return parameter system as the second target test step;
[0134] In response to receiving the second target test step execution instruction, obtaining the second target input parameter from the parameter system to execute the second target test step.
[0135] In one embodiment, another implementation of the use case execution method that can be implemented by the above device includes the following specific steps:
[0136] Determining whether the return value includes the second expression includes:
[0137] Obtain the expected input parameter of the target test case execution step, and obtain the second expression corresponding to the expected input parameter;
[0138] Determine whether the return value includes the second expression corresponding to the expected input parameter;
[0139] If included, calculate the second calculation result corresponding to the second expression;
[0140] If not included, the parameters in the return value are extracted and stored in the parameter system.
[0141] In one embodiment, another implementation of the use case execution method that can be implemented by the above device includes the following specific steps:
[0142] The target test case also includes a third target test step, which is an assertion test step. The method includes:
[0143] Get the expected value of the assertion of the third target test step;
[0144] determining whether the assertion expected value of the third target test step includes the third expression;
[0145] If included, obtaining a third environment parameter, a third use case parameter, and a third context parameter corresponding to the third expression, and calculating a third calculation result corresponding to the third expression based on the third environment parameter, the third use case parameter, and the third context parameter;
[0146] Using the third calculation result as the target assertion expected value, and comparing the target assertion expected value with the actual execution result of the third target test step to obtain a comparison result;
[0147] Get the assertion test step status based on the comparison result.
[0148] In one embodiment, another implementation of the use case execution method that can be implemented by the above device includes the following specific steps:
[0149] The method also includes:
[0150] Identify the first expression, the second expression, and the third expression;
[0151] The input box is located. The input box extracts the expression corresponding to the identifier by identifying the identifier, and passes the expression corresponding to the identifier to the calculation engine for calculation.
[0152] For the specific definition of the use case execution device, please refer to the definition of the use case execution method above, which will not be repeated here. Each module in the above-mentioned use case execution device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0153] In one embodiment, the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the use case execution methods provided by the above methods.
[0154] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data applied by the use case execution method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a use case execution method is implemented.
[0155] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0156] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0157] Step 201, obtaining a target test case, where the target test case at least includes a first target test step and a second target test step.
[0158] Step 202, obtaining execution parameters of the first target test step.
[0159] Step 203: Process the execution parameters based on the first processing rule to obtain the first target input parameter, and execute the first target test step based on the first target input parameter.
[0160] Step 204, obtain the return value of the first target test step, process the return value according to the second processing rule, obtain the second target input parameter, and execute the second target test step based on the second target input parameter.
[0161] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0162] The method of obtaining the execution parameters of the first target test step includes:
[0163] Obtaining environment parameters corresponding to the target test case execution environment, and storing the environment parameters corresponding to the target test case execution environment in a parameter system;
[0164] Obtain the test case parameters required for executing the target test case, and store the test case parameters required for executing the target test case in the parameter system;
[0165] Obtain the context parameters required for the target test case execution, and store the context parameters required for the target test case execution in the parameter system.
[0166] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0167] Processing the execution parameter based on the first processing rule to obtain the first target input parameter, and executing the first target test step based on the first target input parameter includes:
[0168] Determine whether the execution parameters include the first expression;
[0169] If included, obtaining the first environment parameter, the first use case parameter, and the first context parameter corresponding to the first expression, and calculating the first calculation result corresponding to the first expression based on the first environment parameter, the first use case parameter, and the first context parameter;
[0170] The first calculation result is returned to the parameter system as the first target input parameter of the first target test step and stored; the first target test step is executed based on the first target input parameter.
[0171] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0172] Obtaining a return value of the first target test step, processing the return value according to a second processing rule to obtain a second target input parameter, and executing the second target test step based on the second target input parameter includes:
[0173] Determine whether the return value includes the second expression;
[0174] If included, obtaining the second environment parameter, the second use case parameter, and the second context parameter corresponding to the second expression, and calculating the second calculation result corresponding to the second expression based on the second environment parameter, the second use case parameter, and the second context parameter;
[0175] The second calculation result is stored in the second target input parameter return parameter system as the second target test step;
[0176] In response to receiving the second target test step execution instruction, obtaining the second target input parameter from the parameter system to execute the second target test step.
[0177] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0178] Determining whether the return value includes the second expression includes:
[0179] Obtain the expected input parameter of the target test case execution step, and obtain the second expression corresponding to the expected input parameter;
[0180] Determine whether the return value includes the second expression corresponding to the expected input parameter;
[0181] If included, calculate the second calculation result corresponding to the second expression;
[0182] If not included, the parameters in the return value are extracted and stored in the parameter system.
[0183] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0184] The target test case also includes a third target test step, which is an assertion test step. The method includes:
[0185] Get the expected value of the assertion of the third target test step;
[0186] determining whether the assertion expected value of the third target test step includes the third expression;
[0187] If included, obtaining a third environment parameter, a third use case parameter, and a third context parameter corresponding to the third expression, and calculating a third calculation result corresponding to the third expression based on the third environment parameter, the third use case parameter, and the third context parameter;
[0188] Using the third calculation result as the target assertion expected value, and comparing the target assertion expected value with the actual execution result of the third target test step to obtain a comparison result;
[0189] Get the assertion test step status based on the comparison result.
[0190] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0191] The method also includes:
[0192] Identify the first expression, the second expression, and the third expression;
[0193] The input box is located. The input box extracts the expression corresponding to the identifier by identifying the identifier, and passes the expression corresponding to the identifier to the calculation engine for calculation.
[0194] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0195] Step 201, obtaining a target test case, where the target test case at least includes a first target test step and a second target test step.
[0196] Step 202, obtaining execution parameters of the first target test step.
[0197] Step 203: Process the execution parameters based on the first processing rule to obtain the first target input parameter, and execute the first target test step based on the first target input parameter.
[0198] Step 204, obtain the return value of the first target test step, process the return value according to the second processing rule, obtain the second target input parameter, and execute the second target test step based on the second target input parameter.
[0199] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0200] The method of obtaining the execution parameters of the first target test step includes:
[0201] Obtaining environment parameters corresponding to the target test case execution environment, and storing the environment parameters corresponding to the target test case execution environment in a parameter system;
[0202] Obtain the test case parameters required for executing the target test case, and store the test case parameters required for executing the target test case in the parameter system;
[0203] Obtain the context parameters required for the target test case execution, and store the context parameters required for the target test case execution in the parameter system.
[0204] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0205] Processing the execution parameter based on the first processing rule to obtain the first target input parameter, and executing the first target test step based on the first target input parameter includes:
[0206] Determine whether the execution parameters include the first expression;
[0207] If included, obtaining the first environment parameter, the first use case parameter, and the first context parameter corresponding to the first expression, and calculating the first calculation result corresponding to the first expression based on the first environment parameter, the first use case parameter, and the first context parameter;
[0208] The first calculation result is returned to the parameter system as the first target input parameter of the first target test step and stored; the first target test step is executed based on the first target input parameter.
[0209] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0210] Obtaining a return value of the first target test step, processing the return value according to a second processing rule to obtain a second target input parameter, and executing the second target test step based on the second target input parameter includes:
[0211] Determine whether the return value includes the second expression;
[0212] If included, obtaining the second environment parameter, the second use case parameter, and the second context parameter corresponding to the second expression, and calculating the second calculation result corresponding to the second expression based on the second environment parameter, the second use case parameter, and the second context parameter;
[0213] The second calculation result is stored in the second target input parameter return parameter system as the second target test step;
[0214] In response to receiving the second target test step execution instruction, obtaining the second target input parameter from the parameter system to execute the second target test step.
[0215] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0216] Determining whether the return value includes the second expression includes:
[0217] Obtain the expected input parameter of the target test case execution step, and obtain the second expression corresponding to the expected input parameter;
[0218] Determine whether the return value includes the second expression corresponding to the expected input parameter;
[0219] If included, then using the calculation engine to calculate a second calculation result corresponding to the second expression;
[0220] If not included, the parameters in the return value are extracted and stored in the parameter system.
[0221] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0222] The target test case also includes a third target test step, which is an assertion test step. The method includes:
[0223] Get the expected value of the assertion of the third target test step;
[0224] determining whether the assertion expected value of the third target test step includes the third expression;
[0225] If included, obtaining a third environment parameter, a third use case parameter, and a third context parameter corresponding to the third expression, and calculating a third calculation result corresponding to the third expression based on the third environment parameter, the third use case parameter, and the third context parameter;
[0226] Using the third calculation result as the target assertion expected value, and comparing the target assertion expected value with the actual execution result of the third target test step to obtain a comparison result;
[0227] Get the assertion test step status based on the comparison result.
[0228] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0229] The method also includes:
[0230] Identify the first expression, the second expression, and the third expression;
[0231] The input box is located. The input box extracts the expression corresponding to the identifier by identifying the identifier, and passes the expression corresponding to the identifier to the calculation engine for calculation.
[0232] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0233] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0234] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A use case execution method, characterized in that: include: Obtain a target test case, where the target test case includes at least a first target test step and a second target test step; Obtaining execution parameters of the first target test step; Processing the execution parameter based on a first processing rule to obtain a first target input parameter, and executing a first target test step based on the first target input parameter; Obtain a return value of the first target test step, process the return value according to a second processing rule to obtain a second target input parameter, and execute the second target test step based on the second target input parameter.
2. The method according to claim 1, characterized in that The step of obtaining the execution parameters of the first target test step includes: Acquire environmental parameters corresponding to the target test case execution environment, and store the environmental parameters corresponding to the target test case execution environment in a parameter system; Acquire the test case parameters required for executing the target test case, and store the test case parameters required for executing the target test case in a parameter system; The context parameters required for executing the target test case are obtained, and the context parameters required for executing the target test case are stored in a parameter system.
3. The method according to claim 2, characterized in that The step of processing the execution parameter based on the first processing rule to obtain a first target input parameter, and executing the first target test step based on the first target input parameter includes: Determining whether the execution parameters include a first expression; If included, obtaining the first environment parameter, the first use case parameter, and the first context parameter corresponding to the first expression, and calculating the first calculation result corresponding to the first expression based on the first environment parameter, the first use case parameter, and the first context parameter; The first calculation result is returned to the parameter system as the first target input parameter of the first target test step and stored; the first target test step is executed based on the first target input parameter.
4. The method according to claim 2, characterized in that: The step of obtaining a return value of the first target test step, processing the return value according to a second processing rule to obtain a second target input parameter, and executing the second target test step based on the second target input parameter includes: Determine whether the return value includes a second expression; If included, obtaining a second environment parameter, a second use case parameter, and a second context parameter corresponding to the second expression, and calculating a second calculation result corresponding to the second expression based on the second environment parameter, the second use case parameter, and the second context parameter; The second calculation result is stored in the second target input parameter return parameter system as the second target test step; In response to receiving the second target test step execution instruction, the second target input parameter is obtained from the parameter system to execute the second target test step.
5. The method according to claim 4, characterized in that The determining whether the return value includes the second expression comprises: Obtain the expected input parameter of the target test case execution step, and obtain the second expression corresponding to the expected input parameter; Determine whether the return value includes the second expression corresponding to the expected input parameter; If included, calculate the second calculation result corresponding to the second expression; If not included, the parameters in the return value are extracted and stored in the parameter system.
6. The method according to claim 1, characterized in that The target test case further includes a third target test step, which is an assertion test step. The method includes: Get the expected value of the assertion of the third target test step; Determining whether the assertion expected value of the third target test step includes a third expression; If included, obtaining a third environment parameter, a third use case parameter, and a third context parameter corresponding to the third expression, and calculating a third calculation result corresponding to the third expression based on the third environment parameter, the third use case parameter, and the third context parameter; Using the third calculation result as a target assertion expected value, and comparing the target assertion expected value with an actual execution result of the third target test step to obtain a comparison result; The assertion test step status is obtained according to the comparison result.
7. The method according to claim 1, characterized in that The method further comprises: Identify the first expression, the second expression, and the third expression; An input box is located, and the input box extracts an expression corresponding to the identifier by identifying the identifier, and transmits the expression corresponding to the identifier to a calculation engine for calculation.
8. A use case execution device, characterized in that: The device comprises: An acquisition module is used to acquire a target test case, wherein the target test case includes at least a first target test step and a second target test step; and acquire an execution parameter of the first target test step; A processing module is used to process the execution parameters based on a first processing rule to obtain a first target input parameter, and execute a first target test step based on the first target input parameter; obtain a return value of the first target test step, process the return value according to a second processing rule to obtain a second target input parameter, and execute a second target test step based on the second target input parameter.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, 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 7 are implemented.