Integration test method and device, electronic equipment and storage medium
By using pre-trained test cases to determine the model and the test cases of the target code, the time and resource waste caused by massive use cases in integration tests are solved, and efficient integration testing is achieved.
Patent Information
- Application Number
- CN202510337802.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-08-08
AI Technical Summary
During the integration testing process in the existing software field, there are problems such as mass test cases causing wasted time and resources. At the same time, the learning ability of historical test results is insufficient, resulting in a waste of time and material resources for testing without focus.
Use pre-trained test cases to determine the model, determine the test cases corresponding to the target code, and use the target test cases for integration testing to avoid using all test cases in each test.
Improves integrated testing efficiency, reduces test time and cost, and improves the targetedness and efficiency of testing.
Smart Images

Figure CN120448251A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to an integrated testing method, device, electronic device, and storage medium. Background Art
[0002] Integration testing, also known as assembly testing or joint testing, involves assembling some or all modules into a subsystem or system based on design requirements (e.g., a block diagram) based on unit testing. A system function is typically implemented by multiple modules working together. Integration testing involves combining these modules to verify a specific function. This ensures that the modules work together as intended and without conflicts.
[0003] The current integration testing process in the software field has two shortcomings: (1) Large projects have a huge number of test cases, and executing all test cases in a round takes a long time. Most of the test cases are irrelevant to the code submitted at the time, so unfocused testing wastes both time and resources. (2) The results of each round of test case execution are valuable information. Based on historical test results, we can learn and summarize which specific code is prone to errors in specific use cases. Current testing systems do not have this capability. Summary of the Invention
[0004] Embodiments of the present disclosure provide an integrated testing method, apparatus, electronic device, and storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides an integration testing method, including: obtaining target code; determining a first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case; determining a target test case based on the first test case; performing integration testing on the target code using the target test case, and outputting the test results.
[0006] In the second aspect, an embodiment of the present disclosure provides an integrated testing device, including: a code acquisition unit, configured to acquire target code; a use case prediction unit, configured to determine a first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case; a use case determination unit, configured to determine a target test case based on the first test case; and an integration testing unit, configured to perform integration testing on the target code using the target test case and output the test results.
[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device comprising a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein the processor implements the integrated testing method described in the first aspect when executing the computer program.
[0008] In a fourth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the integrated testing method described in the first aspect.
[0009] By applying the technical solution disclosed in the present invention, a pre-trained test case determination model can be used to determine target test cases for the target code, thereby avoiding the use of all test cases for each test in the existing integration testing process, effectively improving the efficiency of integration testing.
[0010] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure. Figure 1 is an exemplary system architecture diagram to which an embodiment of the integrated testing method disclosed herein may be applied; Figure 2 A flowchart of an embodiment of the integrated testing method disclosed herein; Figure 3 This is a flow chart of another embodiment of the integrated testing method disclosed herein; Figure 4 A schematic diagram of an application scenario of the integrated testing method disclosed herein; Figure 5 This is a schematic structural diagram of an embodiment of an integrated testing device disclosed herein; Figure 6 This is a schematic structural diagram of an embodiment of an electronic device disclosed herein. DETAILED DESCRIPTION
[0012] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present disclosure belongs.
[0013] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.
[0014] In the absence of conflict, the embodiments of the present disclosure and the features thereof may be combined with each other.
[0015] In order to make the technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0016] Figure 1 An exemplary system architecture 100 is shown to which embodiments of the integrated testing method or integrated testing apparatus of the present disclosure may be applied.
[0017] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is a medium for providing communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0018] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications, such as code editing applications, can be installed on terminal devices 101, 102, and 103. Users can upload edited code to server 105 via terminal devices 101, 102, and 103.
[0019] The server 105 can be a server that provides various services, such as analyzing and processing the code uploaded by the terminal devices 101, 102, and 103, determining the appropriate test cases, and then performing integration testing on the code using the test cases, and feeding back the test results to the terminal devices 101, 102, and 103.
[0020] It should be noted that server 105 can be either hardware or software. When server 105 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When server 105 is software, it can be implemented as multiple software programs or software modules (for example, to provide distributed services), or as a single software program or software module. This is not specifically limited here.
[0021] It should be noted that the integrated testing method provided in the embodiment of the present disclosure is generally executed by the server 105. Accordingly, the integrated testing device is generally provided in the server 105.
[0022] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0023] Figure 2 FIG2 shows a process 200 of an embodiment of the integrated testing method of the present disclosure. Figure 2 As shown, the integration testing method of this embodiment may include the following steps: Step 201: Obtain target code.
[0024] In this embodiment, the execution subject of the integrated test method (for example Figure 1 The server 105 shown in the figure can obtain the target code in various ways. For example, it can obtain the target code through various terminal devices used by the user (for example Figure 1 The target code is obtained from the terminal devices 101, 102, and 103 shown in the figure. The target code can be in various languages. The target code can include multiple custom functions, and each custom function can be executed by compiling the target code. The target code can be the code submitted for the first time for the project, or it can be modified from the original code of the project.
[0025] Step 202: Determine a model based on the target code and pre-trained test cases, and determine a first test case corresponding to the target code.
[0026] In this embodiment, after obtaining the target code, the target code can be input into a pre-trained test case determination model. The output of the model is the first test case corresponding to the target code. The test case determination model can be used to characterize the correspondence between code and test cases. The test case determination model can be various machine learning algorithms, such as a neural network.
[0027] Step 203: Determine a target test case based on the first test case.
[0028] After determining the first test case, the target test case can be determined based on the first test case. In this embodiment, each test case can be pre-divided into multiple test case sets, and different test case sets correspond to different user interfaces. For example, a group of test cases corresponds to the user interface Delete Object, a group of test cases corresponds to the user interface Put Object, and a group of test cases corresponds to the user interface Get Object. The mapping relationship between the test case and the user interface can be stored in a database table. After determining the first test case, the above mapping relationship can be queried to determine the test case set to which each test case in the first test case belongs as the target test case. Alternatively, N test cases can be selected from the test case set to which each test case belongs as the target test case.
[0029] Step 204: Perform integration testing on the target code using the target test case and output the test results.
[0030] After determining the target test case, you can use the target test case to perform integration testing on the target code, obtain the test results, and output the test results.
[0031] The integration testing method provided by the above-mentioned embodiments of the present disclosure can use a pre-trained test case determination model to determine target test cases for the target code, thereby avoiding the use of all test cases for each test in the existing integration testing process, and effectively improving the efficiency of integration testing.
[0032] Continue to see Figure 2 , which shows a process 200 according to another embodiment of the integrated testing method of the present disclosure. Figure 2 As shown, the method in this embodiment may include the following steps: Step 301: Obtain target code.
[0033] Step 302: Determine a model based on the target code and pre-trained test cases, and determine a first test case corresponding to the target code.
[0034] Step 303: In response to determining that the target code is a modified version of the original code, a directed graph corresponding to the original code is obtained.
[0035] In this embodiment, if the target code is a modified version of the original code, the directed graph corresponding to the original code can be obtained first. Here, the target code can be obtained after multiple modifications to the original code. It is understandable that each time the original code is modified, it will be submitted for testing. A directed graph is a graph consisting of a set of nodes (or vertices) and directed edges connecting these nodes. Each edge has a direction, usually represented by one node pointing to another node. Each node in the directed graph can represent a function, and the directed edges between vertices can represent the calling relationship between functions. The above-mentioned directed graph can be generated by technicians based on the calling relationship of each function in the original code. Alternatively, it can be generated using an existing algorithm.
[0036] Step 304: Determine the difference between the target code and the original code.
[0037] In this embodiment, a preset instruction can be used to determine the difference between the target code and the original code. For example, the git diff command can be used to determine the difference.
[0038] Step 305: Determine a second test case based on the difference portion and the directed graph.
[0039] After determining the difference, the functions involved in the difference can be determined. Then, combined with the above directed graph, the functions affected by the difference can be determined. Then, using the correspondence between each function and the user interface, the test case set corresponding to the user interface is used as the second test case. For details, see Figure 4 , which shows an application scenario diagram for the second test case determined by different modification points. In this scenario, modification point 1 is function 8. Since function 8 calls function 5, which in turn calls function 3, the test cases corresponding to the Put Object user interface corresponding to function 3 (test cases 1-3) are part of the second test case. Similarly, modification point 2 is function 12. Since function 12 calls function 10, the test cases corresponding to the Get Object user interface corresponding to function 10 (test cases 4-6) are part of the second test case. Therefore, the second test case is test cases 1-6.
[0040] Step 306: Determine the test case set to which the first test case belongs; and determine the target test case based on the second test case and the test case set.
[0041] After obtaining the first test case and the second test case, the two can be combined to obtain a target test case. For example, first determine the test case set to which the first test case belongs. Then, the union of the second test case and the test case set to which the first test case belongs is used as the target test case.
[0042] Step 307: Perform integration testing on the target code using the target test case and output the test results.
[0043] In this embodiment, the directed graph of the original code can be implemented by the following steps: Step 1: For each function of the original code, insert the preset code into the function.
[0044] First, for each function in the original code, a preset code can be inserted into the function. Here, the preset code can be used to print the stack information of the code.
[0045] Step 2: Execute all test cases in the preset test case library to determine the stack information of each function in the original code.
[0046] Then, for the original code, all test cases in the preset test case library can be executed. In this way, the stack information can include function call information. In this embodiment, the test case library includes multiple test case sets, and different test case sets correspond to different user interfaces.
[0047] Step 3: Determine the calling relationship of each function in the original code based on the stack information.
[0048] After obtaining all the stack information, you can analyze the stack information to determine the calling relationship between functions.
[0049] Step 4: Generate a directed graph based on the call relationship, each user interface and each test case set.
[0050] Each function is regarded as a node of a directed graph, and the directed edges between the nodes are determined according to the calling relationship between the functions, thereby obtaining a directed graph of the original code.
[0051] In some optional implementations of this embodiment, the test case determination model can be updated and trained using the determined target test cases and target code to improve the accuracy of the test case determination model in subsequent test case determination. Specifically, the test case determination model can be updated using the target code as input and the determined target test cases as the expected output.
[0052] The integrated testing method provided by the above-mentioned embodiments of the present disclosure can determine adapted test cases for the target code without having to use all test cases for testing every time the original code is modified, thereby improving testing efficiency and reducing testing time and testing costs.
[0053] Further references Figure 5As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an integrated test device. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0054] like Figure 5 As shown, the integrated testing device 500 of this embodiment includes: a code acquisition unit 501, a use case prediction unit 502, a use case determination unit 503 and an integrated testing unit 504.
[0055] The code acquisition unit 501 is configured to acquire the target code.
[0056] The use case prediction unit 502 is configured to determine a first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case.
[0057] The use case determination unit 503 is configured to determine a target test case based on the first test case.
[0058] The integration testing unit 504 is configured to perform integration testing on the target code using target test cases and output test results.
[0059] In addition, in the technical solution of this application, an electronic device is also proposed.
[0060] Figure 6 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown.
[0061] like Figure 6 As shown, the electronic device may include a processor 601, a memory 602, a bus 603, and a computer program stored in the memory 602 and executable on the processor 601, wherein the processor 601 and the memory 602 communicate with each other via the bus 603. When the processor 601 executes the computer program, the steps of the above method are implemented, for example, including: obtaining target code; determining a first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case; determining a target test case based on the first test case; and performing integration testing on the target code using the target test case, and outputting the test results.
[0062] In addition, in one embodiment of the present disclosure, a non-transitory 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 the above method are implemented, for example, including: obtaining the target code; determining the first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case; determining the target test case based on the first test case; performing integration testing on the target code using the target test case, and outputting the test results.
[0063] To sum up, the technical solution disclosed in the present invention can use a pre-trained test case determination model to determine the target test case for the target code, thereby avoiding the use of all test cases for each test in the existing integration testing process, effectively improving the efficiency of integration testing.
[0064] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure should be included in the scope of protection of the present disclosure.
Claims
1. An integration testing method, comprising: Get the object code; Determining a first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case; Based on the first test case, determining a target test case; Perform integration testing on the target code using the target test case and output the test results.
2. The method according to claim 1, wherein The method further comprises: In response to determining that the target code is a modified version of the original code, obtaining a directed graph corresponding to the original code; Determining the difference between the target code and the original code; A second test case is determined based on the difference portion and the directed graph.
3. The method according to claim 2, wherein: The determining a target test case based on the first test case includes: Determining the test case set to which the first test case belongs; The target test case is determined according to the second test case and the test case set.
4. The method according to claim 2, wherein: The method further comprises: A directed graph corresponding to the original code is generated.
5. The method according to claim 4, wherein Generating a directed graph corresponding to the original code includes: For each function of the original code, inserting a preset code into the function, wherein the preset code is used to print stack information of the code; Executing all test cases in a preset test case library to determine stack information for each function in the original code, wherein the test case library includes multiple test case sets, and different test case sets correspond to different user interfaces; Determining the calling relationship of each function in the original code according to the stack information; The directed graph is generated according to the calling relationship, each user interface and each test case set.
6. The method according to claim 5, wherein: Determining a second test case according to the difference portion and the directed graph includes: determining a modified function according to the difference portion; Determine a position of the modified function in the directed graph; The second test case is determined according to the test case set corresponding to the determined position.
7. The method according to claim 2, wherein: The method further comprises: The test case determination model is trained again using the second test case and the target code.
8. An integrated testing device comprising: A code acquisition unit configured to acquire a target code; a use case prediction unit configured to determine a first test case corresponding to the target code based on the target code and a pre-trained test case determination model, wherein the test case determination model is used to characterize the correspondence between the code and the test case; a use case determination unit, configured to determine a target test case based on the first test case; The integration test unit is configured to perform integration testing on the target code using the target test case and output the test result.
9. An electronic device comprising a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the integrated testing method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the integrated testing method according to any one of claims 1 to 7 is implemented.