Test case recommendation method and device, storage medium and electronic device

CN116610552BActive Publication Date: 2026-06-19GUANGZHOU SHIZHEN INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU SHIZHEN INFORMATION TECH CO LTD
Filing Date
2022-02-09
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In existing technologies, the recommendation of test cases is not accurate enough, which affects the effectiveness of software testing, and recommending too many test cases will affect testing efficiency.

Method used

By obtaining the number of times functions are called in the first test code, popularity levels are divided. Combining the code coverage information and association level of test cases with functions, recommended test cases that best meet user needs are generated.

Benefits of technology

It improves the accuracy and efficiency of software testing and reduces the recommendation of invalid or redundant test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116610552B_ABST
    Figure CN116610552B_ABST
Patent Text Reader

Abstract

This invention relates to a test case recommendation method, apparatus, storage medium, and electronic device. The method classifies the popularity level of each function based on the number of times each function is called in the first test code, determines the association level between each test case and each function based on code coverage information between each test case and each function, and then automatically generates recommended test cases that best meet the user's testing needs based on the popularity level information and association level information of each function in the second test code, as well as the popularity level information and association level information of the input recommended test cases. This method can effectively improve software testing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing, and in particular to a test case recommendation method, apparatus, storage medium, and electronic device. Background Technology

[0002] Software testing refers to the process of operating an application under specified conditions to discover program errors, measure application quality, and evaluate whether it meets design requirements. A test case is a set of test inputs, execution conditions, and expected results compiled for a specific purpose, in order to test a program path or verify whether a specific requirement is met.

[0003] Existing technologies typically select test cases based on the code coverage between the test case and the test code. However, the selected test cases are not accurate enough, which affects the effectiveness of software testing. Summary of the Invention

[0004] This application provides a test case recommendation method, apparatus, storage medium, and electronic device, which can accurately recommend test cases and improve the accuracy of software testing. The technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a test case recommendation method, comprising the following steps:

[0006] Obtain the number of times each function is called during the compilation of the first test code;

[0007] Based on the preset correspondence between the number of times a function is called and its popularity level, the popularity level information of each function is obtained.

[0008] The first test code is tested using a preset test case set to obtain the code coverage information of each test case in the function.

[0009] Based on the preset correspondence between code coverage information and association level, obtain the association level information between each test case and each function;

[0010] Obtain the second test code to be tested, obtain the popularity level information of each function in the second test code and the association level information between each function in the second test code and each test case in the test case set; wherein, the second test code corresponds to the first test code;

[0011] In response to an input recommendation request, recommended test cases for the second test code are obtained based on the recommendation request; wherein, the recommendation request includes popularity level information and association level information of the recommended test cases;

[0012] The recommended test cases are pushed to the test client.

[0013] Secondly, embodiments of this application provide a test case recommendation device, including:

[0014] The function call count acquisition module is used to obtain the number of times each function is called during the compilation of the first test code;

[0015] The popularity level acquisition module is used to obtain the popularity level information of each function based on the preset correspondence between the number of times it is called and the popularity level.

[0016] The code coverage information acquisition module is used to test the first test code using a test case set and to acquire the code coverage information of each test case in the test case set in each function.

[0017] The association level acquisition module is used to acquire the association level information between each test case and each function based on the preset correspondence between code coverage information and association level;

[0018] The second test code acquisition module is used to acquire the second test code to be tested, acquire the popularity level information of each function in the second test code and the association level information between each function in the second test code and each test case in the test case set; wherein, the second test code corresponds to the first test code;

[0019] The recommended test case acquisition module is used to respond to an input recommendation request and acquire recommended test cases for the second test code according to the recommendation request; wherein, the recommendation request includes popularity level information and association level information of the recommended test cases;

[0020] The recommendation module is used to push the recommended test cases to the test client.

[0021] Thirdly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the test case recommendation method as described in any of the preceding claims.

[0022] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor executes the computer program to implement the steps of the test case recommendation method as described in any of the preceding claims.

[0023] In this embodiment, the popularity level of each function is divided according to the number of times each function is called in the first test code, the association level between each test case and each function is determined according to the code coverage information between each test case and each function, and then the most suitable recommended test cases are automatically generated and pushed to the test user terminal based on the popularity level information and association level information of each function in the second test code, as well as the popularity level information and association level information of the input recommended test cases, which can effectively improve the efficiency of software testing.

[0024] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description

[0025] Figure 1 This is a schematic diagram illustrating an application scenario of a test case recommendation method according to an embodiment of the present invention;

[0026] Figure 2 This is a flowchart illustrating a test case recommendation method according to an embodiment of the present invention;

[0027] Figure 3 This is a schematic diagram of a test case recommendation interface according to an embodiment of the present invention;

[0028] Figure 4 This is a schematic diagram of a test case recommendation device according to an embodiment of the present invention;

[0029] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0031] It should be understood that the described embodiments are merely some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of the embodiments of this application.

[0032] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the embodiments of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0033] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims. In the description of this application, it should be understood that the terms "first," "second," "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.

[0034] Furthermore, in the description of this application, unless otherwise stated, "several" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0035] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used in this application include both devices that are wireless signal receivers, which are devices that only have wireless signal receiver capabilities without transmission capabilities, and devices that have receiving and transmitting hardware, which have receiving and transmitting hardware capable of bidirectional communication on a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, which have single-line displays or multi-line displays or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service), which can combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant), which may include a radio frequency receiver, pager, Internet / intranet access, web browser, notepad, calendar, and / or GPS (Global Positioning System) receiver; and conventional laptop and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.

[0036] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.

[0037] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.

[0038] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of a test case recommendation method provided in one embodiment of this application. The application scenario includes a server 10 and a test user terminal 20 provided in this embodiment of the application; wherein, the server 10 and the test user terminal 20 can interact with each other through a wired communication link, a wireless communication link, or an optical fiber cable.

[0039] Server 10 can be a server that provides various services, such as analyzing and storing the relationships between functions and test case sets in the first test code, receiving and analyzing recommendation requests sent by the test user client, obtaining corresponding recommended test cases, and pushing them to the test user client 20.

[0040] The test user terminal 20 can be the end where the software test user is located. The test user terminal 20 can be various electronic devices with a display screen, including but not limited to smartphones, smart interactive whiteboards and personal computers.

[0041] In one embodiment, a test case recommendation method provided in this application can be executed on server 10.

[0042] Existing test case recommendation methods typically associate test cases with code coverage or recommend them through semantic analysis. However, the test cases recommended by these methods are often not accurate enough. If unnecessary test cases are recommended in order to improve test accuracy, it will affect the efficiency of software testing.

[0043] Therefore, in response to the above problems, such as Figure 1 As shown in the figure, this application provides a test case recommendation method, including the following steps:

[0044] S101: Obtain the number of times each function is called during the compilation of the first test code;

[0045] A function refers to the functional code in the first test code that is used to perform the corresponding function. Test cases can be used to check the correctness of the function's functionality.

[0046] Specifically, the first test code can be structurally parsed to obtain the location information of each function in the first test code. Based on the location information of each function, each function can be instrumented, and function execution information such as the number of times each function is called during execution can be recorded.

[0047] The location information can be used for insertion call detection tools. The location information of each function can be obtained by analyzing the bytecode in the first test code and identifying the functions contained in the first test code.

[0048] The detection tool is used to obtain the number of times the function is called during the compilation process. The number of times a function is called can be obtained by inserting the function call count acquisition tool at the location of each function.

[0049] In one embodiment, the Jacoco tool can be used to instrument the first test code, and ASM can be used to analyze the bytecode corresponding to the first test code to insert code for obtaining the number of times each function is called into each function, thereby realizing function call tracing and obtaining the number of times each function in the first test code is called.

[0050] Jacoco is an open-source coverage tool that includes coverage counters at various scales, including instruction (C0 coverage), branch (C1 coverage), cyclomatic complexity, line coverage, non-abstract methods, and class coverage. Jacoco uses an agent to insert a boolean[] array into the bytecode to mark each executable code statement. Whenever a corresponding statement is executed, the boolean[] array generates a corresponding flag (True or False). This boolean array, along with the generated flags, is called a probe.

[0051] ASM is a comprehensive Java bytecode manipulation and analysis framework. It allows for the dynamic generation of classes or the enhancement of existing class functionality. In this embodiment, the bytecode corresponding to the first test code is analyzed using the ASM framework, and code for obtaining the number of function calls is inserted into each function to achieve function call tracing, thereby obtaining the number of times each function in the first test code is called.

[0052] Alternatively, in another embodiment, a static variable or counter can be defined in the function body to record the number of times the function is called. When the corresponding function is called, the static variable or counter is automatically assigned a value (e.g., incremented by 1). The number of times the function is called can be obtained by reading the specific value of the static variable or counter.

[0053] S102: Obtain the popularity level information of each function based on the preset correspondence between the number of times it is called and the popularity level;

[0054] The number of times a function is called can be used to determine whether it is a necessary function for the test code to execute the corresponding business function. When selecting test cases, test cases that are highly relevant to the necessary functions that the test code is to implement should be preferred to improve the accuracy of the test.

[0055] In this embodiment, a popularity level is used to classify the importance of each function in performing its corresponding business function. The more times a function is called, the higher its popularity level. The correspondence between the number of calls and the popularity level can be set according to the user's actual needs.

[0056] Optionally, the functions can be sorted by the number of times they are called from largest to smallest. Functions with a call count greater than or equal to a preset threshold are identified as hot functions, while functions with a call count less than the preset threshold are identified as silent functions. This determines the popularity level of each function. The preset threshold can be set based on the actual execution of the first test code.

[0057] Applications often contain functions unrelated to the business logic they perform, such as logging functions and event tracking functions. These unrelated functions do not need to be tested to reduce the amount of test data. Therefore, preferably, this embodiment of the application further includes the following steps before obtaining the popularity level information of each function:

[0058] If the number of times a function is called is less than a preset threshold, the function is determined to be a non-business function and is removed.

[0059] For functions that are called less than a preset threshold during compilation, such as functions with zero calls, they can be removed as non-business functions unrelated to business functions. There is no need to recommend test cases related to them, thus improving the efficiency and accuracy of test case recommendation.

[0060] S103: Test the first test code using a preset test case set, and obtain the code coverage information of each test case in the test case set in each function;

[0061] Code coverage information can be used to determine the matching status of each test case with each function during the testing process. For example, it can be determined whether the execution of a test case matches the header, all lines, or all branches of a function. Based on the matching results of test cases and functions, the correlation between each test case and each function can be determined.

[0062] The code coverage information can include line coverage, branch coverage, and other information. The higher the line coverage and the higher the branch coverage, the stronger the correlation between the test cases and the function.

[0063] Specifically, before the step of testing the first test code using a preset test case set, the method further includes: inserting a code coverage information acquisition tool into the first test code;

[0064] The steps for obtaining the code coverage information of each test case in each function from the test case set include:

[0065] The code coverage information is read from the code coverage information acquisition tool to obtain the code coverage information.

[0066] Code coverage information acquisition tools can be such as Jacoco, Emma, ​​Cobertura, etc. Use code coverage information tools to instrument the first test code and collect code coverage information of each test case and each function during the testing process.

[0067] Preferably, in this embodiment, the Jacoco tool is used for code instrumentation. Jacoco is an open-source coverage tool that includes coverage counters at various scales, including instruction (C0 coverage), branch (C1 coverage), cyclomatic complexity, line coverage, non-abstract methods, and class coverage. The Jacoco tool uses an agent to insert a boolean[] array into the bytecode to mark each executable code statement. Whenever a corresponding statement is executed, the boolean[] array generates a corresponding flag (True or False). This boolean array, along with the generated flags, is called a probe.

[0068] S104: Based on the preset correspondence between code coverage information and association level, obtain the association level information between each test case and each function;

[0069] Association level is used to determine the relevance of each test case to each function. The higher the relevance of each test case to each function, the higher its association level.

[0070] For example, when a test case is executed and matches the header of a function, its association level with the function is determined to be simple association; when a test case is executed and matches all lines of a function, its association level with the function is determined to be tight association; when a test case is executed and matches all branches of a function, its association level with the function is determined to be full association, and so on.

[0071] S105: Obtain the second test code to be tested, obtain the popularity level information of each function in the second test code and the association level information between each function in the second test code and each test case in the test case set;

[0072] The second test code corresponds to the first test code; the second test code may be the same as or partially the same as the first test code, or the second test code may be the code in the first test code used to perform a certain business function.

[0073] The popularity level information of each function in the second test code and its association level information with each test case can be obtained by directly reading the popularity level information and association level information of the corresponding functions in the first test code stored in the database.

[0074] S106: In response to the input recommendation request, obtain recommended test cases for the second test code based on the recommendation request;

[0075] The recommendation request is used to determine recommended test cases. The recommendation request may include popularity level information and association level information for the recommended test cases. Users can input the corresponding popularity level and association level according to their actual testing needs. For example, recommended test cases can be set to be test cases closely related to popular functions, or test cases can be set to be test cases with an association relationship (including simple association, close association, critical association, and complete association) with popular functions. Test cases corresponding to the user-input popularity level and association level are obtained as the recommended test cases to be pushed in this application. The above methods can form a set of recommended test cases that best meets user needs, improving the accuracy and testing efficiency of the recommended test cases.

[0076] Preferably, multiple recommendation strategies are pre-stored in the database. Each recommendation strategy has corresponding popularity level information and association level information of the recommended test cases. When a recommendation request is received from a user, the database is read to obtain the popularity level information and association level information of the recommended test cases by reading the recommendation strategy corresponding to the recommendation request. Based on the popularity level information and association level information, the most suitable set of recommended test cases for the user's needs is automatically generated.

[0077] Specifically, in one embodiment, the recommendation request includes a minimum popularity level threshold and a minimum relevance level threshold;

[0078] The steps for obtaining recommended test cases for the second test code based on the recommendation request specifically include:

[0079] Test cases with a popularity level greater than the minimum popularity level threshold and an association level greater than the minimum association level threshold will be recommended test cases.

[0080] The minimum popularity level threshold and the minimum association level threshold can be set according to the user's actual testing needs.

[0081] After obtaining the popularity level information of each function and the association level information between each test case and each function, the following steps are also included:

[0082] In another embodiment, when there are many test cases corresponding to the popularity level and association level input by the user, each test case can be scored according to its popularity level and association level, and the test case with the highest score can be selected as the recommended test case to reduce the amount of data processing in the test and improve the test efficiency.

[0083] Specifically, the recommendation request includes the weight corresponding to each popularity level and the weight corresponding to each association level;

[0084] The steps for obtaining recommended test cases for the second test code based on the recommendation request specifically include:

[0085] The recommendation score of each test case is obtained based on the popularity level, the weight corresponding to the popularity level, the association level, and the weight corresponding to the association level of each function in the second test code. The top N test cases with the highest recommendation scores are selected as recommended test cases; where N≥1.

[0086] The weight corresponding to each popularity level can be assigned according to the user's testing needs; for example, it can be assigned a value of 0 or 1.

[0087] The weight corresponding to each association level can be assigned a value according to the user's testing needs; for example, it can be assigned a value of 0 or 1.

[0088] The recommendation score can be the sum of the product of the popularity level and the weight corresponding to the popularity level and the product of the association level and the weight corresponding to the association level. Specifically, in the embodiments of this application, the recommendation score of each test case can be the product of the weight corresponding to the popularity level and the weight corresponding to the association level.

[0089] S107: Push the recommended test cases to the test client.

[0090] Recommended test cases can be displayed on the test client's screen in a preset manner, allowing users to confirm, select, and perform other operations on the recommended test cases. The display method of the recommended test cases on the test client's screen can be set according to the user's actual needs.

[0091] In this embodiment, the popularity level of each function is divided according to the number of times each function is called in the first test code, the association level between each test case and each function is determined according to the code coverage information between each test case and each function, and then the most suitable recommended test cases are automatically generated and pushed to the test user terminal based on the popularity level information and association level information of each function in the second test code, as well as the popularity level information and association level information of the input recommended test cases, which can effectively improve the efficiency of software testing.

[0092] In one embodiment, after the step of testing the first test code using a preset test case set, the method further includes:

[0093] Obtain the bug information of each test case in each function from each test case set;

[0094] Based on the code coverage information and bug information of each test case in each function in the test case set, and according to the preset correspondence between code coverage information, bug information and association level, the association level information between each test case and each function is obtained.

[0095] Specifically, the association level can include simple association, close association, full association, and critical association. When a test case is executed and matches the header of a function, its association level with that function is determined to be simple association. When a test case is executed and matches all lines of a function, its association level with that function is determined to be close association. When a test case is executed and matches all branches of a function, its association level with that function is determined to be full association. When a test case is executed and matches a function and finds a bug, its association level with that function is determined to be critical association.

[0096] By combining the code coverage information and bug information of each test case in each function, the correlation level between each test case and each function is determined. Test cases that discover bugs can be given priority recommendation, making the recommended test cases more suitable for the test code and improving the accuracy of software testing.

[0097] The test case recommendation method of this application will be specifically described below using a specific embodiment:

[0098] During software compilation, all software code is read, and plugins such as Jacoco are used to instrument function code. Bytecode is analyzed using ASM, and a call chain tracing is implemented using ASM. The number of function calls is analyzed and ranked. Functions irrelevant to business functions are removed. Functions are classified into popularity levels based on the number of times they are called: functions with a number of calls greater than or equal to a preset threshold are identified as hot functions, and functions with a number of calls less than the preset threshold are identified as silent functions. The popularity level information of each function is saved to a preset database.

[0099] The software's entire code is tested using a pre-defined set of test cases. For each test case, code coverage and bug information are collected, and the association level between each test case and each function is obtained: when a test case is executed and matches the header of a function, the association level is determined to be simple; when a test case is executed and matches all lines of a function, the association level is determined to be tight; when a test case is executed and matches all branches of a function, the association level is determined to be complete; when a test case is executed and matches a function and finds a bug, the association level is determined to be critical.

[0100] Obtain the second test code to be tested and the recommendation strategy input by the user. Read the popularity level information and association level information corresponding to the recommendation strategy input by the user from the database, obtain the corresponding test cases as recommended test cases and push them to the test client.

[0101] like Figure 3 As shown, in one embodiment, after pushing the recommended test cases to the test client, the following steps are also included:

[0102] The test client displays a test case recommendation interface; wherein the test case recommendation interface includes the recommended test cases.

[0103] like Figure 3As shown, the test case recommendation interface displays the test case number and test case name of the recommended test cases. The test case name can be named according to the function verified by each recommended test case (for example, the user name can be "verification of the tag search box display interface", "verification of the tag search box search function", etc.), so that users can understand the function verified by the recommended test cases in a timely manner.

[0104] Each recommended test case has a corresponding selection control 305. Users can select some or all of the recommended test cases for software testing according to their needs, thereby improving software testing efficiency.

[0105] Preferably, after the test client displays the test case recommendation interface, the following steps are further included:

[0106] In response to the test client's adjustment information regarding the recommended test cases, the recommended test cases displayed on the test case recommendation interface are adjusted.

[0107] Users can confirm, delete, modify, rearrange, or re-obtain the recommended test cases according to their needs, and regenerate and display the test case recommendation interface. For example... Figure 3 As shown, the test case recommendation interface also includes: batch modification control 301, re-recommendation control 302, ascending order sorting control 303, and test case query control 304;

[0108] The batch modification control 301 can be used to add or delete recommended test cases displayed on the test case recommendation interface in batches. Users can add or delete recommended test cases in batches by triggering the batch modification control 301 and checking the corresponding selection control 305 for the recommended test cases.

[0109] The re-recommendation control 302 can be used to re-obtain recommended test cases. After the user triggers the re-recommendation control 302, step S106 of this application is executed again to obtain recommended test cases.

[0110] The ascending order sorting control 303 can be used to sort multiple recommended test cases. The sorting method can be based on time, name, function, or other user-preset sorting methods. When the user triggers the ascending order sorting control 303, the recommended test cases displayed on the test case recommendation interface are sorted and the sorted recommended test cases are displayed.

[0111] The test case query control 304 can be used to quickly obtain one or more recommended test cases from multiple recommended test cases. Users can trigger the test case query control 304 and enter query information (such as the test case number, test case name, function, etc. of the recommended test cases) to quickly obtain recommended test cases that meet the user's needs.

[0112] The test case recommendation method in this application can automatically generate a minimal set of test cases related to user testing needs, reduce the recommendation of invalid or redundant test cases, improve the accuracy of test case recommendations, and improve software testing efficiency.

[0113] like Figure 4 As shown in the illustration, this application also provides a test case recommendation device, which can be implemented as all or part of an electronic device through software, hardware, or a combination of both. The device includes:

[0114] The function call count acquisition module 401 is used to obtain the number of times each function is called during the compilation of the first test code;

[0115] The popularity level acquisition module 402 is used to acquire the popularity level information of each function according to the preset correspondence between the number of times it is called and the popularity level.

[0116] The code coverage information acquisition module 403 is used to test the first test code using a test case set and to acquire the code coverage information of each test case in the test case set in each function.

[0117] The association level acquisition module 404 is used to acquire the association level information between each test case and each function according to the preset correspondence between code coverage information and association level;

[0118] The second test code acquisition module 405 is used to acquire the second test code to be tested, acquire the popularity level information of each function in the second test code and the association level information between each function in the second test code and each test case in the test case set; wherein, the second test code corresponds to the first test code;

[0119] The recommended test case acquisition module 406 is used to respond to an input recommendation request and acquire recommended test cases for the second test code according to the recommendation request; wherein, the recommendation request includes popularity level information and association level information of the recommended test cases;

[0120] The recommendation module 407 is used to push the recommended test cases to the test client.

[0121] It should be noted that the test case recommendation device provided in the above embodiments is only illustrated by the division of the above functional modules when executing the test case recommendation method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the test case recommendation device and test case recommendation method provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.

[0122] This embodiment provides an electronic device that can be used to execute all or part of the steps of the test case recommendation method of this application embodiment. For details not disclosed in this embodiment, please refer to the method embodiment of this application.

[0123] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 500 may be, but is not limited to, a combination of one or more devices such as various servers, personal computers, laptops, smartphones, and tablets.

[0124] In a preferred embodiment of this application, the electronic device 500 includes a memory 501, at least one processor 502, at least one communication bus 503, and a transceiver 504.

[0125] Those skilled in the art should understand that Figure 4 The structure of the electronic device shown does not constitute a limitation of the embodiments of this application. It can be a bus structure or a star structure. The electronic device 500 may also include more or fewer other hardware or software than shown, or different component arrangements.

[0126] In some embodiments, the electronic device 500 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), digital processors, and embedded devices. The electronic device 500 may also include client devices, including, but not limited to, any electronic product capable of human-computer interaction with a client via a keyboard, mouse, remote control, touchpad, or voice control device, such as personal computers, tablet computers, smartphones, and digital cameras.

[0127] It should be noted that the electronic device 500 is merely an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.

[0128] In some embodiments, the memory 501 stores a computer program that, when executed by the at least one processor 502, implements all or part of the steps in the test case recommendation method as described in the embodiments. The memory 501 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0129] In some embodiments, the at least one processor 502 is the control unit of the electronic device 500, connecting various components of the electronic device 500 via various interfaces and lines. It executes programs or modules stored in the memory 501 and calls data stored in the memory 501 to perform various functions and process data of the electronic device 500. For example, when the at least one processor 502 executes a computer program stored in the memory, it implements all or part of the steps of the test case recommendation method described in the embodiments of this application; or it implements all or part of the functions of the test case recommendation device. The at least one processor 502 may be composed of integrated circuits, such as a single-packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.

[0130] In some embodiments, the at least one communication bus 503 is configured to enable communication between the memory 501 and the at least one processor 502, etc.

[0131] The electronic device 500 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0132] This embodiment provides a computer-readable storage medium storing a computer program thereon. The instructions are adapted to be loaded by a processor and executed by the test case recommendation method of this application embodiment. For the specific execution process, please refer to the detailed description of the method embodiment, which will not be repeated here.

[0133] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The components described as separate parts may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0134] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0135] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0136] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A test case recommendation method characterized by, Includes the following steps: Obtain the number of times each function is called during the compilation of the first test code; Based on the preset correspondence between the number of times a function is called and its popularity level, the popularity level information of each function is obtained. The first test code is tested using a preset test case set to obtain the code coverage information of each test case in the function. Based on the preset correspondence between code coverage information and association level, obtain the association level information between each test case and each function; Obtain the second test code to be tested, obtain the popularity level information of each function in the second test code and the association level information between each function in the second test code and each test case in the test case set; wherein, the second test code corresponds to the first test code; In response to an input recommendation request, recommended test cases for the second test code are obtained based on the recommendation request; wherein, the recommendation request includes popularity level information and association level information of the recommended test cases; The recommended test cases are pushed to the test client.

2. The test case recommendation method of claim 1, wherein, Before the step of testing the first test code using a preset test case set, the method further includes: A code coverage information acquisition tool is inserted into the first test code; wherein, the code coverage information acquisition tool is used to record the code coverage information of each test case in each function during the testing process; The steps for obtaining the code coverage information of each test case in each function from the test case set include: The code coverage information is read from the code coverage information acquisition tool to obtain the code coverage information.

3. The test case recommendation method of claim 2, wherein, After the step of testing the first test code using a preset test case set, the method further includes: Obtain the bug information of each test case in each function from each test case set; Based on the code coverage information and bug information of each test case in each function in the test case set, and according to the preset correspondence between code coverage information, bug information and association level, the association level information between each test case and each function is obtained.

4. The test case recommendation method of claim 1, wherein, The recommendation request includes the weight corresponding to each popularity level and the weight corresponding to each association level; The steps for obtaining recommended test cases for the second test code based on the recommendation request specifically include: The recommendation score of each test case is obtained based on the popularity level, the weight corresponding to the popularity level, the association level, and the weight corresponding to the association level of each function in the second test code. The top N test cases with the highest recommendation scores are selected as recommended test cases; where N≥1.

5. The test case recommendation method of claim 4, wherein, The recommendation score for each test case is the product of the weight corresponding to the popularity level and the weight corresponding to the association level.

6. The test case recommendation method of claim 1, wherein, The recommendation request includes a minimum popularity level threshold and a minimum relevance level threshold; The steps for obtaining recommended test cases for the second test code based on the recommendation request specifically include: Test cases with a popularity level greater than the minimum popularity level threshold and an association level greater than the minimum association level threshold will be recommended test cases.

7. The test case recommendation method according to claim 1, characterized in that, Before obtaining the popularity level information for each function, the following steps are also included: If the number of times a function is called is less than a preset threshold, the function is determined to be a non-business function and is removed.

8. The test case recommendation method according to claim 1, characterized in that, After pushing the recommended test cases to the test client, the following steps are also included: The test client displays a test case recommendation interface; wherein the test case recommendation interface includes the recommended test cases; In response to the test client's adjustment information regarding the recommended test cases, the recommended test cases displayed on the test case recommendation interface are adjusted.

9. A test case recommendation device, characterized in that, include: The function call count acquisition module is used to obtain the number of times each function is called during the compilation of the first test code; The popularity level acquisition module is used to obtain the popularity level information of each function based on the preset correspondence between the number of times it is called and the popularity level. The code coverage information acquisition module is used to test the first test code using a test case set and to acquire the code coverage information of each test case in the test case set in each function. The association level acquisition module is used to acquire the association level information between each test case and each function based on the preset correspondence between code coverage information and association level; The second test code acquisition module is used to acquire the second test code to be tested, acquire the popularity level information of each function in the second test code and the association level information between each function in the second test code and each test case in the test case set; wherein, the second test code corresponds to the first test code; The recommended test case acquisition module is used to respond to an input recommendation request and acquire recommended test cases for the second test code according to the recommendation request; wherein, the recommendation request includes popularity level information and association level information of the recommended test cases; The recommendation module is used to push the recommended test cases to the test client.

10. A computer readable storage medium having stored thereon a computer program, characterized in that: When the computer program is executed by a processor, it implements the steps of the test case recommendation method as described in any one of claims 1-8.

11. An electronic device, comprising: It includes a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor executes the computer program to implement the steps of the test case recommendation method as described in any one of claims 1-8.