Automatic test code generation method based on parameter correlation and combination constraints
By calculating the input parameter correlation coefficient based on parameter correlation and combination constraints, the target parameters are filtered, and the combined constraint library is used to generate test cases, which solves the problems of low efficiency and insufficient flexibility in the generation of test cases in traditional methods, and achieves high coverage Test code generation for rate and accuracy.
Patent Information
- Application Number
- CN202411218650.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-02
AI Technical Summary
Traditional test case generation methods rely on programming languages and source code analysis, resulting in low generation efficiency and insufficient flexibility, making it difficult to generate test cases quickly and accurately, especially in test scenarios at non-code level and input parameter level.
The automatic generation method of test code based on parameter correlation and combination constraints is adopted. By calculating the correlation coefficient of the input parameters, filtering the target parameters, using the combination constraint library to generate the test case set, and dynamically adjusting the extraction range according to the execution results to generate the test code.
It improves the coverage and effectiveness of test cases, ensures the comprehensiveness and adaptability of tests, promptly discovers and corrects problems, improves the accuracy and reliability of test codes, and optimizes the generation efficiency of test cases.
Smart Images

Figure CN118760607B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of test code generation, and in particular to a test code automatic generation method based on parameter correlation and combination constraints. Background Art
[0002] As software systems become increasingly complex and diverse, traditional test case generation methods face increasing challenges. These methods often rely on detailed analysis of source code and complex calculation processes, resulting in low test case generation efficiency and limited applicability. At the same time, with the continuous emergence of new technologies and new applications, the demand for testing is also increasing, requiring the ability to quickly and accurately generate effective test cases. Therefore, a more efficient and flexible test case generation method is urgently needed to meet these challenges.
[0003] The patent document with publication number CN108959056A discloses a test case generation method and a test case generation device. The method of generating test cases using the device includes: for source codes written in different programming languages, respectively constructing a relationship graph between functions in the corresponding source codes; detecting the connection information between the source codes written in different programming languages; connecting the relationship graph according to the connection information to generate a connection graph; traversing the connection graph to generate a combination path constraint expression; symbolically executing each function in the source code to generate a specific combination path constraint according to the combination path constraint expression; and solving the specific combination path constraint to generate a test case. It can be seen that the method relies on the relationship graph construction and symbolic execution of source codes written in different programming languages, which increases the dependence and complexity on programming languages. Support for different languages requires more complex parsing and conversion processes, and the symbolic execution technology itself is relatively complex, with high requirements on computing resources and time, and mainly targets the function relationship and path constraints of the source code, which may not be suitable for non-code level test scenarios or input parameter level tests. Summary of the invention
[0004] To this end, the present invention provides a method for automatically generating test code based on parameter correlation and combination constraints, so as to overcome the problems in the prior art of slow test code generation speed and low accuracy caused by low test case generation efficiency and insufficient flexibility due to reliance on programming language and source code.
[0005] To achieve the above object, the present invention provides a method for automatically generating test codes based on parameter correlation and combination constraints, comprising:
[0006] Extract all input parameters in the module to be tested in real time within a preset extraction range and calculate the correlation coefficients between the input parameters;
[0007] Determine a plurality of first target parameters from among all input parameters according to the correlation coefficient and a preset standard correlation;
[0008] Determine a number of second target parameters from all first target parameters according to a preset combined constraint library;
[0009] Generate a number of test case sets according to all second target parameters;
[0010] Execute all test case sets and determine abnormal execution results based on all execution results and preset standard execution results;
[0011] Determine based on the number of abnormal execution results and the preset number of standard abnormalities, generate test codes for all test case sets based on the determination results, or calculate the difference between the abnormal execution results and the preset standard execution results;
[0012] Make a judgment based on the difference and the preset tolerance range, record the abnormal execution result and issue a prompt based on the judgment result, or increase or decrease the correction extraction range based on the number of characters in the abnormal execution result and the preset standard character number range, and extract all input parameters in the module to be tested with the corrected extraction range until the test code for the entire test case set is generated.
[0013] Furthermore, the step of extracting all input parameters in the module to be tested in real time within a preset extraction range and calculating the correlation coefficients between the input parameters includes:
[0014] The average value of all input parameters is calculated, and the correlation coefficient between any two input parameters is calculated using the Pearson correlation coefficient calculation formula based on the average value of all input parameters and any two input parameters.
[0015] Further, the determining of a plurality of first target parameters from all input parameters according to the correlation coefficient and a preset standard correlation degree includes:
[0016] When the absolute value of the correlation coefficient is less than the standard correlation, it is determined that the corresponding two input parameters are both the first target parameters.
[0017] Further, determining the second target parameter among all the first target parameters according to the preset combined constraint library includes:
[0018] All first target parameters are screened according to the constraints in the combined constraint library to obtain several second target parameters
[0019] Further, executing all test case sets and determining abnormal execution results according to all execution results and preset standard execution results includes:
[0020] When each execution result is not a preset standard execution result, the execution result is determined to be an abnormal execution result.
[0021] Further, a determination is made based on the number of abnormal execution results and the preset number of standard abnormalities, and the test code of the entire test case set is generated based on the determination result, including:
[0022] When the number of abnormal execution results is less than the standard number of abnormalities, the test code of the entire test case set is directly generated according to the determination result.
[0023] Furthermore, when the number of abnormal execution results is greater than or equal to the standard abnormal number, the mean square error calculation formula is used to calculate the average value of the square differences between the abnormal execution results and the standard execution results to obtain the difference degree.
[0024] Furthermore, when the difference is not within the tolerance range, the abnormal execution result is recorded and a prompt is issued.
[0025] Furthermore, when the number of characters in the abnormal execution result is less than the minimum value of the standard character number range, the maximum value of the corrected extraction range is increased according to the number of characters, the minimum value of the standard character number range and a preset range correction coefficient.
[0026] Further, when the number of characters in the abnormal execution result is greater than the maximum value of the standard character number range, the maximum value of the extraction range is reduced and corrected according to the number of characters, the maximum value of the standard character number range, and the range correction coefficient.
[0027] Compared with the prior art, the beneficial effects of the present invention are that, by calculating parameter correlation coefficients and using a combinatorial constraint library for screening, test cases with high coverage and effectiveness are effectively generated, and by real-time extraction and dynamic adjustment of parameter extraction range, the comprehensiveness and adaptability of test cases are guaranteed. After executing the test cases, by analyzing abnormal execution results, problems are discovered and corrected in a timely manner, thereby improving the accuracy and reliability of the test code, and by making intelligent adjustments based on the degree of difference, the test cases are further optimized, effectively solving the problems of slow test code generation and low accuracy caused by low test case generation efficiency and insufficient flexibility due to reliance on programming languages and source codes.
[0028] Furthermore, by quantifying the linear relationship between input parameters, it helps to identify those parameter combinations that are highly correlated or independent.
[0029] Furthermore, by screening parameter combinations with lower correlation, it helps to identify those input parameters with lower dependence.
[0030] Furthermore, by applying the combination constraint library, it is ensured that the parameter combinations selected in the test cases meet the limitations and requirements in actual applications, thereby improving the validity of the test results.
[0031] Furthermore, by comparing the actual execution results with the standard results, abnormalities or behaviors that do not meet expectations in the system can be quickly located.
[0032] Furthermore, by setting a standard number of exceptions, the abnormality level of the test results can be effectively controlled. When the number of exceptions is within an acceptable range, directly generating test codes can save time and resources.
[0033] Furthermore, by calculating the mean square error and obtaining the difference, the difference between the abnormal execution results and the standard results can be accurately quantified, which helps to evaluate whether the performance of the test case set meets expectations.
[0034] Furthermore, by recording abnormal results and issuing prompts, problems in the test can be discovered and responded to in a timely manner.
[0035] Furthermore, by expanding the extraction range, we can ensure that the test can cover more input conditions. The number of characters in the abnormal execution result is less than the minimum value of the standard range, which means that the current extraction range may not be sufficient to cover all possible test scenarios. Increasing the maximum value can help include more possible input conditions, thereby improving the comprehensiveness of the test.
[0036] Furthermore, by reducing the maximum value of the modified extraction range when the number of characters exceeds the standard range, the test can be made more accurate and effective. Narrowing the extraction range can focus on conditions that are more likely to cause abnormalities, thereby avoiding unnecessary complexity and irrelevant data in the test. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a flow chart of the method for automatically generating test codes based on parameter correlation and combination constraints of this embodiment;
[0038] Figure 2 A decision logic diagram for determining a first target parameter for this embodiment;
[0039] Figure 3 A decision logic diagram for determining the second target parameter for this embodiment;
[0040] Figure 4 This is a decision logic diagram for determining abnormal execution results in this embodiment. DETAILED DESCRIPTION
[0041] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0042] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0043] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0044] See also Figure 1 As shown, it is a flowchart of the method for automatically generating test codes based on parameter correlation and combination constraints in this embodiment;
[0045] This embodiment provides a method for automatically generating test codes based on parameter correlation and combination constraints, including:
[0046] Extract all input parameters in the module to be tested in real time within a preset extraction range and calculate the correlation coefficients between the input parameters;
[0047] Determine a plurality of first target parameters from among all input parameters according to the correlation coefficient and a preset standard correlation;
[0048] Determine a number of second target parameters from all first target parameters according to a preset combined constraint library;
[0049] Generate a number of test case sets according to all second target parameters;
[0050] Execute all test case sets and determine abnormal execution results based on all execution results and preset standard execution results;
[0051] Determine based on the number of abnormal execution results and the preset number of standard abnormalities, generate test codes for all test case sets based on the determination results, or calculate the difference between the abnormal execution results and the preset standard execution results;
[0052] Make a judgment based on the difference and the preset tolerance range, record the abnormal execution result and issue a prompt based on the judgment result, or increase or decrease the correction extraction range based on the number of characters in the abnormal execution result and the preset standard character number range, and extract all input parameters in the module to be tested with the corrected extraction range until the test code for the entire test case set is generated.
[0053] The preset extraction range is the initial range set by the system when performing parameter extraction. It depends on the complexity of the module to be tested and the number of input parameters. It is usually set to a range that can cover all input parameters. This embodiment is set to a set of all input parameters, which can ensure that the test covers all possible input parameters and ensure the comprehensiveness of the test.
[0054] The input parameters are all variables or values that need to be tested in the module to be tested, which depend on the function and design of the module to be tested, and usually include all parameters that may affect the behavior of the module. In this embodiment, all parameters in the module to be tested are set to fully cover the input of the module to be tested to ensure the integrity of the test.
[0055] The correlation coefficient is a numerical value used to measure the strength of the linear relationship between two input parameters, which depends on the changing relationship of the two input parameters. The correlation coefficient of the present embodiment is calculated using the Pierre correlation coefficient calculation formula, which usually ranges from -1 to 1, indicating a complete negative correlation, no correlation, and a complete positive correlation. It can accurately measure the relationship between the input parameters and provide a basis for parameter screening.
[0056] The preset standard correlation is used to determine whether the correlation between input parameters is significant. It depends on the actual test requirements and the strength of the correlation between the parameters. It is usually set between 0.1 and 0.5. In this embodiment, it is set to 0.3, which can screen out parameters with lower correlation and ensure the diversity of test cases.
[0057] The first target parameter is a group of parameters selected from all input parameters whose correlation is lower than the preset standard correlation, depending on the correlation coefficient and the preset standard correlation. In this embodiment, it is set to select all parameters with a correlation lower than 0.3 to ensure the independence of parameters in the test case and improve the test coverage.
[0058] The preset combination constraint library includes a library of various combination constraint conditions, which are used to screen the first target parameter, depending on the actual application scenario and the rationality of the parameter combination, and generally includes all possible parameter combination constraint conditions. This embodiment is set to the common parameter combination constraints in actual applications, which can ensure that the generated test cases are reasonable and effective, and improve the practicality of the test.
[0059] The second target parameter is a parameter screened through the combination constraint library. It is a set of parameters in the first target parameter that meet the preset combination constraint. It depends on the preset combination constraint library and the first target parameter. It is usually several parameters that meet the combination constraint. This embodiment is set to screen out all parameters that meet the combination constraint, and further screen the parameters to ensure the effectiveness and pertinence of the test case.
[0060] The preset standard execution result is the correct output or behavior expected to be obtained during the execution of the test case, which depends on the design specifications and functional expectations of the module to be tested. It is usually the ideal output of the module to be tested, and provides a benchmark for judging whether the test result is correct, ensuring the accuracy of the test result. This embodiment is configured to execute the correct result.
[0061] The abnormal execution result is a test result that does not conform to the preset standard execution result. It depends on the comparison between the actual execution result and the standard execution result. It usually includes all outputs that do not conform to the standard execution result. In this embodiment, it is set to the execution failure result and the execution error result.
[0062] The preset standard exception number is the maximum number of allowed abnormal execution results. It depends on the test requirements and fault tolerance. It is usually set to a smaller value, such as 1 or 2. In this embodiment, it is set to 1, which can control the number of exceptions and ensure the reliability and stability of the test results.
[0063] The preset tolerance range is the range within which the difference is allowed. Depending on the actual test requirements and the degree of tolerance, it is usually set in a smaller range, such as 0.1 to 0.5. In this embodiment, it is set to 0.2, which can ensure that the difference is within an acceptable range and the accuracy of the test results.
[0064] The preset standard character number range is used to evaluate the range of the number of characters in the abnormal execution result. It depends on the actual test content and the expected number of characters. Usually a reasonable character number range is set, such as 10 to 100, and this embodiment is set to 20 to 80. It can ensure that the number of characters in the abnormal result is within a reasonable range, which is helpful for analyzing and adjusting the extraction range.
[0065] First, all input parameters in the module to be tested are extracted in real time and the correlation coefficients between them are calculated. Then, a number of first target parameters are screened out according to the correlation coefficient and the preset standard correlation. Next, a number of second target parameters are determined from the first target parameters according to the preset combination constraint library. Subsequently, multiple test case sets are generated based on these second target parameters, and these test cases are executed. The abnormal execution results are determined based on the comparison between the execution results and the standard results, and further judged based on the number of abnormal execution results and the number of standard abnormalities, and the test code is generated or the difference is calculated and the extraction range is adjusted until the final test code is generated.
[0066] By calculating parameter correlation coefficients and using the combinatorial constraint library for screening, test cases with high coverage and effectiveness are effectively generated. By real-time extraction and dynamic adjustment of parameter extraction range, the comprehensiveness and adaptability of test cases are guaranteed. After executing the test cases, by analyzing abnormal execution results, problems are discovered and corrected in a timely manner, which improves the accuracy and reliability of the test code. By making intelligent adjustments based on the degree of difference, the test cases are further optimized, effectively solving the problems of slow test code generation and low accuracy caused by low test case generation efficiency and insufficient flexibility due to reliance on programming languages and source codes.
[0067] Specifically, the extracting all input parameters in the module to be tested in real time within a preset extraction range and calculating the correlation coefficients between the input parameters includes:
[0068] The average value of all input parameters is calculated, and the correlation coefficient between any two input parameters is calculated using the Pearson correlation coefficient calculation formula based on the average value of all input parameters and any two input parameters.
[0069] In the process of extracting all input parameters of the module to be tested in real time with a preset extraction range, the average values of all input parameters need to be calculated first. Then, using these average values and the actual data of any two input parameters, the Pearson correlation coefficient calculation formula is applied to calculate the correlation coefficient between them. This formula measures the linear relationship between two variables by evaluating the product of their covariance and their standard deviation.
[0070] By quantifying the linear relationship between input parameters, it helps to identify those parameter combinations that are highly correlated or independent.
[0071] Please continue reading Figure 2 As shown, it is a decision logic diagram for determining the first target parameter in this embodiment;
[0072] Specifically, the determining of a plurality of first target parameters from all input parameters according to the correlation coefficient and the preset standard correlation degree includes:
[0073] When the absolute value of the correlation coefficient is less than the standard correlation, it is determined that the corresponding two input parameters are both the first target parameters.
[0074] In the process of determining the first target parameter based on the correlation coefficient and the preset standard correlation, the correlation coefficient between each pair of input parameters is first calculated. Then, the absolute value of these correlation coefficients is compared with the preset standard correlation. When the absolute value of the correlation coefficient is less than the standard correlation, the pair of parameters is marked as the first target parameter. This means that the linear relationship between these parameters is weak and their changes will not affect each other too much.
[0075] By screening parameter combinations with low correlation, it helps to identify those input parameters with low dependence.
[0076] Please continue reading Figure 3 As shown, it is a decision logic diagram for determining the second target parameter in this embodiment;
[0077] Specifically, determining the second target parameter among all the first target parameters according to the preset combined constraint library includes:
[0078] All first target parameters are screened according to the constraint conditions in the combined constraint library to obtain a number of second target parameters.
[0079] In the process of determining the second target parameter according to the preset combined constraint library, the constraints in the combined constraint library are first applied to all the screened first target parameters. These constraints specify the valid combination of parameters, such as range restrictions, mutually exclusive relationships, or dependency relationships. By screening the first target parameters through these conditions, several parameters that meet the constraints can be identified as the second target parameters.
[0080] By applying the combination constraint library, it is ensured that the parameter combinations selected in the test cases meet the limitations and requirements in actual applications, thereby improving the effectiveness of the test results.
[0081] Please continue reading Figure 4 As shown, it is a decision logic diagram for determining abnormal execution results in this embodiment;
[0082] Specifically, executing all test case sets and determining abnormal execution results according to all execution results and preset standard execution results includes:
[0083] When each execution result is not a preset standard execution result, the execution result is determined to be an abnormal execution result.
[0084] During the execution of the entire test case set, each test case is evaluated based on the preset standard execution results. By comparing the actual execution results with these preset standard results, if the actual result of a test case does not meet the expected standard execution result, the execution result is marked as an abnormal execution result. This judgment method ensures that the results of all test cases can meet expectations, thereby identifying potential problems or defects in the system.
[0085] By comparing the actual execution results with the standard results, you can quickly locate abnormalities or unexpected behaviors in the system.
[0086] Specifically, the determination is made based on the number of abnormal execution results and the preset number of standard abnormalities, and the test code for generating the entire test case set based on the determination result includes:
[0087] When the number of abnormal execution results is less than the standard number of abnormalities, the test code of the entire test case set is directly generated according to the determination result.
[0088] When judging based on the number of abnormal execution results and the preset standard number of abnormalities, first count the number of abnormal execution results in all test cases. If the number of abnormal execution results is less than the preset standard number of abnormalities, it means that the abnormalities in the test case set are within the acceptable range. In this case, the existing test case set is directly used to generate the final test code without further adjusting or revising the test case set.
[0089] By setting a standard number of exceptions, the abnormal level of the test results can be effectively controlled. When the number of exceptions is within an acceptable range, directly generating test code can save time and resources.
[0090] Specifically, when the number of abnormal execution results is greater than or equal to the number of standard abnormalities, the mean square error calculation formula is used to calculate the average of the square differences between the abnormal execution results and the standard execution results to obtain the difference degree.
[0091] When the number of abnormal execution results is greater than or equal to the number of standard abnormal results, further analysis of the abnormal situation is required. The square difference between all abnormal execution results and the preset standard execution results is calculated using the mean square error calculation formula. The square difference between each abnormal execution result and the standard execution result is calculated, and these square differences are summed and then divided by the number of abnormal results to obtain the average value, that is, the difference. This process aims to quantify the degree of deviation between the abnormal execution results and the standard results.
[0092] By calculating the mean square error and obtaining the degree of difference, the difference between abnormal execution results and standard results can be accurately quantified, which helps to evaluate whether the performance of the test case set meets expectations.
[0093] Specifically, when the difference is not within the tolerance range, the abnormal execution result is recorded and a prompt is issued.
[0094] When the difference is not within the preset tolerance range, further measures need to be taken. First, the calculated difference is compared with the tolerance range. If the difference exceeds the tolerance range, these abnormal execution results are recorded and a prompt is issued through the system. The recorded content includes the specific abnormal results and the difference, which is convenient for subsequent analysis and processing.
[0095] By recording abnormal results and issuing prompts, problems in testing can be discovered and responded to in a timely manner.
[0096] Specifically, when the number of characters in the abnormal execution result is less than the minimum value of the standard character number range, the maximum value of the corrected extraction range is increased according to the number of characters, the minimum value of the standard character number range, and a preset range correction coefficient.
[0097] The preset range correction coefficient is a parameter used to adjust the upper and lower limits of the extraction range, and the purpose is to make appropriate corrections to the test range according to the characteristics of the abnormal results during the actual test process. Depending on the test objectives and requirements, the distribution of abnormal results and the characteristics of the test environment, there is usually no fixed standard for the setting of the range correction coefficient, but it is determined according to the specific application and test requirements. It is usually set to a positive number less than 1, such as 0.1 to 0.5, for moderately adjusting the extraction range. The specific value depends on the complexity of the test, the distribution of abnormal results and the requirements for data accuracy. In this embodiment, the preset range correction coefficient is set to 0.2. This setting is selected according to the actual test requirements and the characteristics of the abnormal data, with the purpose of providing sufficient adjustment space in actual operation while avoiding excessive expansion or contraction of the extraction range.
[0098] When the number of characters in the abnormal execution result is less than the minimum value of the standard character number range, the extraction range needs to be adjusted to improve the test. First, determine the difference between the actual number of characters in the abnormal execution result and the minimum value of the standard character number range. Then, based on this difference, the minimum value of the standard character number range, and the preset range correction factor, increase the maximum value of the extraction range. This process involves calculating a new maximum value to ensure that the extraction range can cover more potential test conditions.
[0099] By expanding the extraction range, ensure that the test can cover more input conditions. The number of characters in the abnormal execution result is less than the minimum value of the standard range, indicating that the current extraction range may not be sufficient to cover all possible test scenarios. Increasing the maximum value can help include more possible input conditions, thereby improving the comprehensiveness of the test.
[0100] Specifically, when the number of characters in the abnormal execution result is greater than the maximum value of the standard character number range, the maximum value of the extraction range is reduced and corrected according to the number of characters, the maximum value of the standard character number range, and the range correction coefficient.
[0101] When the number of characters in the abnormal execution result is greater than the maximum value of the standard character number range, the extraction range needs to be adjusted. First, the actual number of characters in the abnormal execution result is compared with the maximum value of the standard character number range. Then, based on the number of characters, the maximum value of the standard character number range, and the preset range correction factor, a new maximum value is calculated to narrow the extraction range. This new maximum value is used to correct the upper limit of the extraction range to exclude input conditions that do not meet the actual test requirements.
[0102] By reducing the maximum value of the corrected extraction range when the number of characters exceeds the standard range, the test can be made more accurate and effective. Narrowing the extraction range can focus on conditions that are more likely to cause abnormalities, thereby avoiding unnecessary complexity and irrelevant data in the test.
[0103] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0104] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for automatically generating test code based on parameter correlation and combination constraints, characterized in that: include: Extract all input parameters in the module to be tested in real time within a preset extraction range and calculate the correlation coefficients between the input parameters; Determine a plurality of first target parameters from among all input parameters according to the correlation coefficient and a preset standard correlation; Determine a number of second target parameters from all first target parameters according to a preset combined constraint library; Generate a number of test case sets according to all second target parameters; Execute all test case sets and determine abnormal execution results based on all execution results and preset standard execution results; Determine based on the number of abnormal execution results and the preset number of standard abnormalities, generate test codes for all test case sets based on the determination results, or calculate the difference between the abnormal execution results and the preset standard execution results; Make a judgment based on the difference and the preset tolerance range, record the abnormal execution result and issue a prompt based on the judgment result, or increase or decrease the correction extraction range based on the number of characters in the abnormal execution result and the preset standard number of characters, and extract all input parameters in the module to be tested with the corrected extraction range until the test code of the entire test case set is generated; When the number of characters in the abnormal execution result is less than the minimum value of the standard character number range, the maximum value of the corrected extraction range is increased according to the number of characters, the minimum value of the standard character number range, and a preset range correction coefficient; When the number of characters in the abnormal execution result is greater than the maximum value of the standard character number range, the maximum value of the extraction range is reduced and corrected according to the number of characters, the maximum value of the standard character number range, and the range correction coefficient.
2. The method for automatically generating test code based on parameter correlation and combination constraints according to claim 1, characterized in that: The method of extracting all input parameters in the module to be tested in real time within a preset extraction range and calculating the correlation coefficients between the input parameters includes: The average value of all input parameters is calculated, and the correlation coefficient between any two input parameters is calculated using the Pearson correlation coefficient calculation formula based on the average value of all input parameters and any two input parameters.
3. The method for automatically generating test code based on parameter correlation and combination constraints according to claim 2, characterized in that: The step of determining a plurality of first target parameters from among all input parameters according to the correlation coefficient and the preset standard correlation comprises: When the absolute value of the correlation coefficient is less than the standard correlation, it is determined that the corresponding two input parameters are both the first target parameters.
4. The method for automatically generating test code based on parameter correlation and combination constraints according to claim 3, characterized in that: Determining the second target parameter among all the first target parameters according to the preset combined constraint library includes: All first target parameters are screened according to the constraint conditions in the combined constraint library to obtain a number of second target parameters.
5. The method for automatically generating test codes based on parameter correlation and combination constraints according to claim 4, characterized in that: The executing of all test case sets and determining abnormal execution results according to all execution results and preset standard execution results includes: When each execution result is not a preset standard execution result, the execution result is determined to be an abnormal execution result.
6. The method for automatically generating test codes based on parameter correlation and combination constraints according to claim 5, characterized in that: The test code for generating the entire test case set based on the number of abnormal execution results and the preset number of standard abnormalities includes: When the number of abnormal execution results is less than the standard number of abnormalities, the test code of the entire test case set is directly generated according to the determination result.
7. The method for automatically generating test codes based on parameter correlation and combination constraints according to claim 6, characterized in that: When the number of abnormal execution results is greater than or equal to the number of standard abnormal results, the mean square error calculation formula is used to calculate the average of the square differences between the abnormal execution results and the standard execution results to obtain the difference degree.
8. The method for automatically generating test codes based on parameter correlation and combination constraints according to claim 7, characterized in that: When the difference is not within the tolerance range, the abnormal execution result is recorded and a prompt is issued.
Citation Information
Patent Citations
Test case generation method and test case generation device
CN108959056A
Method and apparatus for interface test
CN109032956A
Method and device for generating a combined test case, storage medium and computer equipment
CN109902002A
Test method, device and system, electronic equipment and medium
CN110347596A
Data interface testing method and device
CN115509941A
