A testing method, electronic device, and medium
By dynamically adjusting the bidirectional mapping relationship between code segments and test cases, the problem of inaccurate mapping in traditional testing methods is solved, resulting in more efficient and accurate test result output and providing complete test result backtracking data.
Patent Information
- Application Number
- CN202511114457.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-08-11
AI Technical Summary
In traditional testing methods, the mapping between test cases and code segments is inaccurate, leading to inaccurate test results and affecting the scope and efficiency of testing, especially in scenarios where the code changes frequently and accurate results cannot be obtained.
By dynamically adjusting the bidirectional mapping relationship between code segments and test cases, updating the mapping relationship in real time, determining matching objects based on the association characteristics of code segments and test cases, forming a target mapping relationship, executing test cases, and outputting test results.
It improves the accuracy and efficiency of testing methods, ensures comprehensive coverage and accurate testing when code changes occur, and builds a multi-dimensional mapping library to provide backtracking data for test results.
Smart Images

Figure CN120610902B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more particularly to a testing method, electronic device, and medium. Background Technology
[0002] Test cases are an effective means of verifying the functionality and performance of code. By executing test cases and analyzing the test results, code defects can be located.
[0003] Traditional testing methods typically divide code into multiple independent code segments based on function or module. For each code segment, test cases are designed, consisting of different inputs, coverage boundaries, and other test items. The mapping relationship between test cases and code segments is marked through comments or configuration files. Test cases are then loaded and run according to the mapping relationship, and the corresponding test results are output. This testing method has been widely used in scenarios such as financial risk control, e-commerce inventory management, and medical diagnosis.
[0004] However, traditional testing methods suffer from a mismatch between test cases and code segments, which in turn interferes with test results. Summary of the Invention
[0005] This invention aims to address, to a certain extent, one of the technical problems in related technologies. To this end, this invention provides a testing method, an electronic device for executing the testing method, and a computer-readable medium, which has advantages such as automatically updating the mapping relationship between test cases and code segments, improving test coverage, and increasing test accuracy.
[0006] To achieve the above objectives, as a first aspect of the present invention, a testing method is provided, wherein the method includes:
[0007] Obtain the initial mapping relationship between multiple code segments under test and multiple test cases, wherein the code segments under test and the test cases are objects of the initial mapping relationship;
[0008] If it is determined that the initial mapping relationship has been broken, an object that can be matched with the object that broke the initial mapping relationship is configured to form an updated target mapping relationship;
[0009] Execute the test cases in the target mapping relationship and output the test results.
[0010] Optionally, the test method further includes:
[0011] Periodically check the markers of each code segment under test;
[0012] If there are unlabeled code segments under test, it is determined that the initial mapping relationship has been broken;
[0013] The step of configuring a matching object for the object that disrupts the initial mapping relationship to form an updated target mapping relationship includes:
[0014] Configure matching test cases for untagged code segments under test.
[0015] Optionally, the method further includes:
[0016] If a change to the code segment is detected, it is determined that the initial mapping relationship has been broken;
[0017] The step of configuring a matching object for the object that disrupts the initial mapping relationship to form an updated target mapping relationship includes:
[0018] Identify the code segment associated with the code segment that has been modified;
[0019] Based on the initial mapping relationship, determine the test cases matching the modified code segment; and the test cases matching the associated code segment;
[0020] The initial mapping is updated based on the modified code segment and its matching test case, as well as the associated code segment and its matching test case, to form the updated target mapping.
[0021] Optionally, determining the code segment associated with the modified code segment includes:
[0022] Extract the feature information of the modified code segment and the feature information of the code segment before the modification;
[0023] The code change factor is obtained by comparing the feature information of the modified code segment with the feature information of the code segment before the modification.
[0024] If the code change factor is within a preset code change range, the code segment associated with the changed code segment is determined within the code change range.
[0025] Optionally, changes to the code segment include adding a code segment, modifying a code segment, and deleting a code segment.
[0026] Optionally, the method further includes:
[0027] If a change to a test case is detected, it is determined that the initial mapping relationship has been disrupted.
[0028] The step of configuring a matching object for the object that disrupts the initial mapping relationship to form an updated target mapping relationship includes:
[0029] Identify the test cases associated with the changed test cases;
[0030] Based on the initial mapping relationship, determine the code segment matching the changed test case; and the code segment matching the associated test case;
[0031] The initial mapping is updated based on the changed test cases and their matching code segments, as well as the associated test cases and their matching code segments, to form the updated target mapping.
[0032] Optionally, the changes to the test cases include adding test cases, modifying test cases, and deleting test cases.
[0033] Optionally, executing the test cases in the target mapping relationship and outputting the test results includes:
[0034] Obtain the execution process data of the test cases in the target mapping relationship;
[0035] Update the execution process data to the attribute information of the target mapping relationship;
[0036] Output the test results.
[0037] As a second aspect of the present invention, an electronic device is provided, comprising:
[0038] One or more processors;
[0039] A memory having stored one or more computer programs that, when executed by one or more processors, cause the one or more processors to implement the test method provided according to the first aspect of the invention.
[0040] Furthermore, as a third aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the testing method provided in the first aspect of the present invention.
[0041] The testing method provided by this invention first obtains the initial mapping relationship between multiple code segments and multiple test cases. If the initial mapping relationship is determined to be broken, a matching object is configured for the object that broke the initial mapping relationship to form an updated target mapping relationship. Then, the test cases in the target mapping relationship are executed, and the test results are output. When a code segment changes, the code segment in the initial mapping relationship is used as a reference object. The associated code segment is determined based on the association characteristics between the initial mapping relationship and the code segment (such as call relationships and dependency chains), and then the corresponding test case is determined based on the associated code segment and the initial mapping relationship. When a test case changes, the associated test case is determined based on the association characteristics between the test cases (such as coverage logic and input parameters), and then the corresponding code segment is determined based on the associated test case and the initial mapping relationship. When neither the code segment nor the test case changes, the method performs a self-check on the initial mapping relationship by periodically checking the markings of each tested code segment. When an unmarked code segment is detected, a matching test case is configured for the unmarked code segment. All three implementation methods are used to form the updated target mapping relationship. In addition, during the execution of test cases for the target mapping relationship, the execution process data (such as code execution location and test environment information) of the test cases for the target mapping relationship are obtained and updated to the attribute information of the target mapping relationship. The final output test results include code coverage.
[0042] The testing method provided by this invention solves the problems of inaccurate mapping between test cases and code segments caused by frequent code changes, such as test case failure / missed tests and test case compatibility ignoring verification code due to frequent changes, by dynamically adjusting the bidirectional mapping relationship between code segments and test cases. This not only improves the testing scope of the entire testing method, but also improves the accuracy and efficiency of the testing method. In addition, by constructing and updating a multi-dimensional mapping library (attribute information of the mapping relationship) of test cases, code segments and test environment information, complete backtracking data is provided for test result backtracking.
[0043] These features and advantages of the present invention will be disclosed in detail in the following specific embodiments and accompanying drawings. The preferred embodiments or means of the present invention will be shown in detail in conjunction with the accompanying drawings, but are not intended to limit the technical solutions of the present invention. In addition, each of these features, elements and components appearing in the following text and drawings is a plurality of, and different symbols or numbers are used for convenience of representation, but all represent parts with the same or similar construction or function. Attached Figure Description
[0044] The present invention will be further described below with reference to the accompanying drawings:
[0045] Figure 1 A flowchart of a testing method provided by the present invention;
[0046] Figure 2 A flowchart illustrating another implementation of the testing method provided by the present invention;
[0047] Figure 3 A flowchart illustrating one embodiment of step S120 of the testing method provided by the present invention;
[0048] Figure 4 A flowchart illustrating one embodiment of step S122 of the testing method provided by the present invention;
[0049] Figure 5 A flowchart illustrating another embodiment of step S120 of the testing method provided by the present invention;
[0050] Figure 6 A flowchart of one embodiment of step S130 of the test method provided by the present invention;
[0051] Figure 7 This is a schematic diagram illustrating the mutual calls between code segments in the testing method provided by this invention.
[0052] Figure 8 A schematic diagram illustrating a mapping relationship between test method code segments and test cases provided by the present invention;
[0053] Figure 9 A module diagram of an electronic device provided by the present invention;
[0054] Figure 10 This invention provides a schematic diagram of a computer-readable medium.
[0055] Explanation of reference numerals in the attached figures
[0056] Among them, 101 is the processor; 102 is the memory; 103 is the I / O interface; and 104 is the bus. Detailed Implementation
[0057] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described are intended to explain the present invention and should not be construed as limiting the invention.
[0058] The terms "an embodiment," "example," or "trademark" used in this specification refer to a particular feature, structure, or characteristic described in connection with the embodiment itself that may be included in at least one embodiment disclosed in this invention. The phrase "in an embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment.
[0059] Traditional testing methods rely on pre-establishing static associations between code segments and test cases using tools, and then verifying the functionality and performance of the code segments by executing the test cases. However, this method heavily depends on the accuracy of the association. Using tools to complete the association process can result in missing associations, leading to incomplete initial mappings. Furthermore, if the code segment changes after the association process is complete, the corresponding test cases need to be re-annotated, causing a delay in test case updates. Alternatively, the code segment may not be adjusted in a timely manner to reflect changes in test cases. All of these issues can lead to inaccurate mappings between test cases and code segments, resulting in incomplete test scope and low test accuracy. Similarly, in development scenarios with frequent requirement changes or a surge in customized / differentiated projects, traditional testing methods not only fail to obtain accurate test results but also impact project development progress.
[0060] In view of this, in order to solve the problem of inaccurate mapping between code segments and test cases in traditional testing methods, as a first aspect of the present invention, a testing method is provided, such as... Figure 1 As shown, the test method includes:
[0061] In step S110, an initial mapping relationship is obtained between multiple code segments under test and multiple test cases, wherein the code segments under test and the test cases are objects of the initial mapping relationship;
[0062] In step S120, if it is determined that the initial mapping relationship has been destroyed, an object that can match the object that destroyed the initial mapping relationship is configured to form an updated target mapping relationship;
[0063] In step S130, the test cases in the target mapping relationship are executed, and the test results are output.
[0064] The testing method provided by this invention first obtains the initial mapping relationship between multiple code segments and multiple test cases. If the initial mapping relationship is determined to be broken, a matching object is configured for the object that broke the initial mapping relationship to form an updated target mapping relationship. Then, the test cases in the target mapping relationship are executed, and the test results are output. When a code segment changes, the code segment in the initial mapping relationship is used as a reference object. The associated code segment is determined based on the association characteristics between the initial mapping relationship and the code segment (such as call relationships and dependency chains), and then the corresponding test case is determined based on the associated code segment and the initial mapping relationship. When a test case changes, the associated test case is determined based on the association characteristics between the test cases (such as coverage logic and input parameters), and then the corresponding code segment is determined based on the associated test case and the initial mapping relationship. When neither the code segment nor the test case changes, the method performs a self-check on the initial mapping relationship by periodically checking the markings of each tested code segment. When an unmarked code segment is detected, a matching test case is configured for the unmarked code segment. All three implementation methods are used to form the updated target mapping relationship. In addition, during the execution of test cases for the target mapping relationship, the execution process data (such as code execution location and test environment information) of the test cases for the target mapping relationship are obtained and updated to the attribute information of the target mapping relationship. The final output test results include code coverage.
[0065] The testing method provided by this invention solves the problems of inaccurate mapping between test cases and code segments caused by frequent code changes, such as test case failure / missed tests and test case compatibility ignoring verification code due to frequent changes, by dynamically adjusting the bidirectional mapping relationship between code segments and test cases. This not only improves the testing scope of the entire testing method, but also improves the accuracy and efficiency of the testing method. In addition, by constructing and updating a multi-dimensional mapping library (attribute information of the mapping relationship) of test cases, code segments and test environment information, complete backtracking data is provided for test result backtracking.
[0066] The initial mapping relationships are obtained manually. First, code segments are marked with annotations (such as @TestScenario) to associate them with business scenarios; then, the annotations are parsed to generate the mapping relationship between test cases and code segments. Annotations can define multiple dimensions. For example, in the field of cross-border payments, annotations can include business dimensions (including the module, transaction type, and business scenario), technical dimensions (including related channels, terminal type, and data structure), and quality dimensions (including test level, risk level, and defect type). For example, a test case can be tagged with custom annotations such as [Module][Related Channel][Transaction Type][Card Type][Transaction Currency][Transaction Status], which would be [Transaction Module][Citibank Channel][Authorized Transaction][Physical Credit Card][USD][Authorization Failed]. Unique identifiers of test cases can also be used as tags.
[0067] The mapping relationships mentioned above include forward mapping (mapping corresponding test cases based on code changes) and reverse mapping (mapping corresponding code segments based on test case changes). In practical application scenarios, the code segments implementing various functional modules are not independent. Therefore, there are relationships between code segments (e.g., code segment A calls code segment B, and code segments D, E, and F are on a dependency chain and together constitute a functional module). Test cases are also not independent; for example, test cases A and B share common input parameters, and test cases C and D need to be executed in sequence. Inevitably, since the annotations are defined manually, the obtained initial mapping relationships may contain defaults, such as isolated test cases (i.e., test cases do not have corresponding executable code segments) or isolated code segments (i.e., code segments do not have corresponding test cases to verify their functionality and performance). To avoid this problem of inaccurate initial mapping relationships, the testing method provided by this invention can initiate self-checking even when no code change information or test case change information is detected, to update the initial mapping relationships and obtain the target test cases. The self-checking method is executed periodically, as an optional implementation method, such as... Figure 2 As shown, the method further includes:
[0068] In step S110, an initial mapping relationship is obtained between multiple code segments under test and multiple test cases, wherein the code segments under test and the test cases are objects of the initial mapping relationship;
[0069] In step S120, the markers of each code segment under test are periodically checked;
[0070] In step S130, if there is an unlabeled code segment under test, it is determined that the initial mapping relationship has been destroyed;
[0071] In step S140, matching test cases are configured for the unmarked code segment under test.
[0072] It should be noted that the self-checking method is executed periodically, and the corresponding self-checking cycle can be set according to actual testing requirements. In scenarios requiring frequent checks, the self-checking cycle can be set to 10 seconds, 30 seconds, or 60 seconds. In scenarios where infrequent checks are not required, the self-checking cycle can be set to 5 minutes, 8 minutes, or 10 minutes.
[0073] The bidirectional initial mapping relationship between code segments and test cases proposed in this invention can also be initiated upon receiving a change. First, the forward mapping relationship is described in detail. When a change in a code segment is detected, the forward mapping relationship is adjusted. As another implementation of step S120, such as... Figure 3 As shown, the method further includes:
[0074] In step S121, if a change in the code segment is detected, it is determined that the initial mapping relationship has been destroyed;
[0075] In step S122, the code segment associated with the modified code segment is determined;
[0076] In step S123, test cases matching the modified code segment and their associated test cases are determined based on the initial mapping relationship.
[0077] In step S124, the initial mapping relationship is updated based on the modified code segment and its matching test case, as well as the associated code segment and its matching test case, to form the updated target mapping relationship.
[0078] It should be noted that code segments are necessarily related. A code segment is not strictly speaking a division of all the code in the test method according to a certain method. It only represents a certain range of the complete code, and this range is associated with test cases. For example, lines 100 to 500 in the complete code (code segment) correspond to test cases for a certain scenario.
[0079] Detecting code segment changes can be achieved not only through existing version control systems such as the distributed version control system Git and the centralized version control system (SVN, Subversion) by directly determining the changes through operation log parameters, but also by periodically comparing the current code with saved historical code snapshots. Detection and identification algorithms can then be used to determine whether the code content has changed and the type of change, such as adding, modifying, or deleting code. Code changes include, but are not limited to, adding code segments, adding content to specific code segments, modifying content to specific code segments, deleting code segments, and deleting content from specific code segments.
[0080] When a code segment change is detected, due to the call-and-invoke relationships between code segments (i.e., the output of code segment A is the input of code segment B, and the output of code segment B is the input of code segment A), all associated code segments in the entire code can be identified based on these relationships. All detected associated code segments (including the changed code segment) are then sequentially mapped using initial mapping relationships to determine their respective matching test cases. It should be noted that the matched test cases can be a test case set composed of multiple test cases. This testing method ensures that the functionality and performance of all associated code segments are tested when a code segment changes, thereby improving the accuracy and coverage of the testing method.
[0081] To avoid the impact of redundant code segments on test results and further improve the accuracy and timeliness of the testing method, as an optional implementation of step S122, such as... Figure 4 As shown, determining the code segment associated with the modified code segment includes:
[0082] In step S122a, the feature information of the modified code segment and the feature information of the code segment before the modification are extracted;
[0083] In step S122b, the feature information of the modified code segment is compared with the feature information of the code segment before the modification to obtain the code change factor;
[0084] In step S122c, if the code change factor is within a preset code change range, the code segment associated with the changed code segment is determined within the code change range.
[0085] Steps S122a-S122c above aim to define a preset code change range before identifying all associated code segments, thus avoiding the association with redundant or invalid code segments. The characteristic information of a code segment includes, but is not limited to, code name, class name, line number, code annotations, and one or a combination of functions. The code change factor reflects the amount of change before and after the code change; when the amount of change (code change factor) is large, the preset code change range is large; when the amount of change (code change factor) is small, the preset code change range is small.
[0086] Similarly, the above method of determining test cases based on code changes and initial mapping relationships is an incremental testing method. It only determines the corresponding test cases for the changed content and verifies the functionality and performance of the changed code by executing the corresponding test cases. This incremental testing method solves the problems of test redundancy and long test cycles that occur in the traditional full-scale testing (executing all test cases).
[0087] The initial mapping relationship includes not only the association between code segments, but also the association between test cases (e.g., test cases have the same parameters, test case A covers test case B). When a change in a test case is detected, the reverse mapping relationship is adjusted. As another implementation of step S120, such as... Figure 5 As shown, the method further includes:
[0088] In step S121, if a change in the test case is detected, it is determined that the initial mapping relationship has been destroyed;
[0089] In step S122, the test cases associated with the changed test cases are identified;
[0090] In step S123, the code segment matching the changed test case and its associated code segment matching the test case are determined according to the initial mapping relationship.
[0091] In step S124, the initial mapping relationship is updated based on the changed test cases and their matching code segments, as well as the associated test cases and their matching code segments, to form the updated target mapping relationship.
[0092] To improve the accuracy of testing methods and prevent missed tests, steps S121-S124 above explain that when test cases change, their associated test cases are re-determined based on the changed test cases to re-verify the functionality and performance of the code segment. It should be noted that the changed test cases may be a single test case or multiple test cases. Due to the relationships between test cases, the test cases associated with the changed test cases may be a single test case or multiple test cases. Changes to test cases include, but are not limited to, adding, modifying, and deleting test cases. These additions, modifications, and deletions include, but are not limited to, performing the above operations on the input parameters of the test cases. For example, Test1(a, b) indicates that the input parameters of test case Test1 are a and b. When the input parameters of Test1(a, b) are added to Test1(a, b, c), it indicates that a new input parameter is added (a new test case is added); when the input parameters of Test1(a, b) are changed to Test1(a', b), it indicates that the input parameters are modified (the test case is modified); when the input parameters of Test1(a, b) are deleted to Test1(a), it indicates that the input parameter is deleted; when the entire test case Test1 is deleted, it indicates that the test case is deleted.
[0093] In determining the target test cases, considering the timeliness of the testing methods and the utilization of computing resources, all related test cases of the changed test cases will be processed to obtain the target test cases within a precise range. Similarly, determining related test cases can include the following methods: increasing the number of related test cases when adding new test cases, and decreasing the number of related test cases when deleting test cases.
[0094] To elaborate further on steps S121-S124 above, firstly, based on the relationships between test cases (such as coverage logic and associated input parameters), all associated test cases of the changed test case are determined. This secondary screening of associated test cases is not performed sequentially, nor is it limited to a single selection; it depends on the method of test case modification. When a new input parameter is detected, it's necessary to test as many test cases as possible to verify the impact of the new input parameter on the test results from multiple perspectives. Therefore, associated test cases need to be added, and the added associated test cases and the test cases with configuration parameter changes are used together as target test cases. When a deleted input parameter is detected, considering that the deleted input parameter has a low contribution to the test method, some associated test cases can be deleted. The deleted associated test cases and the test cases with configuration parameter changes are used together as target test cases, ensuring both the coverage of the test method and improving testing efficiency. Furthermore, when only the input parameter is modified, since the code segment corresponding to the test case has already been verified, the associated test cases before the test case with configuration parameter changes are reused.
[0095] After the test cases are determined, the updated target mapping relationship can be obtained by monitoring the execution of the test cases, and the test results can be output. As an optional implementation of step S130, such as... Figure 6 As shown, executing the test cases in the target mapping relationship and outputting the test results includes:
[0096] In step S131, the execution process data of the test cases in the target mapping relationship is obtained;
[0097] In step S132, the execution process data is updated to the attribute information of the target mapping relationship;
[0098] In step S133, the test results are output.
[0099] The execution process data also includes code location information and test environment information. Methods for obtaining the corresponding code location (including but not limited to line number, start coordinate, and end coordinate) during the execution of the target test case include, but are not limited to, JaCoCo bytecode instrumentation technology. Bytecode instrumentation can be used to track the number of lines of code executed. Based on the code location of the test case during execution, the relationship between the code location (including code segment) and the test case is obtained, and this relationship is updated to the mapping relationship. After the test case execution is completed, all mapping relationships to be updated are completed. For example, if a test case with the tags [Transaction Module][Citibank Channel][Authorized Transaction][Physical Credit Card][USD][Authorization Failure] is executed, and the JaCoCo-colored code segment is A, then the mapping relationship A-[Transaction Module][Citibank Channel][Authorized Transaction][Physical Credit Card][USD][Authorization Failure] is saved and updated. During execution, the coloring model can also be used to color the executed code segments, improving testers' awareness of the testing process. It is necessary to provide a detailed description of the output test results, which include, but are not limited to, test case identification information and code coverage data.
[0100] Test environment information includes, but is not limited to, test code version information, test device name, test platform information, and test logs. To better track test results and reproduce them, or to identify and analyze the causes of specific performance metrics, the aforementioned test environment information needs to be stored in the attribute information of the mapping relationship after updating the mapping relationship between test cases and code segments. As an optional implementation, a multi-dimensional mapping library of test cases, code segments, and test environment information can be constructed using knowledge graphs or graph data.
[0101] The above shows that, in addition to starting execution when a change is detected, the entire method can also periodically check whether there is a mapping misalignment problem in the mapping relationship. When a mapping misalignment problem exists, the mapping relationship is updated based on the execution result.
[0102] The testing method provided by this invention solves the problems of inaccurate mapping between test cases and code segments caused by frequent code changes, such as test case failure / missed tests and test case compatibility ignoring verification code due to frequent changes, by dynamically adjusting the bidirectional mapping relationship between code segments and test cases. This not only improves the testing scope of the entire testing method, but also improves the accuracy and efficiency of the testing method. In addition, by constructing and updating a multi-dimensional mapping library (attribute information of the mapping relationship) of test cases, code segments and test environment information, complete backtracking data is provided for test result backtracking. Figure 7A diagram illustrating mutual calls between code segments is provided, where the output of code segment A is the input of code segments B and C; the input of code segment C depends on the outputs of code segments A and D. Figure 8 A schematic diagram of the mapping relationship between code segments and test cases is provided. The relationship between code segments and test cases is not one-to-one. There may be cases where one code segment requires two test cases or one test case can be used to test two code segments.
[0103] As a second aspect of the present invention, an electronic device is provided, such as... Figure 9 As shown, it includes:
[0104] One or more processors 101;
[0105] The memory 102 stores one or more computer programs that, when executed by the one or more processors 101, cause the one or more processors 101 to implement the test method provided according to the first aspect of the invention.
[0106] The tool may also include one or more I / O interfaces 103 connected between the processor 101 and the memory 102, configured to enable information interaction between the processor 101 and the memory 102.
[0107] The processor 101 is a device with data processing capabilities, including but not limited to a central processing unit 101 (CPU); the first memory 102 is a device with data storage capabilities, including but not limited to random access memory 102 (RAM, more specifically SDRAM, DDR, etc.), read-only memory 102 (ROM), electrically erasable programmable read-only memory 102 (EEPROM), and flash memory (FLASH); the I / O interface 103 (read-write interface) is connected between the processor 101 and the memory 102, enabling information interaction between the processor 101 and the memory 102, including but not limited to a data bus 104 (Bus).
[0108] In some embodiments, the processor 101, memory 102, and I / O interface 103 are interconnected via bus 104, and thus connected to other components of the computing device.
[0109] Furthermore, as a third aspect of the present invention, a computer-readable medium is also provided having a computer program stored thereon, such as... Figure 10 As shown, when the computer program is executed by the processor, it implements the credit testing method provided in the first aspect of the present invention.
[0110] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. Accordingly, the computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can implement the methods of any of the above embodiments. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0111] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Those skilled in the art should understand that the present invention includes, but is not limited to, the contents described in the accompanying drawings and the specific embodiments above. Any modifications that do not depart from the functional and structural principles of the present invention will be included within the scope of the claims.
Claims
1. A testing method, characterized in that, The testing method includes: Obtain the initial mapping relationship between multiple code segments under test and multiple test cases, wherein the code segments under test and the test cases are objects of the initial mapping relationship; If it is determined that the initial mapping relationship has been broken, an object that can be matched with the object that broke the initial mapping relationship is configured to form an updated target mapping relationship; Execute the test cases in the target mapping relationship and output the test results; If a change to the code segment is detected, it is determined that the initial mapping relationship has been broken; The step of configuring a matching object for the object that disrupts the initial mapping relationship to form an updated target mapping relationship includes: Identify the code segment associated with the code segment that has been modified; Based on the initial mapping relationship, determine the test cases matching the modified code segment; and the test cases matching the associated code segment; The initial mapping is updated based on the modified code segment and its matching test case, as well as the associated code segment and its matching test case, to form the updated target mapping. The determination of the code segment associated with the modified code segment includes: Extract the feature information of the modified code segment and the feature information of the code segment before the modification; The code change factor is obtained by comparing the feature information of the modified code segment with the feature information of the code segment before the modification; wherein, the code change factor reflects the amount of change before and after the code modification. If the code change factor is within a preset code change range, the code segment associated with the changed code segment is determined within the code change range. If a change to a test case is detected, it is determined that the initial mapping relationship has been disrupted. The step of configuring a matching object for the object that disrupts the initial mapping relationship to form an updated target mapping relationship includes: Identify the test cases associated with the changed test case; the association between test cases includes test cases with the same input parameters and test cases whose input parameters are overridden by input parameters of other test cases; determine all associated test cases based on the association; filter all identified associated test cases according to the change method of the test case; if a new input parameter for a test case is detected, add associated test cases, and use the added associated test cases and the test case with the new input parameter together as the target test case; if a test case's input parameter is detected to be deleted, delete some associated test cases, and use the deleted associated test cases and the test case with the deleted input parameter together as the target test case; if only the input parameter of a test case is modified, reuse the associated test cases before the test case with the modified input parameter. Based on the initial mapping relationship, determine the code segment matching the changed test case; and the code segment matching the associated test case; The initial mapping is updated based on the changed test cases and their matching code segments, as well as the associated test cases and their matching code segments, to form the updated target mapping.
2. The test method according to claim 1, characterized in that, The testing method also includes: Periodically check the markers of each code segment under test; If there are unlabeled code segments under test, it is determined that the initial mapping relationship has been broken; The step of configuring a matching object for the object that disrupts the initial mapping relationship to form an updated target mapping relationship includes: Configure matching test cases for untagged code segments under test.
3. The test method according to claim 1, characterized in that, The changes to the code segment include adding a code segment, modifying a code segment, and deleting a code segment.
4. The test method according to claim 1, characterized in that, The changes to the test cases include adding test cases, modifying test cases, and deleting test cases.
5. The test method according to claim 1, characterized in that, The execution of test cases in the target mapping relationship and the output of test results include: Obtain the execution process data of the test cases in the target mapping relationship; Update the execution process data to the attribute information of the target mapping relationship; Output the test results.
6. An electronic device, characterized in that, include: One or more processors; A memory having stored one or more computer programs thereon, which, when executed by the one or more processors, cause the one or more processors to implement the test method according to any one of claims 1 to 5.
7. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the test method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Testing mapping relation database generation method and device, computer equipment and storage medium
CN108874661A
Application test method and device, equipment and storage medium
CN112131114A
Application program testing method and device, storage medium and program product
CN118779247A