Use Case Recommendation Method, Device, Equipment and Storage Medium
By identifying the code updated change function and its call chain in the target application, and using the corresponding relationship between the use case and the call chain to recommend the use cases to be tested, the problems of low efficiency and lack of targeting regression testing in the existing technology are solved, and efficient and accurate regression testing is achieved.
Patent Information
- Application Number
- CN202210566923.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2042-05-23
AI Technical Summary
The prior art conducts comprehensive inspection of full use cases after the code changes of the target application, resulting in inefficient and lack of targeting regression testing.
By obtaining new task data based on the sustainable learning model, determining the code updated change function and its related call chain, and recommending the use cases to be tested based on the correspondence between the use case and the call chain.
It improves the efficiency of regression testing, makes it targeted, and improves the accuracy of the test, reducing the detection requirement for full use cases.
Smart Images

Figure CN114911706B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer and Internet technology, and in particular to a use case recommendation method, device, equipment and storage medium. Background Art
[0002] As the business of the target application is adjusted, the software system often needs to make code changes to adapt to the business adjustments.
[0003] Currently, after a change to the code is detected, each use case of the target application is fully tested to detect whether the changed code has an impact on the existing use cases of the target application, and then subsequent adjustments or modifications are made to the affected use cases.
[0004] However, in the above-mentioned related technologies, each use case of the target application is tested, and the efficiency of the entire regression test is low and lacks specificity. Summary of the invention
[0005] The embodiment of the present application provides a use case recommendation method, apparatus, device and storage medium, which improves the efficiency of the entire regression test and makes the entire regression test more targeted. The technical solution is as follows.
[0006] According to one aspect of an embodiment of the present application, a use case recommendation method is provided, the method comprising the following steps:
[0007] Acquire unlearned new task data based on the sustainable learning model;
[0008] Acquire a first code of a target application, where the first code is a code that is updated in the target application;
[0009] determining a change function according to the first code;
[0010] Based on the changed function, determining a first call chain from at least one call chain included in the target application, wherein the first call chain refers to a call chain associated with the changed function;
[0011] According to the correspondence between the use case and the call chain, the use case corresponding to the first call chain is determined as a recommended use case to be tested.
[0012] According to one aspect of an embodiment of the present application, a use case recommendation device is provided, the device comprising the following modules:
[0013] A code acquisition module, used to acquire a first code of a target application, where the first code is an updated code in the target application;
[0014] A function determination module, used for determining a change function according to the first code;
[0015] A call chain determination module, configured to determine a first call chain from at least one call chain included in the target application based on the change function, where the first call chain refers to a call chain associated with the change function;
[0016] A use case determination module, configured to determine, according to the correspondence between use cases and call chains, the use case corresponding to the first call chain as a recommended use case to be tested.
[0017] According to one aspect of the embodiments of the present application, the embodiments of the present application provide a computer device, which includes a processor and a memory. At least one program is stored in the memory, and the at least one program is loaded and executed by the processor to implement the above-mentioned use case recommendation method.
[0018] According to one aspect of the embodiments of the present application, the embodiments of the present application provide a computer-readable storage medium, in which at least one program is stored, and the at least one program is loaded and executed by a processor to implement the above-mentioned use case recommendation method.
[0019] According to one aspect of the embodiments of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned use case recommendation method.
[0020] The technical solution provided by the embodiments of the present application can bring the following beneficial effects:
[0021] By determining the call chain corresponding to the change function through the change function corresponding to the code, and then according to the correspondence between use cases and call chains, taking the use case corresponding to the call chain as the recommended use case to be tested. On the one hand, after the code of the target application is updated, it is not necessary to detect all use cases of the target application to determine the recommended use case to be tested, which improves the determination efficiency of the recommended use case and the efficiency of the entire regression test. On the other hand, the update of the code is locked to a more detailed function change to determine the change function, associate the change function with the call chain, and further determine the recommended use case according to the correspondence between the use case and the call chain, which improves the accuracy of the determined recommended use case, makes the entire regression test targeted, and improves the accuracy of the entire regression test. Description of the Drawings
[0022] Figure 1 It is a schematic diagram of the architecture of a use case recommendation platform provided by an embodiment of the present application;
[0023] Figure 2 Exemplarily shows a schematic diagram of a use case recommendation system;
[0024] Figure 3 Is a flowchart of a use case recommendation method provided by an embodiment of the present application;
[0025] Figure 4 Exemplarily shows a flowchart of a method for obtaining the correspondence between a use case and a call chain;
[0026] Figure 5 Exemplarily shows a flowchart of a method for obtaining the correspondence between code and a call chain;
[0027] Figure 6 Exemplarily shows a schematic diagram of the process of a use case recommendation method;
[0028] Figure 7 Is a block diagram of a use case recommendation device provided by an embodiment of the present application;
[0029] Figure 8 Is a block diagram of a use case recommendation device provided by another embodiment of the present application;
[0030] Fig. 9 Is a block diagram of the structure of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0031] To make the objectives, technical solutions, and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.
[0032] Please refer to Figure 1 , which shows a schematic diagram of the architecture of a use case recommendation platform provided by an embodiment of the present application. The use case recommendation platform may include a presentation layer 10, a logic layer 20, a storage layer 30, and a basic service layer 40.
[0033] The display layer 10 is used to display information to present it to the user. In the embodiments of the present application, the display layer 10 can display a recommended use case list, a full set of use case list, a recorded use case list, an affected call chain list, call chain detail data, recording details, etc. Among them, the recommended use case list includes recommended use cases, which refer to the use cases that may be affected after the code of the target application is updated; the full set of use case list refers to all the use cases included in the target application; the recorded use case list includes the executed use cases, which refer to the use cases that have been executed, and by executing the use cases, the call chain corresponding to the use cases can be determined; the affected call chain list includes the affected call chains, which refer to the call chains that may be affected after the code of the target application is updated; the call chain detail data refers to the call relationships between the functions included in the call chain; the recording details refer to the recorded data during the execution of the use cases. Exemplarily, the recorded data is a screenshot or video during the execution of the use cases. In some embodiments, the above-mentioned users include developers and testers. Among them, the developers update the code of the target application; the testers conduct use case tests on the recommended use cases according to the recommended use case list to detect whether the code update affects the use cases. It should be noted that the above introduction to the content displayed by the display layer 10 is only exemplary and explanatory. In the exemplary embodiments, the content displayed by the display layer 10 can be flexibly set and adjusted according to the actual situation; exemplarily, when the code of the target application has not been updated, only the full set of use case list is displayed, and when the code of the target application is updated, the recommended use case list is displayed again.
[0034] The logic layer 20 is used for data processing. In the embodiments of the present application, the logic layer 20 includes a recommended use case determination section, an affected call chain determination section, a use case aggregation section, a normalization section, and a recording data processing section. Among them, the recommended use case determination section is used to determine the use cases that may be affected after the code of the target application is updated as candidate use cases; the affected call chain determination section is used to determine the call chains that may be affected after the code of the target application is updated; the use case aggregation section is used to determine the recommended use cases from the candidate use cases; the normalization section is used to process the data format to keep the data format unified; the recording data processing section is used to determine the recording details.
[0035] The storage layer 30 is used to store data. In the embodiments of the present application, the data stored in the storage layer 30 includes: the call chain of the target application, the use cases of the target application, the code of the target application, the correspondence between the code of the target application and the call chain, and the correspondence between the use cases of the target application and the call chain, etc. In some embodiments, the logic layer 20 obtains the data stored in the storage layer 30, and then processes the data to obtain the content to be displayed by the display layer 10. Exemplarily, the logic layer 20 determines a recommended use case list based on the correspondence between the use cases of the target application stored in the storage layer 30 and the call chain, and then the display layer 10 displays the recommended use case list.
[0036] The basic service layer 40 is used to provide underlying services for the use case recommendation platform. In the embodiments of the present application, the basic service layer 40 can provide a static call chain acquisition service and a dynamic call chain acquisition service for the use case recommendation platform. Among them, the static call chain acquisition service is used to obtain a static call chain, and the static call chain is used to represent the correspondence between the code of the target application and the call chain; the dynamic call chain acquisition service is used to obtain a dynamic call chain, and the dynamic call chain is used to represent the correspondence between the use cases of the target application and the call chain.
[0037] It should be noted that the above is an introduction to the use case recommendation platform taking the target application as an example. In the exemplary embodiments, the use case recommendation platform is also applicable to other applications, and the embodiments of the present application do not limit this.
[0038] Optionally, the above use case recommendation platform can be applied to a use case recommendation system. Exemplarily, as Figure 2 shown, the use case recommendation system includes a terminal device 50 and a server 60.
[0039] The terminal device 50 can be an electronic device such as a tablet computer, a PC (Personal Computer), etc., and the embodiments of the present application do not limit this. In some embodiments, the terminal device 50 includes a client of the above use case recommendation platform.
[0040] The server 60 is used to provide background services for the terminal device 50. The server 60 can be a single server, or a server cluster composed of multiple servers, or a cloud computing service center. Optionally, the server 60 can be the background server of the client of the above use case recommendation platform. In the exemplary embodiments, the server 60 provides background services for the clients of the use case recommendation platform in multiple terminal devices 50.
[0041] Data is transmitted between the above terminal device 50 and the above server 60 through a network.
[0042] In some embodiments, the above terminal device 50 includes a first terminal device and a second terminal device. The first terminal device refers to the terminal device used by developers, and the second terminal device refers to the terminal device used by testers. In the embodiments of the present application, the developer submits updated code through the first terminal device, and the server determines the recommended test cases based on the updated code, and displays the recommended test cases through the second terminal device. It should be noted that the above introduction to the terminal device 50 and the server 60 is only exemplary and explanatory. In the exemplary embodiments, the functions of the terminal device 50 and the server 60 can be flexibly set and adjusted; exemplarily, the terminal device 50 has strong load capacity and data processing capacity, and the terminal device 50 determines the recommended test cases based on the updated code.
[0043] Please refer to Figure 3 , which shows a flowchart of a test case recommendation method provided by an embodiment of the present application. Each step in this method can be executed by the above Figure 2 terminal device 50 and / or server 60 (hereinafter collectively referred to as "computer device"). This method may include at least one of the following steps (301 to 304):
[0044] Step 301, obtain the first code of the target application.
[0045] The target application can be any application, such as an instant messaging application, a social application, a game application, a reading application, etc., and the embodiments of the present application do not limit this. In some embodiments, the target application can be an application that needs to be downloaded and installed, or a small program that can be used immediately upon clicking.
[0046] In the embodiments of the present application, the target application includes test cases and code. Among them, the test cases are used to describe the functions of the target application, and the code refers to the basis for correctly executing the functions of the target application. In the exemplary embodiments, during the running of the target application, the corresponding functions described by the test cases are realized by executing the corresponding code. It should be noted that the test cases and code of the target application can be stored in the computer device, or can be stored in other computer devices.
[0047] In a possible implementation, use cases correspond to different scenarios, and the code executed by the use cases is different in different scenarios. Taking the use case for describing the data transmission function as an example, for the scenario of successful data transmission, the code executed by the use case includes: the relevant code for login, the relevant code for data upload, the relevant code for data sending, and the relevant code for receiving the first response, where the first response is used to indicate that the data is successfully transmitted to the target device; for the scenario of data transmission interruption, the code executed by the use case includes: the relevant code for login, the relevant code for data upload, the relevant code for data sending, and the relevant code for receiving the second response, where the second response is used to indicate that the data is not transmitted to the target device.
[0048] In another possible implementation, a use case corresponds to one scenario, that is, the code corresponding to different use cases is different. Exemplarily, if the use case is used to describe the login function, the code executed by the use case includes: the relevant code for login; if the use case is used to describe the account switching function, the code executed by the use case includes: the relevant code for login and the relevant code for logging out.
[0049] In some embodiments, the code of the target application changes with the adjustment of the business. In the embodiments of the present application, in order to determine whether the change of the code will affect the use cases of the target application, the computer device obtains the first code of the target application, and the first code is the code that has been updated in the target application. The update of the code includes, but is not limited to, at least one of the following: submission of new code, modification of code, deletion of code, etc.
[0050] In some embodiments, the first code can be automatically obtained by the computer device, or the first code can be submitted by the user. In a possible implementation, the first code is automatically obtained by the computer device. The computer device detects the difference between the historical code and the target code of the target application. Further, in the case where there is no difference between the historical code and the target code, it is determined that there is no updated code in the target application. Correspondingly, in the case where there is a difference between the historical code and the target code, it is determined that there is updated code in the target application, and then the above-mentioned first code is obtained. It should be noted that in this case, the computer device can directly determine the different code as the above-mentioned first code; or, the computer device can also use the different code as the center and select the code that can be completely compiled as the above-mentioned first code. In another possible implementation, the first code is submitted by the user. When the computer device detects the code submitted by the user, it determines the code as the above-mentioned first code.
[0051] Step 302, determine the changed function according to the first code.
[0052] The code of the target application includes functions. In the embodiments of the present application, after the computer device obtains the above first code, it determines the changed function according to the first code. Among them, the changed function refers to the function that has been changed and updated in the target application. The update of the function includes, but is not limited to, at least one of the following: addition of a new function, modification of a function, deletion of a function, etc. It should be noted that the number of changed functions determined according to the first code can be one or more, and the embodiments of the present application do not limit this.
[0053] In some embodiments, when the computer device determines the changed function, it obtains the code modification position of the first code, and then determines the changed function based on the code modification position. Among them, the code modification position refers to the position where the code is updated in the first code.
[0054] In some embodiments, the first code corresponds to a source code, that is, the first code is obtained by modifying the source code.
[0055] In a possible implementation manner, the computer device determines the above code modification position according to the difference between the first code and the source code. In some embodiments, after the computer device obtains the above first code, it determines the code modification position based on the difference between the first code and the source code. Among them, the above modification includes adding code, changing code, and deleting code. Exemplarily, if the first code is obtained by adding code to the source code, the computer device determines the difference between the first code and the source code as the newly added code, and further determines the position where the newly added code is located in the first code as the above code modification position; if the first code is obtained by changing code to the source code, the computer device determines the difference between the first code and the source code as the changed code, and determines the position where the changed code is located in the first code as the above code modification position; if the first code is obtained by deleting code from the source code, the computer device determines the difference between the first code and the source code as the deleted code, and further determines the position where the deleted code is located in the source code as the above code modification position.
[0056] In another possible implementation, the computer device determines the above-mentioned code modification location according to the user's modification operation on the source code. In some embodiments, detection probes are set in the source code. When it is determined that the source code is modified, the detection probes record the code modification location and provide the code modification location to the computer device. Among them, the detection probes are inserted into the code during code compilation. Among them, the above-mentioned modification operations include code addition operations, code change operations, and code deletion operations. Exemplarily, if the first code is obtained by adding code to the source code, the detection probes record the location of the newly added code in the first code and determine this location as the above-mentioned code modification location; if the first code is obtained by changing the code based on the source code, the detection probes record the location of the changed code in the first code and determine this location as the above-mentioned code modification location; if the first code is obtained by deleting code from the source code, the detection probes record the location of the deleted code in the source code and determine this location as the above-mentioned code modification location.
[0057] Of course, in still another possible implementation, the user may report the above-mentioned code modification location to the computer device, and the embodiments of the present application do not limit this.
[0058] In some embodiments, the first code does not correspond to the source code, that is, the first code is newly submitted by the developer for the target application program. In this case, the location of the first code in the full-scale code of the target application program is determined as the above-mentioned code modification location.
[0059] In some embodiments, when the computer device determines the changed function based on the above-mentioned code modification location, it may determine all the functions included in the code modification location as the above-mentioned changed function; or, when the computer device determines the changed function based on the above-mentioned code modification location, it detects and determines the function that has been updated from the code modification location as the above-mentioned changed function. It should be noted that if the above-mentioned first code is newly submitted by the developer for the target application program, all the functions included in the first code are the above-mentioned changed functions.
[0060] Step 303: Determine the first call chain from at least one call chain included in the target application program based on the changed function.
[0061] In the embodiments of the present application, after the computer device determines the above-mentioned changed function, it determines the first call chain from at least one call chain included in the target application program based on the changed function. Among them, the first call chain refers to the call chain associated with the changed function.
[0062] It should be noted that, since there are call relationships between functions in the code of the target application, the above first call chain may include the changed function, or the calling functions that have call relationships with the changed function. The specific method for obtaining the first call chain is described below and will not be elaborated here.
[0063] Step 304: Determine the use case corresponding to the first call chain as the recommended use case to be tested according to the correspondence between the use case and the call chain.
[0064] In the embodiment of the present application, after the computer device determines the above first call chain, it determines the use case corresponding to the first call chain as the recommended use case to be tested according to the correspondence between the use case and the call chain. In some embodiments, in order to improve the determination efficiency of the recommended use case, the correspondence between the use case and the call chain may be pre-stored. Among them, if the correspondence between the use case and the call chain can be pre-stored in this computer device, it can also be stored in other computer devices to reduce the storage load of this computer device.
[0065] In a possible implementation manner, when the computer device obtains the above recommended use case, it determines the full set of use cases corresponding to the first call chain according to the correspondence between the use case and the call chain, and uses all the full set of use cases as the recommended use cases to be tested.
[0066] In another possible implementation manner, since one call chain may correspond to multiple use cases, when the computer device obtains the above recommended use case, it determines the full set of use cases corresponding to the first call chain according to the correspondence between the use case and the call chain, and performs an aggregation process on the full set of use cases to screen and determine the recommended use cases to be tested. The specific method is described below and will not be elaborated here.
[0067] In summary, in the technical solution provided by the embodiment of the present application, the call chain corresponding to the changed function is determined through the changed function corresponding to the code, and then, according to the correspondence between the use case and the call chain, the use case corresponding to the call chain is used as the recommended use case to be tested. On the one hand, after the code of the target application is updated, it is not necessary to detect all the use cases of the target application to determine the recommended use cases to be tested, which improves the determination efficiency of the recommended use cases and the efficiency of the entire regression test. On the other hand, the code update is locked to a more detailed function change to determine the changed function, the changed function is associated with the call chain, and further, the recommended use case is determined based on the correspondence between the use case and the call chain, which improves the accuracy of the determined recommended use case, makes the entire regression test targeted, and improves the accuracy of the entire regression test.
[0068] In addition, the changed function is determined based on the code modification position, that is, the changed function is determined based on the position where the code is updated, without traversing the functions in the full amount of code to determine the changed function, which improves the accuracy of the changed function and the determination efficiency of the changed function, and further improves the efficiency of the entire regression test.
[0069] Next, the method for obtaining the above first call chain will be introduced.
[0070] In an exemplary embodiment, step 303 above includes at least one of the following steps:
[0071] 1. Determine the calling function that has a calling relationship with the changed function.
[0072] In the embodiment of the present application, after the computer device obtains the above changed function, it determines the calling function that has a calling relationship with the changed function. Among them, the calling relationship includes calling and being called. In some embodiments, if the calling relationship between the changed function and the calling function is calling, then in the code, the changed function calls the calling function; if the calling relationship between the changed function and the calling function is being called, then in the code, the changed function is called by the calling function. Among them, calling includes direct calling and indirect calling. In some embodiments, if the calling relationship between the changed function and the calling function is direct calling, then in the code, the changed function directly calls the calling function, that is, during the execution of the code, there is no other function between the changed function and the calling function; if the calling relationship between the changed function and the calling function is indirect calling, then in the code, the changed function indirectly calls the calling function, that is, during the execution of the code, there is other function between the changed function and the calling function. Similarly, being called includes direct being called and indirect being called.
[0073] In a possible implementation manner, when the computer device determines the above calling function, it determines a second call chain from at least one call chain included in the target application. The second call chain is a call chain that includes the changed function and the calling function that has a calling relationship with the changed function. Further, based on the second call chain, the calling function that has a calling relationship with the changed function is determined. In some embodiments, the computer device takes the changed function as a reference, determines the call chain including the changed function from at least one call chain included in the target application as the second call chain, and then determines the function that has a calling relationship with the changed function from the second call chain as the above calling function.
[0074] In another possible implementation, when the computer device determines the above-mentioned calling function, it performs instrumentation compilation on the first code to determine the calling function that has a calling relationship with the changed function. In some embodiments, the computer device performs instrumentation compilation on the above-mentioned first code to obtain at least one call chain corresponding to the first code, and then determines the call chain containing the changed function from the at least one call chain corresponding to the first code, and determines the function that has a calling relationship with the changed function from the call chain containing the changed function as the above-mentioned calling function. Of course, in other embodiments, since the relationship between functions can be determined during the instrumentation compilation process, therefore, after performing instrumentation compilation on the first code, directly determine the calling function that has a calling relationship with the changed function, and at the same time obtain at least one call chain corresponding to the first code. Among them, instrumentation compilation refers to inserting detection probes during the code compilation process.
[0075] Of course, in yet another possible implementation, when the computer device determines the above-mentioned calling function, it determines a second call chain from at least one call chain included in the target application, and the second call chain is a call chain that includes the changed function and the calling function that has a calling relationship with the changed function. Further, based on the second call chain, determine the calling function that has a calling relationship with the changed function; and perform instrumentation compilation on the first code to determine the calling function that has a calling relationship with the changed function. In this case, the above-mentioned calling function includes the calling function determined from the second call chain and the calling function obtained through instrumentation compilation.
[0076] It should be noted that the above acquisition of the calling function is only exemplary and explanatory. In the exemplary embodiment, the computer device can flexibly select a suitable method to obtain the above-mentioned calling function according to the actual situation. Exemplarily, if the changed function is a newly added function and the changed function has not appeared in the code of the target application before, it is determined that none of the existing call chains in the target application include the changed function, and then the above-mentioned calling function is determined through the instrumentation compilation of the first code; if the changed function is a newly added function and the changed function has appeared in the code of the target application before, it is determined that there is a call chain in the target application that includes the changed function, and then the above-mentioned calling function is determined through the instrumentation compilation of the first code and the second call chain; if the changed function is obtained by modifying an existing function, when the use case corresponding to the first code runs normally, the above-mentioned calling function is determined through the second call chain.
[0077] 2. Select the call chain that includes the changed function or the calling function from at least one call chain included in the target application as the first call chain.
[0078] In an embodiment of the present application, after the computer device determines the above-mentioned calling function and the above-mentioned change function, it selects, from at least one call chain included in the target application, a call chain that includes the change function or the calling function as the first call chain. That is to say, the first call chain only includes the change function; or, the first call chain only includes the calling function; or, the first call chain includes the change function and the calling function. Wherein, the number of the first call chains can be one or more, and the embodiments of the present application do not limit this.
[0079] In summary, in the technical solution provided by the embodiment of the present application, the first call chain is determined through the change function and the calling function that has a call relationship with the change function. The calling function belongs to the function affected by the change function. The first call chain includes the call chain affected by the change function, the call chain affected by the calling function, and the call chain affected by both the change function and the calling function, making the determined first call chain more comprehensive and improving the determination accuracy of the first call chain.
[0080] In addition, when determining the change function, on the one hand, the calling function that has a call relationship with the change function is determined from the existing call chains of the target application, that is, the calling function is determined based on the existing call relationship of the target application. On the other hand, the first code is instrumented and compiled to determine the calling function that has a call relationship with the change function, that is, the calling function is determined based on the updated code, making the determined first call chain more comprehensive and accurate, and thus improving the determination accuracy of the subsequent first call chain.
[0081] Next, the determination method of the above recommended use cases will be introduced.
[0082] In an exemplary embodiment, step 304 above includes at least one of the following steps:
[0083] 1. Determine a plurality of use cases corresponding to the first call chain as a candidate use case set according to the correspondence between the use case and the call chain;
[0084] 2. Take out a candidate use case from the candidate use case set as a reserved use case and add it to the reserved use case set;
[0085] 3. Determine whether there are unextracted candidate use cases in the candidate use case set;
[0086] 4. If there are unextracted candidate use cases in the candidate use case set, take out a target candidate use case from the candidate use case set and perform coverage comparison with each reserved use case in the reserved use case set;
[0087] 5. If there are no unextracted candidate use cases in the candidate use case set, use the reserved use cases in the reserved use case set as the recommended use cases.
[0088] In an embodiment of the present application, after the computer device determines the above-mentioned first call chain, according to the correspondence between use cases and call chains, it determines multiple use cases corresponding to the first call chain as a candidate use case set. Among them, the multiple use cases can be all use cases corresponding to the first call chain. After that, the computer device takes out a candidate use case from the candidate use case set as a retained use case and adds it to the retained use case set. Among them, the retained use case can be randomly selected from the candidate use case set.
[0089] In an embodiment of the present application, when the computer device determines that there is a retained use case in the retained use case set, it determines whether there are unextracted candidate use cases in the candidate use case set; further, if there are unextracted candidate use cases in the candidate use case set, it takes out a target candidate use case from the candidate use case set and performs a coverage comparison with each retained use case in the retained use case set.
[0090] In a possible implementation manner, during the coverage comparison process, if there is a first retained use case in the retained use case set that functionally covers the target candidate use case, the target candidate use case is excluded, and the process starts again from the step of determining whether there are unextracted candidate use cases in the above-mentioned candidate use case set.
[0091] In another possible implementation manner, during the coverage comparison process, if there is a second retained use case in the retained use case set that is functionally covered by the target candidate use case, the second retained use case is excluded from the retained use case set, the target candidate use case is added to the retained use case set, and the process starts again from the step of determining whether there are unextracted candidate use cases in the above-mentioned candidate use case set.
[0092] In still another possible implementation manner, during the coverage comparison process, if there is no first retained use case and no second retained use case in the retained use case set, the target candidate use case is added to the retained use case set, and the process starts again from the step of determining whether there are unextracted candidate use cases in the above-mentioned candidate use case set.
[0093] In an embodiment of the present application, if there are no unextracted candidate use cases in the candidate use case set, the retained use cases in the retained use case set are used as recommended use cases.
[0094] In summary, in the technical solution provided by the embodiment of the present application, by screening candidate use cases to determine recommended use cases, considering the problem that the number of candidate use cases initially determined according to the first call chain is too large in the case where one call chain corresponds to multiple use cases, and screening candidate use cases based on the functional coverage relationship between use cases to obtain the final recommended use cases, reducing the number of recommended use cases and improving the efficiency of the entire regression test.
[0095] Next, the correspondence between use cases and call chains, and the method for obtaining the correspondence between code and call chains will be introduced.
[0096] Please refer to Figure 4 , which shows a flowchart of a method for obtaining the correspondence between use cases and call chains provided by an embodiment of the present application. Each step in this method can be executed by the terminal device 50 and / or the server 60 (collectively referred to as "computer devices") in the above Figure 2 . This method may include at least one of the following steps (401 to 403):
[0097] Step 401, in response to a running instruction for any use case in the target application, run the use case.
[0098] The running instruction is used to control the running of the use case. Among them, the running instruction may be an instruction automatically initiated by the computer device or an instruction initiated by the user. The embodiments of the present application do not limit this. In the embodiments of the present application, when the computer device detects a running instruction for any use case in the target application, it runs the use case.
[0099] In some embodiments, in order to record the use case running process, when the computer device detects a running instruction for any use case in the target application, it runs the use case and starts recording the use case running process at the same time. After that, when it detects a stop instruction for the use case, it stops running the use case and stops recording the use case running process, generating a video file for recording the use case running process.
[0100] In some embodiments, after obtaining the above video file, the computer device can directly store the video file as the recording data for the use case; or, the computer device can also perform frame division processing on the video file to obtain video image frames, and store the video image frames as the recording data for the use case.
[0101] Of course, in an exemplary embodiment, the computer device can also run multiple use cases. In one possible implementation, the above running instruction is used to control the running of multiple use cases. After detecting the running instruction, the computer device runs the multiple use cases based on the execution order of the running instruction, and records the running process of the multiple use cases. Then, in the case of detecting a stop instruction, the computer device stops running the use cases and generates a video file for recording the running process of the multiple use cases. In some embodiments, after obtaining the video file, the computer device can extract the video files corresponding to each use case from the video file for storage; alternatively, the computer device can also extract the video files corresponding to each use case from the video file, and perform frame splitting processing on the video files corresponding to each use case respectively to obtain the video image frames corresponding to each use case, and store the video image frames as recording data.
[0102] Step 402: Obtain the second code executed in the target application during the running of the use case.
[0103] In the embodiment of the present application, during the running of the use case, the computer device obtains the second code executed in the target application during the running of the use case.
[0104] Step 403: Based on the correspondence between the code and the call chain, determine the call chain corresponding to the second code as the call chain corresponding to the use case, and record the correspondence between the use case and the call chain.
[0105] In the embodiment of the present application, after obtaining the above second code, the computer device determines the call chain corresponding to the second code as the call chain corresponding to the use case based on the correspondence between the code and the call chain, and records the correspondence between the use case and the call chain.
[0106] Among them, if the correspondence between the code and the call chain can be pre-stored in this computer device, or can also be stored in other computer devices to reduce the storage load of this computer device, the embodiment of the present application does not limit this.
[0107] In summary, in the technical solution provided by the embodiment of the present application, during the running of the use case, taking the code as a link, according to the code required for running the use case and the correspondence between the code and the call chain, the correspondence between the use case and the call chain is determined, and the use case and the call chain are directly associated, which is convenient for determining the recommended use cases to be tested according to the call chain associated with the changed function in the subsequent stage, optimizing the management performance of the use cases, and improving the efficiency of the entire regression test.
[0108] Please refer to Figure 5 , which shows a flowchart of a method for obtaining the correspondence between the code and the call chain provided by an embodiment of the present application. Each step in this method can be performed by the above Figure 2 The terminal device 50 and / or the server 60 (hereinafter collectively referred to as "computer device") in
[0109] Step 501: Perform instrumentation compilation on any code included in the target application to obtain the target function included in the code.
[0110] Instrumentation compilation refers to inserting a probe pointer during the code compilation process. In the embodiments of the present application, after the computer device detects any code included in the target application submitted by the user, it performs instrumentation compilation on the code to obtain the target function included in the code. Among them, the target function can be any function in the code, and the embodiments of the present application do not limit this.
[0111] Step 502: Obtain other functions that have a call relationship with the target function to obtain the call chain corresponding to the target function.
[0112] In the embodiments of the present application, after the computer device obtains the above target function, it obtains other functions that have a call relationship with the target function from the above code to obtain the call chain corresponding to the target function. In some embodiments, when the target function has a calling function, the computer device obtains the calling function called by the target function and determines the calling function called by the target function as the new target function, and starts to execute from the step of obtaining the calling function called by the target function when the target function has a calling function until the target function has no calling function; further, based on the call relationship between the target function and other functions in the code, the call chain corresponding to the target function is obtained.
[0113] Step 503: Use the call chain corresponding to the target function as the call chain corresponding to the code, and record the corresponding relationship between the code and the call chain.
[0114] In the embodiments of the present application, after the computer device obtains the call chain corresponding to the above target function, it uses the call chain corresponding to the target function as the call chain corresponding to the code, and records the corresponding relationship between the code and the call chain.
[0115] In some embodiments, the code corresponds to multiple call chains. After the computer device obtains the call chain corresponding to the target function, it obtains the functions that have no call relationship with the target function from the code, and uses this function as the new target function to repeat the above steps to obtain the call chain corresponding to the new target function, and so on, until there are no functions outside the call chain in the code.
[0116] In summary, in the technical solution provided by the embodiments of the present application, by instrumenting and compiling the code to obtain the call chain corresponding to the code, the management performance of the code and the call chain is optimized. Subsequently, the code can be used as a link to determine the correspondence between the use case and the call chain based on the code required by the running use case and the correspondence between the code and the call chain.
[0117] In addition, in combination with reference Figure 6 , a complete introduction to the use case recommendation method in the present application is given. The specific steps are as follows:
[0118] Step 601, the developer submits the code of the target application to the computer device.
[0119] Step 602, the computer device performs instrumentation encoding on the code of the target application through a compilation plug-in to obtain the code compilation result.
[0120] Step 603, the background service of the use case recommendation platform in the computer device determines and stores the correspondence between the code and the call chain according to the code compilation result.
[0121] Step 604, the tester issues a running instruction for the use case to the computer device.
[0122] Step 605, the computer device runs the use case and records the running process of the use case.
[0123] Step 606, the computer device determines the call chain corresponding to the use case according to the code corresponding to the use case and the call chain corresponding to the code.
[0124] Step 607, the tester issues a stop instruction for the use case to the computer device.
[0125] Step 608, the computer device stops running the use case.
[0126] Step 609, the computer device reports the recorded data to the background service of the use case recommendation platform through the reporting interface.
[0127] Step 610, the background service of the use case recommendation platform parses the recorded data to determine and record the correspondence between the use case and the call chain, as well as the recorded data of the use case.
[0128] Step 611, the developer submits the first code to the computer device.
[0129] Step 612, the background service of the use case recommendation platform calculates the changed functions of the first code.
[0130] Step 613, the background service of the use case recommendation platform calculates the first call chain according to the changed functions.
[0131] Step 614, the backend service of the use case recommendation platform determines the recommended use cases to be tested according to the correspondence between the use cases and the call chains.
[0132] Step 615, the client of the use case recommendation platform displays the list of recommended use cases to the developer through the recommended use case interface.
[0133] In some embodiments, the following steps are further included:
[0134] Step 616, the client of the use case recommendation platform displays the first call chain list to the developer through the call chain influence interface.
[0135] The following is the device embodiment of the present application, which can be used to execute the method embodiment of the present application. For the details not disclosed in the device embodiment of the present application, please refer to the method embodiment of the present application.
[0136] Please refer to Figure 7 , which shows a block diagram of a use case recommendation device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned use case recommendation method, and the function can be implemented by hardware or by hardware executing corresponding software. The device can be a computer device or can be set in a computer device. The device 700 may include: a code acquisition module 710, a function determination module 720, a call chain determination module 730, and a use case determination module 740.
[0137] The code acquisition module 710 is used to acquire the first code of the target application, and the first code is the code that has been updated in the target application.
[0138] The function determination module 720 is used to determine the changed function according to the first code.
[0139] The call chain determination module 730 is used to determine the first call chain from at least one call chain included in the target application based on the changed function, and the first call chain refers to the call chain associated with the changed function.
[0140] The use case determination module 740 is used to determine the use case corresponding to the first call chain as the recommended use case to be tested according to the correspondence between the use cases and the call chains.
[0141] In an exemplary embodiment, the call chain determination module 730 is further used to determine the call function that has a call relationship with the changed function; select the call chain that includes the changed function or the call function from at least one call chain included in the target application as the first call chain.
[0142] In an exemplary embodiment, the call chain determination module 730 is further configured to determine a second call chain from at least one call chain included in the target application, where the second call chain is a call chain that includes the changed function and call functions having a call relationship with the changed function; and determine the call functions based on the second call chain.
[0143] In an exemplary embodiment, the call chain determination module 730 is further configured to perform instrumentation compilation on the first code to determine call functions having a call relationship with the changed function.
[0144] In an exemplary embodiment, the use case determination module 740 is further configured to:
[0145] Determine multiple use cases corresponding to the first call chain as a candidate use case set according to the correspondence between the use cases and the call chains;
[0146] Take out one candidate use case from the candidate use case set as a retained use case and add it to the retained use case set;
[0147] Determine whether there are unselected candidate use cases in the candidate use case set;
[0148] If there are unselected candidate use cases in the candidate use case set, take out a target candidate use case from the candidate use case set and perform coverage comparison with each retained use case in the retained use case set;
[0149] If there is a first retained use case in the retained use case set that functionally covers the target candidate use case, eliminate the target candidate use case, and start executing again from the step of determining whether there are unselected candidate use cases in the candidate use case set;
[0150] If there is a second retained use case in the retained use case set that is functionally covered by the target candidate use case, eliminate the second retained use case from the retained use case set, add the target candidate use case to the retained use case set, and start executing again from the step of determining whether there are unselected candidate use cases in the candidate use case set;
[0151] If there is no first retained use case and no second retained use case in the retained use case set, add the target candidate use case to the retained use case set, and start executing again from the step of determining whether there are unselected candidate use cases in the candidate use case set;
[0152] If there are no unselected candidate use cases in the candidate use case set, use the retained use cases in the retained use case set as the recommended use cases.
[0153] In an exemplary embodiment, the function determination module 720 is further configured to:
[0154] Obtain the code modification position of the first code, where the code modification position refers to the position in the first code where code updates occur;
[0155] Determine the change function based on the code modification position.
[0156] In an exemplary embodiment, as Figure 8 shown, the apparatus 700 further includes:
[0157] A use case running module 750, configured to run the use case in response to a running instruction for any use case in the target application.
[0158] A first recording module 760, configured to obtain the second code executed in the target application during the running of the use case; based on the correspondence between the code and the call chain, determine the call chain corresponding to the second code as the call chain corresponding to the use case, and record the correspondence between the use case and the call chain.
[0159] In an exemplary embodiment, as Figure 8 shown, the apparatus 700 further includes:
[0160] A code compilation module 770, configured to perform stub compilation on any code included in the target application to obtain the target function included in the code.
[0161] A second recording module 780, configured to obtain other functions having a call relationship with the target function to obtain the call chain corresponding to the target function; use the call chain corresponding to the target function as the call chain corresponding to the code, and record the correspondence between the code and the call chain.
[0162] In summary, in the technical solution provided by the embodiments of the present application, the call chain corresponding to the change function is determined through the change function corresponding to the code, and then, based on the correspondence between the use case and the call chain, the use case corresponding to the call chain is used as the recommended use case to be tested. On the one hand, after the code of the target application is updated, it is not necessary to detect all use cases of the target application to determine the recommended use case to be tested, which improves the determination efficiency of the recommended use case and the efficiency of the entire regression test. On the other hand, the code update is locked to a more detailed function change to determine the change function, the change function is associated with the call chain, and further, the recommended use case is determined based on the correspondence between the use case and the call chain, which improves the accuracy of the determined recommended use case, makes the entire regression test targeted, and improves the accuracy of the entire regression test.
[0163] It should be noted that for the device provided in the above embodiments, when implementing its functions, only the division of the above function modules is used for illustration. In actual applications, the above functions can be allocated to different function modules according to needs, that is, the internal structure of the device is divided into different function modules to complete all or part of the functions described above. In addition, the device provided in the above embodiments and the method embodiments belong to the same concept. For the specific implementation process, please refer to the method embodiments and will not be elaborated here.
[0164] Please refer to Fig. 9 , which shows the structural block diagram of a computer device provided in an embodiment of the present application. This computer device can be used to implement the functions of the above use case recommendation method. Specifically:
[0165] The computer device 900 includes a central processing unit (CPU) 901, a system memory 904 including a random access memory (RAM) 902 and a read only memory (ROM) 903, and a system bus 905 connecting the system memory 904 and the central processing unit 901. The computer device 900 also includes a basic input / output system (Input / Output, I / O system) 906 for facilitating the transfer of information between various components within the computer, and a mass storage device 907 for storing an operating system 913, application programs 914, and other program modules 915.
[0166] The basic input / output system 906 includes a display 908 for displaying information and input devices 909 such as a mouse and a keyboard for user input. Both the display 908 and the input devices 909 are connected to the central processing unit 901 through an input / output controller 910 connected to the system bus 905. The basic input / output system 906 may also include an input / output controller 910 for receiving and processing inputs from multiple other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 910 also provides outputs to a display screen, a printer, or other types of output devices.
[0167] The mass storage device 907 is connected to the central processing unit 901 through a mass storage controller (not shown) connected to the system bus 905. The mass storage device 907 and its associated computer-readable medium provide non-volatile storage for the computer device 900. That is to say, the mass storage device 907 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0168] Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage devices, CD-ROM, DVD (Digital Video Disc), or other optical storage, magnetic tape cartridges, tapes, disk storage, or other magnetic storage devices. Of course, those skilled in the art will know that computer storage media is not limited to the above several types. The above-mentioned system memory 904 and mass storage device 907 can be collectively referred to as memory.
[0169] According to various embodiments of the present application, the computer device 900 can also run on a remote computer on the network through a network such as the Internet. That is, the computer device 900 can be connected to the network 912 through the network interface unit 911 connected to the system bus 905, or in other words, the network interface unit 911 can also be used to connect to other types of networks or remote computer systems (not shown).
[0170] The memory further includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the above use case recommendation method.
[0171] In an exemplary embodiment, a computer-readable storage medium is further provided. At least one instruction, at least one segment of program, a code set, or an instruction set is stored in the storage medium, and when the at least one instruction, the at least one segment of program, the code set, or the instruction set is executed by a processor, the above use case recommendation method is implemented.
[0172] Optionally, the computer-readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory), SSD (Solid State Drives), or optical discs, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0173] In an exemplary embodiment, there is also provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned use case recommendation method.
[0174] It should be understood that "a plurality of" mentioned herein refers to two or more. "And / or" describes the association relationship of associated objects and indicates that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after. In addition, the step numbers described herein only exemplarily show a possible execution sequence between steps. In some other embodiments, the above steps may not be executed in the order of the numbers. For example, two steps with different numbers are executed simultaneously, or two steps with different numbers are executed in the reverse order of the illustration. The embodiments of the present application do not limit this.
[0175] The above are only exemplary embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A use case recommendation method, characterized in that, the method includes: Obtain the first code of the target application, where the first code is the code that has been updated in the target application; Determine the changed function according to the first code; If the changed function is a newly added function and the changed function has not appeared in the code of the target application before, then by instrumenting and compiling the first code, determine the calling function that has a calling relationship with the changed function; If the changed function is a newly added function and the changed function has appeared in the code of the target application before, then by instrumenting and compiling the first code, determine the calling function; and determine the calling function according to the second call chain determined from at least one call chain included in the target application, where the second call chain is a call chain that includes the changed function and the calling function; If the changed function is obtained by modifying an existing function, then when the use case corresponding to the first code runs normally, determine the calling function through the second call chain; Select a first call chain from at least one call chain included in the target application, where the first call chain includes a call chain that includes the changed function and a call chain that includes the calling function; Determine the use case corresponding to the first call chain as the recommended use case to be tested according to the code required to run the use case and the corresponding relationship between the use case and the call chain determined according to the corresponding relationship between the code and the call chain. One call chain corresponds to at least one use case. The process of determining the corresponding relationship between the code and the call chain is as follows: Instrument and compile any code included in the target application to obtain the target function included in the code; when there is a calling function for the target function, obtain the calling function called by the target function; determine the calling function called by the target function as the new target function, and execute the step of obtaining the calling function called by the target function again when there is a calling function for the target function until the target function has no calling function; obtain the call chain corresponding to the target function according to other functions that have a calling relationship with the target function; use the call chain corresponding to the target function as the call chain corresponding to the code, and record the corresponding relationship between the code and the call chain.
2. The method according to claim 1, characterized in that, the determining the use case corresponding to the first call chain as the recommended use case to be tested according to the corresponding relationship between the use case and the call chain includes: Determine multiple use cases corresponding to the first call chain as a candidate use case set according to the corresponding relationship between the use case and the call chain; Take out a candidate use case from the candidate use case set as the retained use case and add it to the retained use case set; Judge whether there are unextracted candidate use cases in the candidate use case set; If there are candidate use cases in the candidate use case set that have not been retrieved, retrieve a target candidate use case from the candidate use case set and perform coverage comparison with each retained use case in the retained use case set; If there is a first retained use case in the retained use case set that functionally covers the target candidate use case, eliminate the target candidate use case, and start executing again from the step of determining whether there are candidate use cases in the candidate use case set that have not been retrieved; If there is a second retained use case in the retained use case set that is functionally covered by the target candidate use case, eliminate the second retained use case from the retained use case set, add the target candidate use case to the retained use case set, and start executing again from the step of determining whether there are candidate use cases in the candidate use case set that have not been retrieved; If there is no such first retained use case and no such second retained use case in the retained use case set, add the target candidate use case to the retained use case set, and start executing again from the step of determining whether there are candidate use cases in the candidate use case set that have not been retrieved; If there are no candidate use cases in the candidate use case set that have not been retrieved, use the retained use cases in the retained use case set as the recommended use cases.
3. The method according to claim 1, wherein, said determining the change function according to the first code includes: obtaining the code modification position of the first code, where the code modification position refers to the position where code update occurs in the first code; determining the change function based on the code modification position.
4. The method according to any one of claims 1 to 3, wherein, the method further includes: responding to a running instruction for any use case in the target application, and running the use case; obtaining a second code executed in the target application during the running of the use case; based on the correspondence between the code and the call chain, determining the call chain corresponding to the second code as the call chain corresponding to the use case, and recording the correspondence between the use case and the call chain.
5. A use case recommendation device, wherein, the device includes: a code acquisition module, configured to acquire a first code of a target application, where the first code is the code that has been updated in the target application; a function determination module, configured to determine a change function according to the first code; The call chain determination module is used to, if the changed function is a newly added function and the changed function has not appeared in the code of the target application before, determine the calling function that has a call relationship with the changed function by performing first code instrumentation compilation; if the changed function is a newly added function and the changed function has appeared in the code of the target application before, determine the calling function by performing first code instrumentation compilation; and determine the calling function according to the second call chain determined from at least one call chain included in the target application, where the second call chain is a call chain that includes the changed function and the calling function; if the changed function is obtained by modifying an existing function, determine the calling function through the second call chain when the use case corresponding to the first code runs normally; select a first call chain from at least one call chain included in the target application, where the first call chain includes a call chain that includes the changed function and a call chain that includes the calling function; The use case determination module is used to determine the use case corresponding to the first call chain as the recommended use case to be tested according to the code required to run the use case and the corresponding relationship between the use case and the call chain determined according to the corresponding relationship between the code and the call chain. One call chain corresponds to at least one use case. The process of determining the corresponding relationship between the code and the call chain is as follows: Perform instrumentation compilation on any code included in the target application to obtain the target function included in the code; when there is a calling function for the target function, obtain the calling function called by the target function; determine the calling function called by the target function as the new target function, and perform the step of obtaining the calling function called by the target function again when there is a calling function for the target function until there is no calling function for the target function; obtain the call chain corresponding to the target function according to other functions that have a call relationship with the target function; use the call chain corresponding to the target function as the call chain corresponding to the code, and record the corresponding relationship between the code and the call chain.
6. A computer device, characterized in that, the computer device includes a processor and a memory, and at least one program is stored in the memory, and the at least one program is loaded and executed by the processor to implement the use case recommendation method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, at least one program is stored in the storage medium, and the at least one program is loaded and executed by a processor to implement the use case recommendation method according to any one of claims 1 to 4.
8. A computer program product, characterized in that, the computer program product includes a computer program, and the computer program is loaded and executed by a processor to implement the use case recommendation method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Black box regression test method
CN107193739A
Regression test method, device and system and computer readable storage medium
CN111045944A
Automatic test case determination method and device, equipment and storage medium
CN111382073A