Method and system for anti-tracking execution code details after test case execution

By repackaging the Python coverage library, the problem of positioning and solving test case failures in software testing is solved, and the rapid and accurate data collection and processing is achieved, which improves the efficiency of problem investigation and software quality.

CN119415429APending Publication Date: 2025-02-11SHANGHAI SHARETEK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411465961.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

In software testing, when positioning and solving the problem of test cases failures, it is difficult for the existing technology to quickly and accurately collect and process data, resulting in inefficient problem detection.

Method used

By repackaging the coverage library in python, obtaining test configuration, executing test cases, obtaining code coverage and test leaks, analyzing data changes in different execution stages, generating record files, and classifying processing to obtain test case execution After the reverse tracking of the execution code details.

Benefits of technology

It achieves rapid and accurate positioning and solving test case failure problems, improves software quality and development efficiency, and provides valuable reference for code optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415429A_ABST
    Figure CN119415429A_ABST
Patent Text Reader

Abstract

The invention discloses a method and system for anti-tracking execution code details after execution of a test case, and the method comprises the steps: S1, obtaining the test configuration of a configuration file based on the re-packaging of a python-cover library; s2, based on the test configuration, executing test cases and obtaining a test result of each case; s3, obtaining a code coverage rate and a test leakage point of the use case based on the test result, and summarizing the obtained code coverage rate and the test leakage point; s4, analyzing the data of different execution stages of the test case to obtain an initial change difference of the case, and generating a record file based on the initial change difference of the case; and S5, carrying out classification processing and formatting processing on the record file to obtain anti-tracking execution code details after the test case is executed, and sending the anti-tracking execution code details after the test case is executed to other terminals through mails.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of system function testing, and in particular to a method and system for tracing execution code details after a test case is executed. Background Art

[0002] With the continuous development of software technology, the importance of software testing and code management has become increasingly prominent. Testing can verify the correctness, reliability and stability of software. Test cases are the basic unit of testing, which describe the input and expected output for a specific function or scenario. However, when a test case fails, it becomes crucial to locate the root cause of the problem and perform appropriate data processing.

[0003] In periodic system testing, the execution process of test cases is recorded and tracked, the data generated during the execution of test cases is analyzed and processed, and reverse tracing and data processing are performed more effectively. Developers and testers need a method and system to help them quickly identify and solve the problem of test case failure. Data collection is too difficult, the data is complex, and collection is prone to errors, which are inevitable problems.

[0004] Therefore, how to locate and solve the problem of test case failure more quickly and accurately and improve software quality and development efficiency are key issues that technical personnel in this field need to pay attention to. Summary of the invention

[0005] In view of the above problems, the present invention provides a method for tracing execution code details after a test case is executed, the method comprising:

[0006] Step S1, repackage the coverage library in Python to obtain the test configuration of the configuration file;

[0007] Step S2: Based on the test configuration, execute the test cases and obtain the test results of each case;

[0008] Step S3, obtaining the code coverage and test leaks of the use case based on the test results, summarizing the obtained code coverage and test leaks, forming an execution benchmark for the use case executed for the first time and storing the execution data record, and storing the execution data record for the use case with an existing benchmark;

[0009] Step S4, parsing the data of different execution stages of the test case to obtain the change difference of the test case at different execution stages, and generating a record file based on the initial change difference of the test case;

[0010] Step S5: classify and format the record file to obtain the details of the anti-tracing execution code after the test case is executed, and send the details of the anti-tracing execution code after the test case is executed to other terminals via email.

[0011] Optionally, in step S1, after repackaging the coverage library in Python, the test configuration includes:

[0012] The time interval for the system to execute test cases, the test cases to be executed, the storage directory of the test files, and the terminal information for sending the test report.

[0013] Optionally, in step S2, the process of executing the test case and obtaining the test result of each test case based on the test configuration specifically includes:

[0014] Create a thread pool, use the run operation case of the coverage library in the thread, execute the test case, and obtain the test results of each case.

[0015] Optionally, the process of executing the test case specifically includes:

[0016] Use the library os to read the configuration file, and search for test cases that meet the configuration requirements from the configuration file. Use the run operation in the coverage library to execute the test cases that meet the configuration requirements, obtain the coverage file of the test cases and store it in the preset folder.

[0017] Optionally, in step S5, classifying and formatting the record file to obtain the anti-tracing execution code details after the test case is executed, and sending the anti-tracing execution code details after the test case is executed to other terminals via email specifically includes:

[0018] According to the path of the preset folder, extract all record files under the test configuration directory;

[0019] According to the configuration parameters of the repackaged OS library, the difference record data of different execution stages are extracted from each record file in turn and temporarily stored in the memory space;

[0020] The acquired data is compared one by one and the difference output is performed. The data obtained by the difference output is classified and summarized according to the test case, and the details of the reverse tracking execution code after the test case is executed are obtained;

[0021] After the test case is executed, the reverse tracking execution code details are sent to other terminals in the form of emails.

[0022] The present invention also discloses a system for tracking execution code details after a test case is executed, the system comprising: a test configuration acquisition module, a test result acquisition module, a case summarization module, a record generation module and a detail display module;

[0023] The test configuration acquisition module is used to repackage the coverage library in Python and obtain the test configuration of the configuration file;

[0024] The test result acquisition module is used to execute the test cases based on the test configuration and obtain the test result of each case;

[0025] The use case summarization module is used to obtain the code coverage and test loopholes of the use case based on the test results, and summarize the obtained code coverage and test loopholes, form an execution benchmark for the use case executed for the first time and store the execution data record, and store the execution data record for the use case execution with an existing benchmark;

[0026] The record generation module is used to parse the data of different execution stages of the test case, obtain the change difference of different execution stages of the test case, and generate a record file based on the initial change difference of the test case;

[0027] The detail display module is used to classify and format the record file, obtain the details of the reverse tracing execution code after the test case is executed, and send the details of the reverse tracing execution code after the test case is executed to other terminals via email.

[0028] Optionally, in the test configuration acquisition module, the test configuration includes:

[0029] The time interval for the system to execute test cases, the test cases to be executed, the storage directory of the test files, and the terminal information for sending the test report.

[0030] Optionally, the workflow of the test result acquisition module specifically includes:

[0031] Create a thread pool, use the run operation case of the coverage library in the thread, execute the test case, and obtain the test results of each case.

[0032] Optionally, in the test result acquisition module, the process of executing the test case specifically includes:

[0033] Use the library os to read the configuration file, and search for test cases that meet the configuration requirements from the configuration file. Use the run operation in the coverage library to execute the test cases that meet the configuration requirements, obtain the coverage file of the test cases and store it in the preset folder.

[0034] Optionally, the detail display module includes: a file extraction submodule, a packaging submodule, a difference summarization submodule and a detail forwarding submodule;

[0035] The file extraction submodule is used to extract all record files under the test configuration directory according to the path of the preset folder;

[0036] The encapsulation submodule is used to extract the difference record data of different execution stages from each record file in turn according to the configuration parameters of the re-encapsulated OS library, and temporarily store them in the memory space;

[0037] The difference summarization submodule is used to compare the acquired data one by one and then output the difference, classify and summarize the data obtained by the difference output according to the test case, and obtain the reverse tracking execution code details after the test case is executed;

[0038] The detail forwarding submodule is used to send the details of the reverse tracing execution code after the test case is executed to other terminals in the form of email.

[0039] Compared with the prior art, the present invention has the following beneficial effects:

[0040] The present invention discloses a method and a corresponding system for tracking detailed codes involved in the execution of test cases. The method repackages the functions based on the coverage library to realize the execution of specific test cases at predetermined time intervals; captures the code information related to the execution of the test cases; records the code coverage during the execution of each test case; compares the code coverage of the same test case at different execution stages; summarizes the test data, writes a report on the code coverage of the test cases, and sends the processed test report to relevant personnel. The system can realize the timed and quantitative execution of the completed test cases, record and summarize the execution of the test cases and the relevant code details. The application of the system enables testers and developers to determine the code coverage and test accuracy of the test cases at the lowest cost, improve the efficiency of troubleshooting in the software development process, and provide a more valuable reference for code optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0042] Figure 1 It is a flowchart of a method for anti-tracing execution code details according to an embodiment of the present invention;

[0043] Figure 2 It is a block diagram of the functional units of the anti-tracing execution code details system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0045] Embodiment 1

[0046] The present invention provides a method for tracking the execution code details after the test case is executed. Figure 1 As shown, the method includes:

[0047] Step S1: Repackage the coverage library in Python to obtain the test configuration of the configuration file.

[0048] Based on repackaging the original coverage library, it is enabled to obtain the test configuration of the configuration file, wherein the test configuration includes: repackaging the python-coverage library to obtain the test configuration set in the configuration file.

[0049] The repackaging of the python-coverage library specifically includes the following steps: reading the test configuration of the configuration file; using python to create a thread pool to implement multi-threaded operation; using the run operation case of the coverage library in the thread to batch execute the corresponding test cases, so that the coverage library batch executes multiple test cases through the run method.

[0050] The repackaged python-coverage library is configured with the following functions: execute tests periodically according to the settings; execute multiple test cases concurrently in batches; generate code coverage after the test cases are executed; list the number of code lines missed when executing the test cases; and save each test result in the form of a file.

[0051] In the above content, Covergae, a code coverage tool developed by Ned Batchelder, is a Python tool for measuring code coverage. It can help developers evaluate whether their test cases cover various parts of the code in order to determine the quality and stability of the code. The statistical information is relatively comprehensive. It can collect the code coverage situation and output a specific file, and perform statistical analysis of the data through the code logic design in Python. In the specific implementation, the test case execution can be executed through coverage to obtain the code coverage file, which records the code involved in the test case execution.

[0052] In the above content, based on system execution, coverage mainly records the following data: the total number of lines of code files involved in the test case; the total number of code lines not covered in the code files involved in the test case; the total coverage rate of the code files involved in the test case; the total number of lines of each file of the code involved in the test case; the total number of code lines not covered in each file of the code involved in the test case; the code coverage rate of each file of the code involved in the test case; the enumeration of the number of code lines not covered in each file of the code involved in the test case.

[0053] Step S2: Based on the test configuration, execute the test cases and obtain the test results of each case. Use run and os of the python-coverage library to read the configuration file, find the test cases that meet the configuration requirements, operate the test cases to be executed, and output the corresponding coverage files to the preset folder. In the present invention, the preset folder is the original record saving path set in the configuration file.

[0054] Step S3, obtaining the code coverage and test leaks of the use case based on the test results, summarizing the obtained code coverage and test leaks, forming an execution benchmark for the use case executed for the first time and storing the execution data record, and storing the execution data record for the use case with an existing benchmark;

[0055] Step S4, parse the data of different execution stages of the test case to obtain the change differences of the test case at different execution stages, and generate a record file based on the initial change differences of the test case; the different execution stages specifically include the first execution, the second execution, the third execution, etc.

[0056] The Python os library is repackaged so that the tool has the following functions: open the specified record file, extract the specified test data in the file, read the file data, and compare and extract the difference changes.

[0057] Step S5: classify and format the record file to obtain the details of the anti-tracing execution code after the test case is executed, and send the details of the anti-tracing execution code after the test case is executed to other terminals via email.

[0058] This step is implemented by using python to encapsulate a tool that can batch obtain and reassemble Excel data, which specifically includes the following steps: re-encapsulate the EIMEMultipart library of python so that the tool has the following functions: open the mail server, write the processed test report into the body of the mail, and send all kinds of data generated in the test to relevant personnel in the form of attachments. The input of the tool is: the body of the mail, the attachment directory to be sent, and the email address of the relevant personnel. The specific operations of implementing step 5 based on the tool include: S51, according to the test results, organize the cumbersome test results into easy-to-understand report language and edit it as the body of the mail; S52, according to the directory of the input test result file, extract all the test data one by one and make it into a compressed package; S53, add the compressed package file to the attachment of the current mail; S54, after editing the mail, execute the mail sending based on the pre-set personnel.

[0059] Embodiment 2

[0060] A system that tracks the details of executed code after a test case is executed, such as Figure 2 As shown, the system includes: a test configuration acquisition module, a test result acquisition module, a use case summarization module, a record generation module and a detail display module;

[0061] The test configuration acquisition module is used to repackage the coverage library in Python and obtain the test configuration of the configuration file; based on the repackaging of the original coverage library, it is able to obtain the test configuration of the configuration file, wherein the test configuration includes: - repackaging the coverage library to obtain the test configuration set in the configuration file.

[0062] Among them, the repackaging of the python-coverage library specifically includes the following steps: using the library os to read the test configuration of the configuration file; using python to create a thread pool to realize multi-threaded operation; using the run operation case of the coverage library in the thread to batch execute the corresponding test cases, so that the coverage library batch executes multiple test cases through the run method.

[0063] The repackaged python-coverage library is configured with the following functions: execute tests periodically according to the settings; execute multiple test cases concurrently in batches; generate code coverage after the test cases are executed; list the number of code lines missed when executing the test cases; and save each test result in the form of a file.

[0064] In the above content, Covergae, a code coverage tool developed by Ned Batchelder, is a Python tool for measuring code coverage. It can help developers evaluate whether their test cases cover various parts of the code in order to determine the quality and stability of the code. The statistical information is relatively comprehensive. It can collect the code coverage situation and output a specific file, and perform statistical analysis of the data through the code logic design in Python. In the specific implementation, the test case execution can be executed through coverage to obtain the code coverage file, which records the code involved in the test case execution.

[0065] In the above content, based on system execution, coverage mainly records the following data: the total number of lines of code files involved in the test case; the total number of code lines not covered in the code files involved in the test case; the total coverage rate of the code files involved in the test case; the total number of lines of each file of the code involved in the test case; the total number of code lines not covered in each file of the code involved in the test case; the code coverage rate of each file of the code involved in the test case; the enumeration of the number of code lines not covered in each file of the code involved in the test case.

[0066] The test result acquisition module is used to execute test cases based on the test configuration and obtain the test results of each case; use the run and os of the python-coverage library to read the configuration file, find the test cases that meet the configuration requirements, operate the test cases that need to be executed, and output the corresponding coverage files to the specified folder.

[0067] The use case summarizing module is used to obtain the code coverage and test leaks of the use case based on the test results, and summarize the obtained code coverage and test leaks.

[0068] The record generation module is used to parse the data of different execution stages of the test case, obtain the initial change difference of the case, and generate a record file based on the initial change difference of the case; repackage the Python os library so that the tool has the following functions: open the specified record file, extract the test data specified in the file, read the file data, and compare and extract the difference changes.

[0069] The detail display module is used to classify and format the record files, obtain the details of the anti-tracing execution code after the test case is executed, and send the details of the anti-tracing execution code after the test case is executed to other terminals via email. File extraction submodule, encapsulation submodule, difference summary submodule and detail forwarding submodule; the file extraction submodule is used to extract all record files under the test configuration directory according to the test configuration directory; the encapsulation submodule is used to extract the required data from each record file in turn according to the configuration parameters of a tool obtained by the function of the re-encapsulated os library, and temporarily store it in the memory space; the difference summary submodule is used to compare the acquired data one by one and output the difference, classify and summarize the data obtained by the difference output according to the test case, and obtain the details of the anti-tracing execution code after the test case is executed; the detail forwarding submodule is used to send the details of the anti-tracing execution code after the test case is executed to other terminals in the form of email.

[0070] This step is achieved by using python to encapsulate a tool that can batch obtain and reassemble Excel data. Specifically, it includes the following steps: re-encapsulate the EIMEMultipart library of python so that the tool has the following functions: open the mail server, write the processed test report into the body of the mail, and send all kinds of data generated in the test to relevant personnel as attachments. The input of the tool is: the body of the mail, the attachment directory to be sent, and the email address of the relevant personnel. The specific operations include: according to the test results, organize the cumbersome test results into easy-to-understand report language and edit it into the body of the mail; according to the directory of the input test result file, extract all the test data one by one and make it into a compressed package; add the compressed package file to the attachment of the current mail; after editing the mail, send the mail to the pre-set personnel.

[0071] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.

Claims

1. A method for tracing execution code details after a test case is executed, characterized in that: The method comprises: Step S1, repackage the coverage library in Python to obtain the test configuration of the configuration file; Step S2: Based on the test configuration, execute the test cases and obtain the test results of each case; Step S3, obtaining the code coverage and test leaks of the use case based on the test results, summarizing the obtained code coverage and test leaks, forming an execution benchmark for the use case executed for the first time and storing the execution data record, and storing the execution data record for the use case with an existing benchmark; Step S4, parsing the data of different execution stages of the test case to obtain the change difference of the test case at different execution stages, and generating a record file based on the initial change difference of the test case; Step S5: classify and format the record file to obtain the details of the anti-tracing execution code after the test case is executed, and send the details of the anti-tracing execution code after the test case is executed to other terminals via email.

2. The method for tracing execution code details after the test case is executed according to claim 1, characterized in that: In step S1, after repackaging the coverage library in Python, the test configuration includes: The time interval for the system to execute test cases, the test cases to be executed, the storage directory of the test files, and the terminal information for sending the test report.

3. The method for tracing execution code details after the test case is executed according to claim 1, characterized in that: In step S2, based on the test configuration, the process of executing the test case and obtaining the test result of each test case specifically includes: Create a thread pool, use the run operation case of the coverage library in the thread, execute the test case, and obtain the test results of each case.

4. The method for tracing execution code details after the test case is executed according to claim 1, characterized in that: The process of executing the test case specifically includes: Use the library os to read the configuration file, and search for test cases that meet the configuration requirements from the configuration file. Use the run operation in the coverage library to execute the test cases that meet the configuration requirements, obtain the coverage file of the test cases and store it in the preset folder.

5. The method for tracing execution code details after the test case is executed according to claim 4, characterized in that: In step S5, the record file is classified and formatted to obtain the details of the anti-tracing execution code after the test case is executed, and the details of the anti-tracing execution code after the test case is executed are sent to other terminals via email, which specifically includes: According to the path of the preset folder, extract all record files under the test configuration directory; According to the configuration parameters of the repackaged OS library, the difference record data of different execution stages are extracted from each record file in turn and temporarily stored in the memory space; The acquired data is compared one by one and the difference output is performed. The data obtained by the difference output is classified and summarized according to the test case, and the details of the reverse tracking execution code after the test case is executed are obtained; After the test case is executed, the reverse tracking execution code details are sent to other terminals in the form of emails.

6. A system for anti-tracing execution code details after a test case is executed, the system being used to implement the anti-tracing execution code details method according to any one of claims 1 to 5, characterized in that: The system includes: a test configuration acquisition module, a test result acquisition module, a use case summarization module, a record generation module and a detail display module; The test configuration acquisition module is used to repackage the coverage library in Python and obtain the test configuration of the configuration file; The test result acquisition module is used to execute the test cases based on the test configuration and obtain the test result of each case; The use case summarization module is used to obtain the code coverage and test loopholes of the use case based on the test results, and summarize the obtained code coverage and test loopholes, form an execution benchmark for the use case executed for the first time and store the execution data record, and store the execution data record for the use case execution with an existing benchmark; The record generation module is used to parse the data of different execution stages of the test case, obtain the change difference of different execution stages of the test case, and generate a record file based on the initial change difference of the test case; The detail display module is used to classify and format the record file, obtain the details of the reverse tracing execution code after the test case is executed, and send the details of the reverse tracing execution code after the test case is executed to other terminals via email.

7. The system for tracing execution code details after the test case is executed according to claim 6, characterized in that: In the test configuration acquisition module, the test configuration includes: The time interval for the system to execute test cases, the test cases to be executed, the storage directory of the test files, and the terminal information for sending the test report.

8. The system for tracing execution code details after the test case is executed according to claim 6, characterized in that: The workflow of the test result acquisition module specifically includes: Create a thread pool, use the run operation case of the coverage library in the thread, execute the test case, and obtain the test results of each case.

9. The system for tracing execution code details after the test case is executed according to claim 6, characterized in that: In the test result acquisition module, the process of executing the test case specifically includes: Use the library os to read the configuration file, and search for test cases that meet the configuration requirements from the configuration file. Use the run operation in the coverage library to execute the test cases that meet the configuration requirements, obtain the coverage file of the test cases and store it in the preset folder.

10. The system for tracing execution code details after the test case is executed according to claim 6, characterized in that: The detail display module includes: a file extraction submodule, a packaging submodule, a difference summarization submodule and a detail forwarding submodule; The file extraction submodule is used to extract all record files under the test configuration directory according to the path of the preset folder; The encapsulation submodule is used to extract the difference record data of different execution stages from each record file in turn according to the configuration parameters of the re-encapsulated OS library, and temporarily store them in the memory space; The difference summarization submodule is used to compare the acquired data one by one and then output the difference, classify and summarize the data obtained by the difference output according to the test case, and obtain the reverse tracking execution code details after the test case is executed; The detail forwarding submodule is used to send the details of the reverse tracing execution code after the test case is executed to other terminals in the form of email.