Program testing method, device, electronic equipment and storage medium
By obtaining the code modification list and mapping table of the called system, test cases are automatically filtered, which solves the problems of difficulty in filtering test cases for upstream related systems and repeated calls in existing technologies, and achieves efficient test case determination and reduces manual intervention.
Patent Information
- Application Number
- CN202210166299.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-23
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2042-02-23
AI Technical Summary
In cases where multiple services have call relationships, existing technologies cannot effectively filter upstream related test cases based on code coverage statistics, and there are a large number of duplicate calls, requiring manual intervention to filter or execute redundant test cases.
By obtaining the code modification list of the called system, and using the test case code mapping table and system call relationship mapping table, the calling relationship between the called system and the called system can be automatically determined, and concise test cases can be selected to reduce duplicate calls.
Effectively determine the test case relationships of upstream related systems, reduce repeated calls to test cases, reduce manual intervention, and improve testing efficiency.
Smart Images

Figure CN114564388B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to computer technology, and in particular to a program testing method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of computer technology, the common testing methods can be divided into functional module-based testing and code coverage statistics-based testing. Code coverage statistics-based testing ensures the completeness of the test through quantification, which has higher reliability or security for software systems. Now many industries use more code coverage statistics-based testing as the testing standard, for example: it is executed according to the standards of "function coverage" and "function call coverage", requiring that the functions contained in the software must at least be executed and called to avoid obvious omissions in the test or the appearance of honor codes. However, the code coverage statistics-based testing in the prior art cannot effectively screen the test cases of the upstream related systems when there are call relationships between multiple services. At the same time, the determined test cases often have a large number of repeated calls, requiring manual participation in screening or the execution of more redundant cases. Summary of the invention
[0003] The present invention provides a program testing method, device, electronic device and storage medium, so as to effectively determine the test cases for the upstream associated system and avoid a large number of repeated calls of the test cases.
[0004] In a first aspect, an embodiment of the present invention provides a program testing method, the method comprising:
[0005] Obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0006] Determine the calling system corresponding to the called system according to the code modification list, and obtain the regression code corresponding to the calling system;
[0007] According to the regression code, a use case code mapping table of the calling system is searched to obtain a use case list corresponding to the calling system;
[0008] The use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are screened to obtain test cases, and the modified code in the called system and the regression code corresponding to the calling system are tested according to the test cases.
[0009] In a second aspect, an embodiment of the present invention further provides a program testing device, the device comprising:
[0010] A use case search module is used to obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0011] A system determination module, used to determine the calling system corresponding to the called system according to the code modification list, and obtain the regression code corresponding to the calling system;
[0012] A list search module is used to query the use case code mapping table of the calling system according to the regression code to obtain a use case list corresponding to the calling system;
[0013] The use case screening module is used to screen the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, and test the modified code in the called system and the regression code corresponding to the calling system according to the test cases.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0015] one or more processors;
[0016] a storage device for storing one or more programs,
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the program testing method.
[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the program testing method is implemented.
[0019] According to an embodiment of the present invention, a code modification list corresponding to the called system is obtained, and a use case code mapping table of the called system is searched according to the code modification list to obtain a use case list corresponding to the modification code in the called system; a calling system corresponding to the called system is determined according to the code modification list, and a regression code corresponding to the calling system is obtained; a use case code mapping table of the calling system is searched according to the regression code to obtain a use case list corresponding to the calling system; a use case list corresponding to the modification code in the called system and a use case list corresponding to the calling system are screened to obtain a test case, and the modification code in the called system and the regression code corresponding to the calling system are tested according to the test case. That is, according to an embodiment of the present invention, a call relationship between the called system and the calling system is determined according to the modification code, so that the test case relationship of the upstream associated system can be effectively determined, and a use case list corresponding to the modification code in the called system and a use case list corresponding to the calling system are screened to obtain a test case, thereby avoiding a large number of repeated calls of test cases and reducing the need for manual participation. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a flowchart of a program testing method provided by an embodiment of the present invention;
[0021] Figure 2 is another flowchart of the program testing method provided by an embodiment of the present invention;
[0022] Figure 2A A schematic diagram of the principle of a use case code mapping table provided in an embodiment of the present invention;
[0023] Figure 2B A schematic diagram of the structure of a call relationship record strip provided by an embodiment of the present invention;
[0024] Figure 2C A schematic diagram of the principle of a use case code call diagram provided by an embodiment of the present invention;
[0025] Figure 2D A schematic diagram of the principle of screening a use case list provided in an embodiment of the present invention;
[0026] Figure 3 is a schematic diagram of the structure of a program testing device provided by an embodiment of the present invention;
[0027] Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0029] Figure 1 A flowchart of a program testing method provided in an embodiment of the present invention is provided. The method can be executed by a program testing device provided in an embodiment of the present invention. The device can be implemented in software and / or hardware. In a specific embodiment, the device can be integrated in an electronic device, such as a server. The following embodiments will be described by taking the device integrated in an electronic device as an example. Figure 1 , the method may specifically include the following steps:
[0030] S110, obtaining a code modification list corresponding to the called system, and searching a use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0031] For example, the called system can be a system called by other systems in the calling relationship between systems, and is used to provide program code to other systems through a program interface to facilitate the implementation of the functions of the called system. For example, the called system can be any system in the set of all system calls for implementing the operating system. The code modification list corresponding to the called system can be a modification list generated when the called system is modified, wherein the code modification list includes all modification code locations, functional content of the modification code, and modification logs, etc., which can be used to determine the modification code of the called system. The use case code mapping table of the called system can be used as a test relationship comparison table of all use cases and codes for program testing in the called system, and is used to determine the use cases corresponding to the program that needs to be tested in the called system. The use case list corresponding to the modification code in the called system can be a test case statistics table of the current modification code determined by the use case code mapping table of the called system.
[0032] In a specific implementation, when the called system detects that the code in the called system has been modified, the code modification list corresponding to the called system is obtained by comparing the programs in the called system at different times before and after the modification; or when the called system detects that the code in the called system has been modified, the code modification list corresponding to the called system automatically generated by the called system is obtained. The use case code mapping table of the called system is searched according to the code modification list to obtain the use case list corresponding to the modified code in the called system.
[0033] S120, determining the calling system corresponding to the called system according to the code modification list, and obtaining the regression code corresponding to the calling system;
[0034] In a specific implementation, the calling system may be a system that calls the called system in a calling relationship between systems, and is used to call the program code in the called system through a program interface to implement the function of the calling system. For example, the calling system may be any system in a set of all system calls for implementing an operating system. The regression code corresponding to the calling system may be a code that implements the program function based on the modified code in the called system, or may be a code of the calling system related to the modified code in the called system.
[0035] In a specific implementation, the modification code in the called system is determined according to the modification code list of the called system, and the calling system of the modification code in the called system (i.e., the calling system corresponding to the called system) is determined according to the modification code in the called system and the system call relationship mapping table. The program code that calls the modification code in the called system in the calling system is determined according to the modification code in the called system, and the regression code corresponding to the calling system is obtained.
[0036] S130, querying the use case code mapping table of the calling system according to the regression code, and obtaining a use case list corresponding to the calling system;
[0037] In a specific implementation, the use case code mapping table of the calling system can be used to compare all the use cases of the program test in the calling system with the test relationship table of the code in the calling system, and is used to determine the use cases corresponding to the program that needs to be tested in the calling system. The use case code mapping table of the calling system is searched according to the regression code in the calling system to obtain a list of use cases corresponding to the calling system, wherein the list of use cases corresponding to the calling system can be a list of use cases corresponding to the regression code in the calling system, and is used to test the regression code in the calling system.
[0038] S140, screening the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, and testing the modified code in the called system and the regression code corresponding to the calling system according to the test cases.
[0039] In the specific implementation, the test cases are used to test the modified code in the called system and the regression code corresponding to the calling system, and the streamlined test cases are obtained by screening the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system. The use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are screened because of the implicit repeated test relationship between the modified code in the called system and the regression code of the calling system during the test process. Without affecting the functional testing of the modified code in the called system and the regression code of the calling system, the repeated test cases in the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are deleted, and the streamlined test cases for testing the modified code in the called system and the regression code corresponding to the calling system are obtained.
[0040] According to an embodiment of the present invention, a code modification list corresponding to the called system is obtained, and a use case code mapping table of the called system is searched according to the code modification list to obtain a use case list corresponding to the modification code in the called system; a calling system corresponding to the called system is determined according to the code modification list, and a regression code corresponding to the calling system is obtained; a use case code mapping table of the calling system is searched according to the regression code to obtain a use case list corresponding to the calling system; a use case list corresponding to the modification code in the called system and a use case list corresponding to the calling system are screened to obtain a test case, and the modification code in the called system and the regression code corresponding to the calling system are tested according to the test case. That is, according to an embodiment of the present invention, a call relationship between the called system and the calling system is determined according to the modification code, so that the test case relationship of the upstream associated system can be effectively determined, and a use case list corresponding to the modification code in the called system and a use case list corresponding to the calling system are screened to obtain a test case, thereby avoiding a large number of repeated calls of test cases and reducing the need for manual participation.
[0041] The following further describes the program testing method provided by the embodiment of the present invention. Figure 2 As shown, the method may specifically include the following steps:
[0042] S210, obtaining a code modification list corresponding to the called system, and searching a use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0043] Furthermore, the code modification list corresponding to the called system is obtained, including:
[0044] Compare the system codes of the called system before and after modification to obtain a code modification list corresponding to the called system.
[0045] In a specific implementation, when the called system detects that the code in the called system has been modified, the program in the called system at different times before and after the modification is compared. For example, when the code in the workspace of the called system is modified, the git diff algorithm can be used to compare the code in the called system before and after the modification to obtain a code modification list corresponding to the called system. Alternatively, the modification log of the called system can be used to compare the code in the called system at different times to obtain a code modification list corresponding to the called system.
[0046] Further, the use case code mapping table of the called system is searched according to the code modification list to obtain a use case list corresponding to the modified code in the called system, including:
[0047] Determine whether there is a use case corresponding to the modified code in the use case code mapping table of the called system;
[0048] When there is a use case corresponding to the modification code in the use case code mapping table of the called system, a use case list corresponding to the modification code in the called system is determined according to the use case code mapping table of the called system;
[0049] When the use case code mapping table of the called system does not have a use case corresponding to the modification code, a use case corresponding to the modification code is written to obtain a use case list corresponding to the modification code in the called system.
[0050] In a specific implementation, the use case code mapping table of the called system is automatically searched according to the code modification list of the called system, and it is determined whether the use case code mapping table of the called system has a use case corresponding to the modification code, so as to determine whether the use case list corresponding to the modification code in the called system is determined according to the use case code mapping table of the called system. When there is a use case corresponding to the modification code in the use case code mapping table of the called system, the use case corresponding to the modification code in the called system is matched in the use case code mapping table of the called system according to the modification code, and a use case list corresponding to the modification code in the called system is obtained. When there is a use case corresponding to the modification code in the use case code mapping table of the called system, it means that the use case corresponding to the modification code cannot be found in the use case code mapping table of the called system, and a new use case needs to be written to cover the modification code as the use case list corresponding to the modification code in the called system. In addition, the written new use case and the modification code need to be added to the use case code mapping table of the called system, and the use case code mapping table of the called system is updated to obtain a new use case code mapping table of the called system.
[0051] Figure 2A A schematic diagram of the principle of the use case code mapping table provided in the embodiment of the present invention, such as Figure 2AAs shown, the use case code mapping table is used to record the mapping relationship between the automated test cases and the system codes. The mapping relationship between the modified code and the test cases in the use case code mapping table can be determined through the use case code mapping table to determine the test cases. When ClassB Method4 in system B is the modified code, the use case corresponding to the modified code is determined to be b.
[0052] S220, determining the calling system corresponding to the called system according to the code modification list, and obtaining the regression code corresponding to the calling system;
[0053] Further, the calling system corresponding to the called system is determined according to the code modification list, including:
[0054] Obtain a system call relationship mapping table in the call relationship system, query the system call relationship mapping table according to the code modification list and the called system, and obtain the calling system corresponding to the called system.
[0055] In a specific implementation, the call relationship system can be a system that communicates information with the called system and the calling system, can be a separately developed system specifically used for maintaining call information related to each system, or can be a system that performs information communication backup through registration and other methods, and is used to record information such as program call sources, call codes, and call interfaces in each system. Among them, the call relationship system maintains call relationship mapping tables for multiple systems. The call relationship mapping table includes the name of the called system, the name of the calling system, the calling method name, and the called method name. The modified code in the code modification list is used as the name of the called method and the name of the called system to query the system call relationship mapping table, determine the calling system and call relationship record entry corresponding to the called system, and obtain the regression code corresponding to the calling system from the call relationship record.
[0056] Figure 2B A schematic diagram of the structure of a call relationship record strip provided by an embodiment of the present invention, such as Figure 2B As shown, the calling system A and the called system B call the called method name Method2 in the called system by calling the method name Method1. According to the call relationship record, the regression code of the upstream system can be determined according to the code changes of the system, and then the test cases that need to be regressed in the upstream system can be determined. Among them, the code of method Method2 of ClassB of the called system B in the call relationship record has been modified. Through this record, it can be determined that the code of method1 of ClassA of the calling system A needs to be regressed, and the code of method1 of ClassA of the calling system A is used as the regression code.
[0057] S230, querying the use case code mapping table of the calling system according to the regression code, and obtaining a use case list corresponding to the calling system;
[0058] S240, drawing a use case code call graph according to the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system;
[0059] In a specific implementation, the use case code call graph can be a graph that shows the call relationship between the use case and the system through the call pointing of the use case and the system. The call relationship between the system and the use case is determined based on the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system. The use case code call graph is drawn based on the call relationship between the system and the use case.
[0060] Figure 2C A schematic diagram of the principle of the use case code call diagram provided by the embodiment of the present invention, such as Figure 2C As shown, the circle represents the use case, and the square represents the system code. The use case code call diagram has system A code, system B code, system C code, system D code, and system E code, and has legends a, b, c, d, f, and e. The use case list corresponding to the system A code is {a, b, c}, the use case list corresponding to the system B code is {c}, the use case list corresponding to the system C code is {b, d}, the use case list corresponding to the system D code is {d, c, f}, and the use case list corresponding to the system E code is {e}.
[0061] S250, determining the in-degree of the called system and the in-degree of the calling system respectively according to the use case code call graph;
[0062] For example, the in-degree of the called system can be the number of use cases pointing to the modification code in the called system in the use case code call graph corresponding to the code modification list of the called system. The in-degree of the calling system can be the number of use cases pointing to the regression code in the calling system in the use case code call graph drawn by the use case list corresponding to the calling system.
[0063] In the specific implementation, a use case code call graph is drawn according to the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system. The in-degree of the called system is determined by the number of use cases pointing to the modified code in the called system in the use case code call graph, and the in-degree of the calling system is determined by the number of use cases pointing to the regression code in the calling system in the use case code call graph. This facilitates screening through the in-degree of the called system and the in-degree of the calling system to obtain a streamlined list of use cases for testing the modified code in the called system and the regression of the calling system.
[0064] S260. Filter the use cases in the use case code call graph according to the in-degree of the called system and the in-degree of the calling system to obtain test cases, and test the modified code in the called system and the regression code corresponding to the calling system according to the test cases.
[0065] In the specific implementation, a preset simplified in-degree threshold is set according to the test requirements and experimental data of the code in the called system and the code in the calling system. Generally, the in-degree threshold is set to 1 without affecting the test code function. The in-degree of the called system and the in-degree of the calling system are compared with the in-degree threshold respectively to determine whether to filter the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system. When the in-degree of the called system and the in-degree of the calling system are both less than the in-degree threshold, it means that the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are too simplified and cannot meet the test requirements. When the in-degree of the called system is less than the in-degree threshold or the in-degree threshold of the calling system, it means that the use case list corresponding to the modified code in the called system is too simplified and cannot meet the test requirements, or the use case list corresponding to the calling system is too simplified and cannot meet the test requirements. When the in-degree of the calling system is greater than the in-degree threshold and the in-degree of the called system is equal to the in-degree threshold, it means that the use case list corresponding to the calling system needs to be filtered to meet the simplified requirements of the regression code test cases in the preset calling system.
[0066] Furthermore, the use cases in the use case code call graph are screened according to the in-degree of the called system and the in-degree of the calling system to obtain test cases, including:
[0067] Determine the system whose in-degree of the called system and the system whose in-degree of the calling system is not 1 as the use case screening system, and retain the use cases corresponding to the called system and the system whose in-degree of the calling system is equal to 1 in the use case code call graph;
[0068] According to the out-degree of the use cases corresponding to the use case screening system in the use case code call graph, the use cases corresponding to the use case screening system are sorted from small to large, and according to the sorting of the use cases corresponding to the use case screening system, the use cases in the use case code call graph are screened to obtain test cases.
[0069] For example, the use case screening system can be a system in which the in-degree of the called system and the calling system is not 1, that is, each system in the use case screening system corresponds to multiple test cases, wherein the system in which the in-degree of the called system and the calling system is equal to 1 can be a system in which the called system and the calling system have only one test case, and the use cases corresponding to the system in which the in-degree of the called system and the calling system is equal to 1 in the use case code call graph are retained, that is, the test cases of the system in which the called system and the calling system have only one test case are retained, so that the test cases fully test the functions of each system. The out-degree of the use case corresponding to the use case screening system in the use case code call graph can be the number of systems that can be tested corresponding to each use case in the use case screening system in the current use case code call graph.
[0070] In the specific implementation, the in-degree threshold is set to 1 according to actual needs. The system equal to the in-degree threshold is the called system and the calling system with only one test case. It is necessary to retain the use cases corresponding to the called system and the calling system with in-degree equal to 1 in the use case code call graph, that is, the test cases for the called system and the calling system with only one test case are retained, so that the test cases fully test the functions of each system; the system greater than the in-degree threshold is the called system and the calling system with multiple test cases, which requires use case screening. Before deleting the use case, the use case code call graph corresponding to the called system and the calling system does not have a system less than the in-degree threshold, and the system needs to be tested before use. According to the connection between the use case and the system in the use case code call graph, the out-degree of the use case corresponding to the use case screening system in the use case code call graph is determined, which is used to determine the number of systems that can be tested by each use case in the use case screening system. When screening the use cases in the use case code call graph, it is necessary to sort the use cases corresponding to the use case screening system according to the out-degree of the use case corresponding to the use case screening system. Generally, they are sorted from small to large according to the out-degree, because the number of systems that can be tested by the use case with a large out-degree is large, that is, multiple systems can be tested by this use case, and the number of systems that can be tested by the use case with a small out-degree is small, that is, fewer systems can be tested by this use case. Start with screening with a small out-degree, from simple to complex, until the use cases corresponding to the use case screening system are simplified to the point where both the called system and the calling system can be tested. When there are the least use cases in the use case code call graph, the use cases in the use case code call graph can be used as test cases.
[0071] Further, the use cases in the use case code call graph are screened according to the out-degree of the use case corresponding to the use case of the use case screening system to obtain the test case, including:
[0072] Delete the corresponding use cases of the use case screening system in the use case code call diagram one by one, and determine whether the in-degree of the use case screening system is not zero after deleting a use case;
[0073] When a system with zero in-degree appears in the use case screening system after a use case is deleted, the currently deleted use case is restored in the use case code call graph;
[0074] When the in-degree of the use case screening system is not zero after deleting a use case, continue to delete the next use case in the use case code call graph until all corresponding use cases in the use case screening system are tentatively deleted, and then use the use cases in the use case code call graph after screening as test cases.
[0075] In the specific implementation, when filtering the use cases in the use case code call graph, it is necessary to sort the use cases corresponding to the use case screening system according to the out-degree of the use case corresponding to the use case screening system, and generally sort them from small to large according to the out-degree. According to the sorting, the use cases corresponding to the use case screening system are deleted in the use case code call graph in sequence. After deleting a use case in the use case corresponding to the use case screening system, after each use case is deleted, it is determined whether the in-degree of the use case screening system is zero; when a system with an in-degree of zero appears in the use case screening system after deleting a use case, it means that the currently deleted use case is the only test case of a system in the use case screening system, and the currently deleted use case is restored in the use case code call graph; when a system with an in-degree of zero does not appear in the use case screening system after deleting a use case, it means that the currently deleted use case is not the only test case of the use case screening system and can be deleted, then continue to delete the next use case in the use case corresponding to the use case screening system in the use case code call graph, and determine whether the in-degree of the use case screening system is zero after deleting the next use case. If it is zero, it is restored, and if it is not zero, it is continued to be deleted until all the use cases corresponding to the use case screening system are deleted, and the use cases in the filtered use case code call graph are obtained as test cases. Among them, the use cases in the use case screening system corresponding to the last attempted deletion need to be determined and restored and deleted, and then the use cases corresponding to the use case screening system are considered to have all been attempted to be deleted.
[0076] Figure 2D A schematic diagram of the principle of screening a use case list provided in an embodiment of the present invention, such as Figure 2DAs shown, the circle represents the use case, and the square represents the system code. The use case code call graph has system A code, system B code, system C code, system D code, and system E code, and has legends a, b, c, d, f, and e. The use case list corresponding to the system A code is {a, b, c}, the use case list corresponding to the system B code is {c}, the use case list corresponding to the system C code is {b, d}, the use case list corresponding to the system D code is {d, c, f}, and the use case list corresponding to the system E code is {e}. It is determined that the in-degree of system A in the use case code call graph is 3, the in-degree of system B is 1, the in-degree of system C is 2, the in-degree of system D is 3, and the in-degree of system E is 1. In the use case code call graph, the use cases {c, e} corresponding to system B and system E are retained without screening, and system A, system C, and system D are determined as the use case screening system, and it is determined that the use cases {a, b, d, f} corresponding to system A, system C, and system D in the use case code call graph. Determine the out-degree of use case a, use case b, use case d and use case f according to the use case code call graph before use case screening. The out-degree of use case a is 1, the out-degree of use case b is 2, the out-degree of use case d is 2, and the out-degree of use case f is 1. Use case a, use case b, use case d and use case f can be sorted from small to large according to their out-degree, or they can be sorted without any need. Delete them one by one, first delete use case a, make sure that the in-degree of system A in the use case screening system is 2, the in-degree of system C is 2, and the in-degree of system D is 3, all of which are not zero, then continue to delete use case f, make sure that the in-degree of system A in the use case screening system is 2, the in-degree of system C is 2, and the in-degree of system D is 2, all of which are not zero, then continue to delete use case b, the in-degree of system A in the use case screening system is 1, the in-degree of system C is 1, and the in-degree of system D is 2, all of which are not zero, then continue to try to delete use case d, make sure that the in-degree of system A in the use case screening system is 1, the in-degree of system C is 0, and the in-degree of system D is 1, and the in-degree of system C is 0, then restore d, and the test cases are {c, d, e}.
[0077] According to an embodiment of the present invention, a code modification list corresponding to the called system is obtained, and a use case code mapping table of the called system is searched according to the code modification list to obtain a use case list corresponding to the modification code in the called system; a calling system corresponding to the called system is determined according to the code modification list, and a regression code corresponding to the calling system is obtained; a use case code mapping table of the calling system is searched according to the regression code to obtain a use case list corresponding to the calling system; a use case list corresponding to the modification code in the called system and a use case list corresponding to the calling system are screened to obtain a test case, and the modification code in the called system and the regression code corresponding to the calling system are tested according to the test case. That is, according to an embodiment of the present invention, a call relationship between the called system and the calling system is determined according to the modification code, so that the test case relationship of the upstream associated system can be effectively determined, and a use case list corresponding to the modification code in the called system and a use case list corresponding to the calling system are screened to obtain a test case, thereby avoiding a large number of repeated calls of test cases and reducing the need for manual participation.
[0078] Figure 3 is a schematic diagram of the structure of a program testing device provided by an embodiment of the present invention, such as Figure 3 As shown, the program test device includes:
[0079] A use case search module 310 is used to obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0080] A system determination module 320, configured to determine a calling system corresponding to the called system according to the code modification list, and obtain a regression code corresponding to the calling system;
[0081] A list search module 330 is used to query the use case code mapping table of the calling system according to the regression code to obtain a use case list corresponding to the calling system;
[0082] The use case screening module 340 is used to screen the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, and test the modified code in the called system and the regression code corresponding to the calling system according to the test cases.
[0083] In one embodiment, the use case search module 310 obtains a code modification list corresponding to the called system, including:
[0084] The system codes of the called system before and after modification are compared to obtain a code modification list corresponding to the called system.
[0085] In one embodiment, the use case search module 310 searches the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system, including:
[0086] Determine whether there is a use case corresponding to the modification code in the use case code mapping table of the called system;
[0087] When the use case code mapping table of the called system contains a use case corresponding to the modification code, determining a use case list corresponding to the modification code in the called system according to the use case code mapping table of the called system;
[0088] When the use case code mapping table of the called system does not contain the use case corresponding to the modification code, the use case corresponding to the modification code is written to obtain a use case list corresponding to the modification code in the called system.
[0089] In one embodiment, the system determination module 320 determines the calling system corresponding to the called system according to the code modification list, including:
[0090] A system call relationship mapping table in the call relationship system is obtained, and the system call relationship mapping table is queried according to the code modification list and the called system to obtain a calling system corresponding to the called system.
[0091] In one embodiment, the use case screening module 340 screens the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, including:
[0092] Draw a use case code call graph according to the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system;
[0093] Determine the in-degree of the called system and the in-degree of the calling system respectively according to the use case code call graph;
[0094] The use cases in the use case code call graph are screened according to the in-degree of the called system and the in-degree of the calling system to obtain the test case.
[0095] In one embodiment, the use case screening module 340 screens the use cases in the use case code call graph according to the in-degree of the called system and the in-degree of the calling system to obtain the test case, including:
[0096] The use cases in the use case code call graph are screened according to the in-degree of the called system and the in-degree of the calling system to obtain the test case, including:
[0097] Determine the in-degree of the called system and the system whose in-degree of the calling system is not 1 as the use case screening system, and retain the use cases corresponding to the called system and the system whose in-degree of the calling system is equal to 1 in the use case code call graph;
[0098] According to the out-degree of the use cases corresponding to the use case screening system in the use case code call graph, the use cases corresponding to the use case screening system are sorted from small to large, and according to the sorting of the use cases corresponding to the use case screening system, the use cases in the use case code call graph are screened to obtain the test cases.
[0099] In one embodiment, the use case screening module 340 screens the use cases in the use case code call graph according to the out-degree of the use case corresponding to the use case of the use case screening system to obtain the test case, including:
[0100] Deleting the use cases corresponding to the use case screening system in the use case code call graph in sequence, and determining whether the in-degree of the use case screening system is not zero after deleting one use case;
[0101] When a system with zero in-degree appears in the use case screening system after a use case is deleted, a currently deleted use case is restored in the use case code call graph;
[0102] When the in-degree of the use case screening system is not uniformly zero after deleting a use case, continue to delete the next use case in the use case code call graph until all corresponding use cases in the use case screening system are tentatively deleted, and then use the use case in the use case code call graph after screening as the test case.
[0103] The device of the embodiment of the present invention obtains the code modification list corresponding to the called system, and searches the use case code mapping table of the called system according to the code modification list to obtain the use case list corresponding to the modification code in the called system; determines the calling system corresponding to the called system according to the code modification list, and obtains the regression code corresponding to the calling system; queries the use case code mapping table of the calling system according to the regression code to obtain the use case list corresponding to the calling system; screens the use case list corresponding to the modification code in the called system and the use case list corresponding to the calling system to obtain the test case, and tests the modification code in the called system and the regression code corresponding to the calling system according to the test case. That is, the embodiment of the present invention determines the calling relationship between the called system and the calling system according to the modification code, can effectively determine the test case relationship of the upstream associated system, and screens the use case list corresponding to the modification code in the called system and the use case list corresponding to the calling system to obtain the test case, thereby avoiding a large number of repeated calls of the test case and reducing the need for manual participation.
[0104] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 4 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 4 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0105] like Figure 4 The electronic device 12 is shown as a general purpose computing device. Components of the electronic device 12 may include, but are not limited to, one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0106] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0107] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0108] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media (not shown, typically referred to as a "hard drive"). Although Figure 4 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0109] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0110] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0111] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing the program testing method provided in the embodiment of the present invention, the method comprising:
[0112] Obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0113] Determine the calling system corresponding to the called system according to the code modification list, and obtain the regression code corresponding to the calling system;
[0114] According to the regression code, a use case code mapping table of the calling system is searched to obtain a use case list corresponding to the calling system;
[0115] The use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are screened to obtain test cases, and the modified code in the called system and the regression code corresponding to the calling system are tested according to the test cases.
[0116] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the program testing method is implemented. The method includes:
[0117] Obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system;
[0118] Determine the calling system corresponding to the called system according to the code modification list, and obtain the regression code corresponding to the calling system;
[0119] According to the regression code, a use case code mapping table of the calling system is searched to obtain a use case list corresponding to the calling system;
[0120] The use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are screened to obtain test cases, and the modified code in the called system and the regression code corresponding to the calling system are tested according to the test cases.
[0121] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.
[0122] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0123] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0124] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0125] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A program testing method, characterized in that: include: Obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system; Determine the calling system corresponding to the called system according to the code modification list, and obtain the regression code corresponding to the calling system; According to the regression code, a use case code mapping table of the calling system is searched to obtain a use case list corresponding to the calling system; Screening the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, and testing the modified code in the called system and the regression code corresponding to the calling system according to the test cases; The use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system are screened to obtain test cases, including: Draw a use case code call graph according to the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system; Determine the in-degree of the called system and the in-degree of the calling system respectively according to the use case code call graph; the in-degree of the called system is the number of use cases in the code modification list that directly call the modification code of the called system, and the in-degree of the calling system is the number of use cases in the use case list that directly call the regression code of the calling system; The use cases in the use case code call graph are screened according to the in-degree of the called system and the in-degree of the calling system to obtain the test case.
2. The method according to claim 1, characterized in that Obtaining a code modification list corresponding to the called system, including: The system codes of the called system before and after modification are compared to obtain a code modification list corresponding to the called system.
3. The method according to claim 1, characterized in that Searching the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modification code in the called system includes: Determine whether there is a use case corresponding to the modification code in the use case code mapping table of the called system; When the use case code mapping table of the called system contains a use case corresponding to the modification code, determining a use case list corresponding to the modification code in the called system according to the use case code mapping table of the called system; When the use case code mapping table of the called system does not contain the use case corresponding to the modification code, the use case corresponding to the modification code is written to obtain a use case list corresponding to the modification code in the called system.
4. The method according to claim 1, characterized in that: Determining a calling system corresponding to the called system according to the code modification list includes: A system call relationship mapping table in the call relationship system is obtained, and the system call relationship mapping table is queried according to the code modification list and the called system to obtain a calling system corresponding to the called system.
5. The method according to claim 1, characterized in that The use cases in the use case code call graph are screened according to the in-degree of the called system and the in-degree of the calling system to obtain the test case, including: Determine the in-degree of the called system and the system whose in-degree of the calling system is not 1 as the use case screening system, and retain the use cases corresponding to the called system and the system whose in-degree of the calling system is equal to 1 in the use case code call graph; According to the out-degree of the use case corresponding to the use case screening system in the use case code call graph, the use cases corresponding to the use case screening system are sorted from small to large, and according to the sorting of the use case corresponding to the use case screening system, the use cases in the use case code call graph are screened to obtain the test case; the out-degree of the use case corresponding to the use case screening system is the number of test systems corresponding to each use case in the use case screening system.
6. The method according to claim 5, characterized in that The use cases in the use case code call graph are screened according to the out-degree of the use case corresponding to the use case screening system to obtain the test case, including: Deleting the use cases corresponding to the use case screening system in the use case code call graph in sequence, and determining whether the in-degree of the use case screening system is not zero after deleting one use case; When a system with zero in-degree appears in the use case screening system after a use case is deleted, a currently deleted use case is restored in the use case code call graph; When the in-degree of the use case screening system is not uniformly zero after deleting a use case, continue to delete the next use case in the use case code call graph until all corresponding use cases in the use case screening system are tentatively deleted, and then use the use case in the use case code call graph after screening as the test case.
7. A program testing device, characterized in that: include: A use case search module is used to obtain a code modification list corresponding to the called system, and search the use case code mapping table of the called system according to the code modification list to obtain a use case list corresponding to the modified code in the called system; A system determination module, used to determine the calling system corresponding to the called system according to the code modification list, and obtain the regression code corresponding to the calling system; A list search module is used to query the use case code mapping table of the calling system according to the regression code to obtain a use case list corresponding to the calling system; A use case screening module, used to screen the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, and test the modified code in the called system and the regression code corresponding to the calling system according to the test cases; The use case screening module screens the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system to obtain test cases, including: Draw a use case code call graph according to the use case list corresponding to the modified code in the called system and the use case list corresponding to the calling system; Determine the in-degree of the called system and the in-degree of the calling system respectively according to the use case code call graph; the in-degree of the called system is the number of use cases in the code modification list that directly call the modification code of the called system, and the in-degree of the calling system is the number of use cases in the use case list that directly call the regression code of the calling system; The use cases in the use case code call graph are screened according to the in-degree of the called system and the in-degree of the calling system to obtain the test case.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the program testing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the program testing method as described in any one of claims 1 to 6 is implemented.
