Regression testing method and system, computer equipment and storage medium

By preprocessing and feature extraction of code change records, the risk identification model is used to analyze the basic test cases in the test case library, and the regression risk level is determined, which solves the problem of low efficiency of traditional regression testing and achieves efficient code change records Test and functional module coverage.

CN119201682APending Publication Date: 2024-12-27WUHAN CARBIT INFORMATION CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411154313.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Traditional regression testing methods are inefficient and cannot effectively deal with the test efficiency problems caused by the expansion of software scale and the increase in update frequency.

Method used

By obtaining code change records for data preprocessing and feature extraction, the risk identification model is used to analyze the basic test cases in the test case library, determine the regression risk level, and focus on executing test cases with higher regression risk level to improve testing efficiency.

Benefits of technology

It improves the testing efficiency of code change records, ensures coverage and verification of functional modules that are potentially affected, and improves testing efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201682A_ABST
    Figure CN119201682A_ABST
Patent Text Reader

Abstract

The invention relates to a regression testing method and system, computer equipment and a storage medium, and the method comprises the steps: obtaining a code change record, and carrying out the data preprocessing of the code change record; feature extraction is carried out on the code change records after data preprocessing, change features are obtained, and the change features at least comprise code elements and element relations; analyzing the change features and each basic test case in a test case library by using a risk identification model, and determining a regression risk level of each basic test case; determining a regression test case, wherein the regression test case comprises a basic test case of which the regression risk level is greater than or equal to a preset level threshold; and executing a regression test according to the regression test case. According to the invention, the test efficiency of code change records can be improved, and functional modules with relatively high regression risks are covered as much as possible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a regression testing method, system, computer equipment and storage medium. Background Art

[0002] Regression testing is an important part of software testing, and its purpose is to ensure that new code modifications do not introduce new errors. However, with the continuous expansion of software scale and the increase in update frequency, traditional regression testing methods usually execute all test cases once, resulting in low testing efficiency. Summary of the invention

[0003] Based on the above description, the present application provides a regression testing method, system, computer device and storage medium to solve the problem of low efficiency of current regression testing.

[0004] According to a first aspect, the present application provides a regression testing method, comprising:

[0005] Obtaining code change records, and performing data preprocessing on the code change records;

[0006] Extracting features from the code change records after data preprocessing to obtain change features, where the change features at least include code elements and element relationships;

[0007] Use the risk identification model to analyze the change characteristics and each basic test case in the test case library to determine the regression risk level of each basic test case;

[0008] Determine regression test cases, wherein the regression test cases include basic test cases whose regression risk level is greater than or equal to a preset level threshold;

[0009] Perform regression testing based on regression test cases.

[0010] In one or more embodiments, extracting features from the code change records after data preprocessing to obtain change features includes: using text analysis technology and symbol analysis technology to extract keywords and symbols from the code change records after data preprocessing to obtain change features.

[0011] In one or more embodiments, it also includes: obtaining the use case characteristics of each basic test case in the test case library; using the risk identification model to analyze the change characteristics and each basic test case in the test case library to determine the regression risk level of each basic test case, including: fusing the change characteristics with the use case characteristics of each basic test case respectively to analyze and predict the regression risk level of each basic test case.

[0012] In one or more embodiments, further comprising:

[0013] Acquire a historical sample set, wherein the historical sample set includes a plurality of historical change records and a plurality of historical test cases used by each historical change record and a plurality of corresponding historical test result data;

[0014] Extract features from each historical change record and the corresponding multiple historical test cases and multiple historical test result data to obtain corresponding historical change features, historical case features and test failure rates; and use the test failure rates as data labels;

[0015] Each historical change feature and the corresponding multiple historical use case features are used as input data of the initial model, and multiple data labels corresponding to the multiple historical use case features are used as output data of the initial model. The initial model is trained to obtain the risk identification model.

[0016] In one or more embodiments, further comprising:

[0017] Using a machine learning model to classify the change features to obtain a change scope, wherein the change scope includes function modules involved;

[0018] The basic test cases corresponding to the functional modules are modified and used as the regression test cases, wherein the basic test cases corresponding to the functional modules after modification cover the code snippets involved in the changes.

[0019] In one or more embodiments, it also includes: sorting the test order of multiple regression test cases, and the test order is: basic test cases corresponding to the functional modules involved after modification, and basic test cases with gradually reduced regression risk levels.

[0020] In one or more embodiments, the performing of regression testing includes: the performing of regression testing according to regression test cases includes: parsing the regression test cases using an automated testing tool, and performing regression testing according to the parsing results; and / or

[0021] The method also includes: visualizing and analyzing the regression test results using a data analysis tool.

[0022] According to a second aspect, the present application provides a regression testing system, comprising:

[0023] A data acquisition module is used to acquire code change records and perform data preprocessing on the code change records;

[0024] A feature extraction module is used to extract features from the code change records after data preprocessing to obtain change features, where the change features at least include code elements and element relationships;

[0025] The risk identification module is used to analyze the change characteristics and each basic test case in the test case library using the risk identification model to determine the regression risk level of each basic test case;

[0026] The regression test case determination module is used to determine regression test cases, wherein the regression test cases include basic test cases whose regression risk levels are greater than or equal to a preset level threshold.

[0027] The test execution module is used to execute regression testing according to regression test cases.

[0028] According to a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in any one of the above embodiments when executing the computer program.

[0029] According to a fourth aspect, the present application provides a storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of any one of the above-mentioned implementation methods are implemented.

[0030] Compared with the prior art, the technical solution of this application has the following beneficial technical effects:

[0031] This application obtains change features by performing data preprocessing and feature extraction on code change records, and uses a risk identification model to analyze the change features and each basic test case in the test case library to determine the regression risk level of each basic test case. Then, the basic test cases with a regression risk level greater than or equal to a preset level threshold are used as regression test cases. In this way, the basic test cases with a higher regression risk level are executed in a focused manner to verify the functional modules that are potentially more affected, thereby improving the testing efficiency for code change records and covering the functional modules with higher regression risks as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A flowchart of a regression testing method provided in an embodiment of the present application;

[0033] Figure 2 A schematic diagram of the principle of a regression testing system provided in an embodiment of the present application;

[0034] Figure 3 A schematic diagram of the principles of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0037] See also Figure 1 , Figure 1 A flow chart of a regression testing method provided in an embodiment of the present application is shown. A regression testing method provided in an embodiment of the present application comprises the following steps:

[0038] S11. Obtain code change records, and perform data preprocessing on the code change records.

[0039] In this embodiment, the code change record usually comes from a software version control system (such as Git), which contains information such as the code difference, author, and timestamp of each submission. Data preprocessing of the code change record includes: data cleaning of the code change record, removing irrelevant information (such as comments, space changes, etc.), and ensuring data consistency and accuracy.

[0040] S12. Extract features from the code change records after data preprocessing to obtain change features, where the change features at least include code elements and element relationships.

[0041] In some embodiments, text analysis technology and symbol analysis technology are used to extract keywords and symbols from the code change records after data preprocessing to obtain change features. Specifically, text analysis technology such as natural language processing technology is used to identify and extract keywords from the code change records. Specifically, the text is divided into words or phrases using word segmentation technology, and then various algorithms (such as TF-IDF, TextRank, etc.) are applied to calculate the importance of words, thereby extracting keywords to reflect the main content and change points of the code change record, which helps to understand the purpose and impact of the code change. Further, a code parsing library (such as Python's ast library) can be used to parse the code snippets in the code change record and extract symbolic information such as variable names and function names. In this embodiment, code elements include programming elements such as variable names, function names, classes, and interfaces. Element relationships are determined by integrating code elements and keywords.

[0042] S13. Use the risk identification model to analyze the change characteristics and each basic test case in the test case library to determine the regression risk level of each basic test case.

[0043] In some embodiments, the regression testing method of this embodiment further includes:

[0044] A historical sample set is obtained, where the historical sample set includes multiple historical change records and multiple historical test cases used by each historical change record and corresponding multiple historical test result data.

[0045] Specifically, during the test process, each execution of a historical test case will generate corresponding historical test result data, which includes the test execution time, test environment, test result (success / failure), and test error log data.

[0046] Furthermore, feature extraction is performed on each historical change record and the corresponding multiple historical test cases and multiple historical test result data to obtain the corresponding historical change features, historical case features and test failure rate; the test failure rate is used as a data label. Specifically, feature extraction is performed on each historical change record and the corresponding multiple historical test cases and multiple historical test result data through text analysis technology and symbolic analysis technology to obtain the corresponding historical change features, historical case features and test error features. Furthermore, the test error features are evaluated through a classifier to generate a test failure rate.

[0047] Furthermore, each historical change feature and the corresponding multiple historical use case features are used as input data of the initial model, and the multiple data labels corresponding to the multiple historical use case features are used as output data of the initial model. The initial model is trained to obtain a risk identification model. Specifically, the initial model can be a machine learning model or a deep learning model, such as a decision tree, a random forest, or a deep neural network. Furthermore, each historical change feature and the corresponding multiple historical use case features are input into the initial model, and the test failure rate of each historical test case is output, which is compared with the corresponding data label, and the loss value is calculated. The gradient is back-propagated according to the loss value, and the model parameters of the initial model are updated until the model converges to obtain a risk identification model.

[0048] In some embodiments, the regression testing method of the present application also includes: obtaining the use case characteristics of each basic test case in the test case library; using the risk identification model to analyze the change characteristics and each basic test case in the test case library to determine the regression risk level of each basic test case, including: fusing the change characteristics with the use case characteristics of each basic test case respectively to analyze and predict the regression risk level of each basic test case.

[0049] Specifically, text analysis technology and symbolic analysis technology are used to extract features from each basic test case, and the use case features of each basic test case are obtained and stored in the use case feature database, wherein the use case features represent the code path features covered by the basic test case. Furthermore, the change features and each use case feature are input into the risk identification model for fusion analysis to predict the regression risk level of each basic test case, which represents the potential test failure rate when executing the current basic test case. In this way, by combining the change features with each basic test case in the test case library for analysis, the potential regression risk level of each basic test case is determined, so as to focus on executing basic test cases with higher regression risk levels, verify the functional modules that are potentially more affected, improve the test efficiency for code change records, and try to cover functional modules with higher regression risks.

[0050] S14. Determine regression test cases, where the regression test cases include basic test cases whose regression risk level is greater than or equal to a preset level threshold.

[0051] In some embodiments, the regression testing method of the present application further includes:

[0052] The machine learning model is used to classify the change features and obtain the change scope, which includes the involved functional modules. The basic test cases corresponding to the involved functional modules are modified and used as regression test cases, wherein the basic test cases corresponding to the involved functional modules after modification cover the code snippets involved in the change.

[0053] Specifically, the machine learning model can use a classification algorithm or a clustering algorithm to classify the change features and obtain the change scope. The change scope includes the functional modules involved. The basic test cases corresponding to the functional modules involved are modified so that the basic test cases corresponding to the functional modules involved after modification cover the code snippets involved in the change. In this way, the code snippets corresponding to the code modification records can be covered by the test to verify whether the functions of the functional modules involved can be used normally.

[0054] In some embodiments, the regression testing method of the present application further includes:

[0055] The test order of multiple regression test cases is sorted, and the test order is: basic test cases corresponding to the functional modules involved after modification, and basic test cases with gradually lower regression risk levels. Specifically, first test the basic test cases corresponding to the functional modules involved after modification, and then test the basic test cases with gradually lower regression risk levels in sequence. According to such a test strategy, the test efficiency can be improved, and at the same time, it can quickly verify whether the code modification record introduces new problems.

[0056] S15. Execute regression testing according to regression test cases.

[0057] In some embodiments, the regression test cases are parsed using an automated testing tool, and regression testing is performed based on the parsing results.

[0058] Specifically, an integrated automated testing tool (such as Selenium, Appium) can be used to parse the regression test case. In a specific embodiment, the specific steps of executing the test process are as follows:

[0059] (1) Test environment preparation

[0060] Environmental configuration: Configure the corresponding test environment according to the requirements of the software under test, including operating system, database, middleware, etc. Environmental isolation: Ensure that the test environment is isolated from the production environment to avoid the impact of test activities on the production environment. Environmental stability: Maintain the stability of the test environment to ensure the reliability and repeatability of the test results.

[0061] (2) Test tool integration

[0062] Automated testing tool selection: According to the type and characteristics of the software being tested, select appropriate automated testing tools, such as Selenium (for Web application testing), Appium (for mobile application testing), JUnit / PyTest (for unit testing), etc. Tool configuration: Configure the selected automated testing tool, including setting the execution path of the test script, the input method of test data, the output format of the test results, etc. Integration interface: Develop or use existing interfaces to integrate the automated testing tool with the test execution module to realize the automatic scheduling and execution of regression test cases.

[0063] (3) Test case execution

[0064] Test case analysis: parse regression test cases to extract information such as test steps, test data, and expected results. Test script generation: automatically generate or call corresponding test scripts based on the parsed test case information. These scripts will simulate user operations to verify the software functions. Execution control: control the execution order and concurrency of test scripts to ensure the orderly progress of test activities. At the same time, monitor abnormal situations during the test process, such as test script execution failure, tested software crash, etc., and take corresponding treatment measures.

[0065] (4) Test result records

[0066] Real-time recording: During the test execution, real-time recording of test step execution, test data input and output, actual results and other information. Log management: Unified management of log information generated during the test process, including test logs, system logs, exception logs, etc. These log information are of great significance for subsequent problem analysis and troubleshooting.

[0067] (5)Exception handling and recovery

[0068] Abnormal detection: By monitoring abnormal signals (such as error codes, abnormal stacks, etc.) during the test execution, problems in the test process are discovered and reported in a timely manner. Automatic recovery: For certain foreseeable abnormal situations (such as network fluctuations, insufficient resources, etc.), set to try to automatically recover the test environment or test process to reduce manual intervention. Manual intervention: For abnormal situations that cannot be automatically recovered or problems that require manual judgment, set to provide clear error prompts and log information so that testers can quickly locate the problem and handle it.

[0069] Furthermore, data analysis tools (such as ELK Stack) are used to visualize and analyze the regression test results.

[0070] (1) Selection and configuration of data analysis tools

[0071] Select tools: According to the development team's technology stack and demand analysis, select suitable data analysis tools, such as ELKStack (Elasticsearch, Logstash, Kibana) combination, Tableau, Power BI, etc. These tools should have good data visualization, data mining and report generation capabilities. Configure the environment: Install and configure the selected data analysis tools to ensure that they are compatible with the data output format during the test execution process, and set a reasonable data storage and backup strategy.

[0072] (2) Collection and organization of test result data

[0073] Data collection: Obtain test result data, including the execution of test cases, input and output of test data, comparison of actual results with expected results, etc. Data collation: Clean, convert and collate the collected test result data to ensure data accuracy and consistency. This may include removing invalid data, merging duplicate data, converting data formats, etc.

[0074] (3) Test result analysis

[0075] Defect identification: Identify defects or problems in the software by comparing actual results with expected results. This usually involves detailed analysis of test logs, error reports and other information. Test coverage analysis: Evaluate the coverage of regression test cases to determine which code paths or functional points have been covered by the test and which have not been covered. This helps to discover potential test blind spots or omissions. Performance analysis: If the test involves performance evaluation, it is also necessary to analyze performance indicators such as the software's response time, throughput, and resource utilization to evaluate the software's performance. Trend analysis: Perform trend analysis on the results of multiple tests to observe the changing trend of software quality and provide a basis for subsequent test optimization and improvement.

[0076] (4) Generation and release of test reports

[0077] Report template design: Design the test report template according to the needs and habits of the team, including the report format, content structure, chart style, etc. Report generation: Use the functions of the data analysis tool to fill the analysis results into the test report template to generate a detailed test report. The report should include the test purpose, test environment, test scope, test method, test results, defect list, test conclusions and suggestions, etc. Report release: Release the generated test report to relevant personnel, such as project managers, developers, testers, etc. At the same time, notification and sharing can be carried out through email, project management tools, etc.

[0078] (5) Subsequent processing and feedback

[0079] Defect tracking: For defects or problems identified in the report, a tracking mechanism should be established to ensure that each defect is handled and verified in a timely manner. Optimization suggestions: Based on the analysis of test results, targeted optimization suggestions are put forward, such as improving test case design, optimizing test strategies, and improving code quality. Continuous improvement: Collect feedback from testers and developers, continuously optimize the functions and performance of the result analysis module, and improve test efficiency and accuracy.

[0080] In one embodiment, based on the same inventive concept, the present application also provides a regression testing system, which corresponds one-to-one to a regression testing method in the above embodiment. Figure 2 As shown, the regression testing system 200 includes a data acquisition module 210, a feature extraction module 220, a risk identification module 230, a regression case determination module 240 and a test execution module 250. The functional modules are described in detail as follows:

[0081] The data acquisition module 210 is used to acquire the code change record and perform data preprocessing on the code change record;

[0082] A feature extraction module 220 is used to extract features from the code change records after data preprocessing to obtain change features, where the change features at least include code elements and element relationships;

[0083] The risk identification module 230 is used to analyze the change characteristics and each basic test case in the test case library using the risk identification model to determine the regression risk level of each basic test case;

[0084] The regression test case generating module 240 is used to determine regression test cases, where the regression test cases include basic test cases whose regression risk levels are greater than or equal to a preset level threshold.

[0085] The test execution module 250 is used to execute regression testing according to regression test cases.

[0086] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3 As 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 such as code change records, test case libraries, risk identification models, etc. 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, the steps of a regression testing method in the above embodiment are implemented.

[0087] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of a regression testing method in the above embodiment are implemented.

[0088] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant 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 can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an 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 (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0089] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A regression testing method, characterized in that: include: Obtaining code change records, and performing data preprocessing on the code change records; Feature extraction is performed on the code change records after data preprocessing to obtain Change characteristics, the change characteristics at least including code elements and element relationships; Use the risk identification model to analyze the change characteristics and each basic test case in the test case library to determine the regression risk level of each basic test case; Determine regression test cases, wherein the regression test cases include basic test cases whose regression risk level is greater than or equal to a preset level threshold; Perform regression testing based on regression test cases.

2. The regression testing method according to claim 1, characterized in that: The feature extraction of the code change record after data preprocessing to obtain the change feature includes: using text analysis technology and symbol analysis technology to extract keywords and symbols from the code change record after data preprocessing to obtain the change feature.

3. The regression testing method according to claim 1, characterized in that: Also includes: Obtain the test case characteristics of each basic test case in the test case library; The risk identification model is used to analyze the change characteristics and each basic test case in the test case library to determine the regression risk level of each basic test case, including: fusing the change characteristics with the case characteristics of each basic test case to predict the regression risk level of each basic test case.

4. The regression testing method according to claim 1, characterized in that: Also includes: Acquire a historical sample set, wherein the historical sample set includes a plurality of historical change records and a plurality of historical test cases used by each historical change record and a plurality of corresponding historical test result data; Feature extraction is performed on each historical change record and the corresponding multiple historical test cases and multiple historical test result data to obtain the corresponding historical change features, historical case features and test failure rate; Using the test failure rate as a data label; Each historical change feature and the corresponding multiple historical use case features are used as input data of the initial model, and multiple data labels corresponding to the multiple historical use case features are used as output data of the initial model. The initial model is trained to obtain the risk identification model.

5. The regression testing method according to any one of claims 1 to 4, characterized in that: Also includes: Using a machine learning model to classify the change features to obtain a change scope, wherein the change scope includes function modules involved; The basic test cases corresponding to the functional modules are modified and used as the regression test cases, wherein the basic test cases corresponding to the functional modules after modification cover the code snippets involved in the changes.

6. The regression testing method according to claim 5, characterized in that: Also includes: The test order of the plurality of regression test cases is sorted, and the test order is: the basic test cases corresponding to the functional modules involved after the modification, and the basic test cases with gradually decreasing regression risk levels.

7. The regression testing method according to any one of claims 1 to 4, characterized in that: The performing regression test according to the regression test case includes: parsing the regression test case using an automated testing tool, and performing regression test according to the parsing result; and / or The method also includes: visualizing and analyzing the regression test results using a data analysis tool.

8. A regression testing system, characterized in that: include: A data acquisition module is used to acquire code change records and perform data preprocessing on the code change records; A feature extraction module is used to extract features from the code change records after data preprocessing to obtain change features, where the change features at least include code elements and element relationships; The risk identification module is used to analyze the change characteristics and each basic test case in the test case library using the risk identification model to determine the regression risk level of each basic test case; The regression test case determination module is used to determine regression test cases, wherein the regression test cases include basic test cases whose regression risk levels are greater than or equal to a preset level threshold. The test execution module is used to execute regression testing according to regression test cases.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: 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 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.

Citation Information

Cited By

  • Database test case generation method and device, server and storage medium

    CN120196555A

  • Database test case generation method, device, server and storage medium

    CN120196555B

  • Automatic software test case generation system and method based on artificial intelligence

    CN121070802A

  • An artificial intelligence-based software test case automatic generation system and method

    CN121070802B