Test case generation method and device and electronic equipment

Through multiple rounds of target operations and updates of test results, the redundancy and invalid problems in the generation of test cases in the prior art are solved, the efficiency of test cases is improved, and efficient acquisition of effective test cases is achieved.

CN119271539APending Publication Date: 2025-01-07BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310808133.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-03
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

A large number of invalid and redundant test cases are generated during the generation of existing test cases, which reduces the efficiency of generating test cases.

Method used

By performing multiple rounds of target operations, generating and testing test cases, updating the collection used to generate test cases based on the test results, thereby obtaining target test cases, avoiding traversing all test cases and reducing redundant information.

Benefits of technology

Improve the efficiency of generating effective test cases, reduce the generation of invalid and redundant test cases, and improve the effectiveness of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271539A_ABST
    Figure CN119271539A_ABST
Patent Text Reader

Abstract

The invention provides a test case generation method, which comprises the steps of executing multiple rounds of target operation, and each round of target operation comprises the steps of generating at least one test case of the round, and testing the test case to obtain a test result; wherein the test cases not in the first round are determined based on test results before the current round; updating a first set for generating the test cases at least based on the test cases with correct test results; and after the execution of the multiple rounds of target operations is ended, obtaining a target test case based on the first set. At least one test case of each round of test operation test not in the first round is determined based on the test result before the current round, so that when the test case is generated, all test cases do not need to be generated through traversal, generation of a large number of invalid and redundant test cases is avoided, and the efficiency of generating effective test cases is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of software testing, and in particular to a test case generation method, device and electronic device. Background Art

[0002] During the application development process, developers often use test cases to test the interface functions, interface event responses, and interactions between interfaces implemented by the application. The common test case generation process includes analyzing the interfaces contained in a specific application and the triggering relationships between interfaces; using automated test case generation tools to deeply traverse the triggering processes between multiple interfaces and generate multiple test cases; finally, analyzing the effectiveness of these test cases to obtain appropriate test cases for testing other versions of the application. However, this will generate a large number of invalid and redundant test cases, reducing the efficiency of generating test cases. Summary of the invention

[0003] The present invention provides a test case generation method, device and electronic device.

[0004] According to a first aspect, a test case generation method is provided, the method comprising: performing multiple rounds of target operations, wherein each round of the target operations comprises:

[0005] Generate at least one test case for this round, and test the test case to obtain a test result; wherein the test case not in the first round is determined based on the test results before this round;

[0006] updating the first set used to generate the test cases based at least on the test cases with correct test results;

[0007] Wherein, after completing the execution of the multiple rounds of target operations, the method further includes obtaining a target test case based on the first set.

[0008] According to a second aspect, a test case generating device is provided, the device being used to perform multiple rounds of target operations, and for each round of the target operations, the device comprising:

[0009] A generation module, used to generate at least one test case of this round, and test the test case to obtain a test result; wherein the test case other than the first round is determined based on the test results before this round;

[0010] a processing module, configured to update the first set used to generate the test cases based at least on the test cases with correct test results;

[0011] After completing the execution of the multiple rounds of target operations, the processing module is further configured to obtain target test cases based on the first set.

[0012] According to a third aspect, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of the above-mentioned first aspects is implemented.

[0013] According to a fourth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any one of the first aspects is implemented.

[0014] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0015] An embodiment of the present disclosure provides an interface test case generation method and device, which obtains a first set of test case updates that are correct at least based on test results by executing multiple rounds of test operations, so as to obtain target test cases based on the first set. Since at least one test case tested in each round of test operations other than the first round is determined based on the test results before this round, when generating test cases, there is no need to traverse and generate all test cases, thereby avoiding the generation of a large number of invalid and redundant test cases, thereby improving the efficiency of generating valid test cases.

[0016] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0018] Figure 1 is a flow chart of a test case generation method provided by an embodiment of the present disclosure;

[0019] Figure 2 is a flow chart of a test case generation method provided by an embodiment of the present disclosure;

[0020] Figure 3 is a schematic diagram of a state transition diagram provided by an embodiment of the present disclosure;

[0021] Figure 4 is a schematic diagram of an event conversion path provided by an embodiment of the present disclosure;

[0022] Figure 5 is a schematic block diagram of a test case generating device provided by an embodiment of the present disclosure;

[0023] Figure 6 is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure;

[0024] Figure 7 is a schematic block diagram of another electronic device provided by an embodiment of the present disclosure;

[0025] Figure 8 It is a schematic block diagram of a storage medium provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0027] When the following description refers to the 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 the present disclosure. Instead, they are only examples of devices and methods consistent with some aspects of the present disclosure as detailed in the attached claims.

[0028] The terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. The singular forms of "a", "the" and "the" used in this disclosure are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0029] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0030] like Figure 1 As shown in FIG. 1 , it is a schematic diagram of a test case generation method according to an exemplary embodiment. Figure 1As shown, first in step 101, the application code is statically analyzed to obtain a state transition graph (window transition graph, WTG). The state transition graph is an ordered mesh topology graph, which includes multiple ordered state nodes and connecting edges between multiple state nodes. Among them, each state node corresponds to an interface obtained by rendering the application, and the connecting edges between multiple state nodes correspond to the triggering relationship between the interfaces of the application. The triggering relationship is a user interface module (user interface module, UI) set on the interface. The UI component is an independent part encapsulated from one or more application code segments that complete their respective functions, and is the interface of the user operation interface. Multiple test cases of the application can be generated by traversing the state transition graph, and the above traversal is the process of combining the ordered state nodes in the state transition graph and the connecting edges between them.

[0031] Obviously, the state transition diagram contains a lot of redundant information and invalid connection edges. This is mainly reflected in that, on the one hand, a UI component corresponding to a connection edge can contain multiple attributes, and different attributes represent different component functions. However, usually only some of the attributes are needed to generate test cases, so there is a lot of redundant information in the state transition diagram. On the other hand, the ordered state nodes and the connection edges between them only represent the static call relationship of the application code, and the test cases generated based on some static call relationships are not valid. That is, in real scenarios or simulation environments, when these test cases are dynamically executed, logical errors related to functions, sequences, or timeliness will occur. Based on the above reasons, if the state transition diagram is simply traversed to generate test cases, it will lead to the problem of component combination explosion. The higher the traversal coverage, the more serious the problem of component combination explosion.

[0032] like Figure 1 As shown, in step 102, based on the state transition diagram and the first set, at least one event conversion path of each round of target operation is obtained. The event conversion path includes multiple event nodes and jump relationships between multiple event nodes. One event node corresponds to one test event, and the jump relationship between event nodes corresponds to the dynamic logical relationship between test events. Multiple event conversion paths can be obtained for each round of target operation, and the number of event nodes included in the event conversion path is positively correlated with the round sequence number of the target operation.

[0033] For each round of target operation, the event conversion path of this round of target operation is obtained based on the state transition diagram and the first set. Among them, the first set includes a correct subset and an incorrect subset, which respectively include the correct and incorrect event conversion paths of the dynamic logical relationship determined before this round of target operation. By traversing the state transition diagram, multiple ordered sequences can be determined, and the sequence elements of the sequence correspond to the connection edges in the state transition diagram. The order between the sequence elements is consistent with the order of the corresponding connection edges in the state transition diagram. Based on multiple ordered sequences, multiple alternative event conversion paths can be obtained. Then, these alternative event conversion paths are screened using the first set, and redundant and invalid event conversion paths are removed to obtain at least one event conversion path of this round of target operation. The event conversion path of this round of target operation is used to generate at least one test case. Among them, an invalid event conversion path refers to a test case corresponding to which includes an incorrect dynamic logical relationship.

[0034] like Figure 1 As shown, in step 103, after completing multiple rounds of target operations, the target test case is obtained using the event conversion path with the correct dynamic logical relationship. As described in step 102, the number of event nodes included in the event conversion path obtained in each round of target operation is positively correlated with the round sequence number of the target operation, and the first set includes the event conversion path determined before this round of target operation. Therefore, in this round of target operation, the number of event nodes included in the event conversion path obtained based on the first set screening is greater than the number of event nodes included in the event conversion path event nodes in the first set. Therefore, the test case generated based on the event conversion path obtained in this round of target operation may still have incorrect dynamic logical relationships.

[0035] It is necessary to test the dynamic logical relationship of the test cases generated by the current round of target operation, and obtain the test cases with correct test results of the current round of target operation according to the test results. And based on the test results, the event conversion paths in the correct subset and the error subset of the first set are updated to obtain at least one event conversion path for the next round of target operation.

[0036] After executing multiple rounds of target operations, an updated first set may be obtained, and target test cases may be acquired based on the first set.

[0037] Based on the above operations, on the one hand, when determining the sequence elements of the sequence, the UI components corresponding to the connection edges in the state transition diagram can be abstracted, and only the necessary information for generating test cases can be retained, thereby reducing the redundant information contained in the event conversion path.

[0038] On the other hand, when obtaining at least one event conversion path in each round of target operation, the alternative event conversion paths obtained by traversing the state transition diagram are screened based on the first set, so as to screen out invalid and redundant event conversion paths and improve the execution efficiency of each round of target operation.

[0039] On the other hand, by testing the test cases generated for each round of target operations, updating the first set based at least on the test cases with correct test results, and then determining at least one test case for the next round based on the updated first set, the efficiency of generating effective test cases is improved.

[0040] In combination with the above contents, an interface test case generation method, device and electronic device provided by an embodiment of the present disclosure will be introduced in detail below.

[0041] Figure 2 A schematic diagram of a test case generation method provided by an embodiment of the present disclosure is shown. The execution subject of the method can be any device, platform, server or device cluster with computing and processing capabilities. Figure 2 As shown, the method includes performing multiple rounds of target operations, wherein each round of target operations mainly includes the following steps:

[0042] In step 201, at least one test case of this round is generated, and the test case is tested to obtain a test result. Among them, the test case of the non-first round is determined based on the test results before this round.

[0043] In this embodiment, for the target operation not in the first round, at least one event transition path of this round is obtained based on the state transition diagram and the first set, and then at least one test case of this round is generated according to the at least one event transition path of the target test of this round. One test case includes multiple test events.

[0044] The state transition graph is an ordered mesh topology graph, including multiple ordered state nodes and connecting edges between multiple state nodes. Among them, any state node corresponds to an interface of the application to be tested, and the connecting edges between multiple state nodes correspond to the triggering relationship between the interfaces of the application to be tested. The triggering relationship corresponds to the UI component set on the interface.

[0045] UI components can be understood as commonly used controls or elements in interface design, such as buttons, icons, navigation menus, labels, input boxes, selectors, forms, etc. It can be understood that a UI component corresponding to a trigger relationship includes multiple attributes, such as src (indicating the source interface of the trigger relationship), tgt (indicating the target interface of the trigger relationship), tag (indicating the tag information of the UI component), evt (indicating the trigger event), widget (indicating the interface where the UI component is located), handler (indicating the operation mode of the UI component), stack (indicating the storage structure for storing UI component data), etc. For generating test cases, this information is not all necessary and there is a lot of redundancy.

[0046] Figure 3 FIG. 1 is a schematic diagram of a state transition diagram provided by an embodiment of the present disclosure. Figure 3 As shown, in one embodiment, the automated analysis tool Gator is used to perform static analysis on the application code to obtain Figure 3 The state transition diagram shown in the figure. The state transition diagram includes 6 state nodes numbered 1 to 6 and 10 connection edges connecting the 6 state nodes, and the connection edges are numbered 1 to 10. Taking state node 1 as an example, you can switch to state node 2 through any of the connection edges 1 to 3, and you can also switch to state node 3 through any of the connection edges 4 or 5.

[0047] Among the six state nodes, state node 1 is the initial state node, corresponding to the startup interface of the application. The initial state node is the starting point for traversing the state transition graph, and a state transition graph includes an initial state node. By traversing the state transition graph, multiple test cases of the application can be generated. The above traversal is the process of combining the ordered state nodes in the state transition graph and the connecting edges between them.

[0048] In one example, the first set includes event conversion paths corresponding to test cases whose test results are correct before the current round of target operation. The event conversion path includes multiple event nodes and jump relationships between multiple event nodes. Among them, one event node corresponds to one test event, and the jump relationship between event nodes corresponds to the dynamic logical relationship between test events. The dynamic logical relationship represents the logical relationship related to function, sequence or timeliness, etc. generated when these test cases are dynamically executed in a real scene or simulation environment. Obviously, the above logical relationship may be correct or incorrect. In the process of generating test cases, the proportion of test cases including erroneous dynamic logical relationships can be reduced to improve the efficiency of generating correct test cases.

[0049] Specifically, the current first set is obtained, and the current first set is the first set after being updated in the previous round of target operation. The preset number of event nodes corresponding to the current round of target operation is determined, and the preset number corresponding to any round of target operation is positively correlated with the round sequence number corresponding to the round of target operation.

[0050] Based on the state transition graph, multiple ordered sequences are determined. The sequence elements of any sequence correspond to the connection edges in the state transition graph, and the order between the sequence elements of any sequence is consistent with the order of the corresponding connection edges in the state transition graph. Based on multiple ordered sequences, multiple alternative event transition paths are obtained.

[0051] Figure 4 A schematic diagram of an event conversion path provided by an embodiment of the present disclosure is shown. Figure 3The state transition diagram shown in can obtain multiple ordered sequences, such as: edge 1 → edge 6, edge 2 → edge 7, etc. Abstracting the UI component corresponding to a connection edge, such as retaining only the attributes of widget, tgt, and evt, can generate event nodes in the event transition path. Figure 3 The connection edges 1 to 10 shown in can generate corresponding event nodes 1 to 10.

[0052] like Figure 4 As shown, the preset number of event nodes corresponding to the target operation of this round is set to 2. Figure 3 The sequence of connecting edges 1 to 10 shown in FIG. 14 can obtain 14 event conversion paths. Taking the event conversion path: event node 1→event node 6 as an example, the event conversion path includes event node 1 and event node 6, and a jump relationship 1 is included between them.

[0053] Next, the current first set is used to screen multiple candidate event conversion paths to obtain at least one event conversion path including a preset number of event nodes as the event conversion path for the current round of target operation.

[0054] The first set includes a first subset and a second subset, wherein the first subset includes event conversion paths corresponding to test cases with correct test results, and the second subset includes event conversion paths corresponding to test cases with incorrect test results. During the screening process, the first subset and the second subset are used to delete illegal event conversion paths from multiple candidate event conversion paths, and the remaining legal candidate event conversion paths are used as event conversion paths for the current round of target operations.

[0055] Specifically, for any round of target operation, the state transition diagram and the current first set are obtained, and the preset number of event nodes corresponding to the target operation of this round is set as NeedVisitDepth. It is not difficult to understand that for the first round of target operation, the obtained event transition path only includes one event node, and the obtained current first set is an empty set.

[0056] For non-first-round target operations, in one implementation, the state transition graph can be traversed multiple times based on the initial state node to generate multiple candidate event transition paths including the NeedVisitDepth event node. Then, based on the first set, the legitimacy of the multiple candidate event node paths is tested to obtain at least one event transition path including the NeedVisitDepth event node as the event transition path for the current round of target operations.

[0057] In another implementation, the state transition diagram can also be traversed multiple times forward based on the initial state node. For each forward traversal, for example, when NeedVisitDepth≥4, an alternative event transition path is obtained through one traversal: event node 1→event node 2→event node 3, then the next traversal can obtain an alternative event transition path: event node 1→event node 2→event node 3→event node 4. The legality of the alternative event node path obtained by each traversal is checked. If the detected alternative event node path is illegal, or the number of nodes contained in the alternative event transition path obtained by the traversal increases to the value NeedVisitDepth, the execution of this forward traversal is stopped.

[0058] The rules for determining whether an alternative event conversion path is illegal include: for any alternative event conversion path, if any sub-path of the event conversion path exists in the second subset, or if the alternative event conversion path is any sub-path of at least one event conversion path in the first subset, then the alternative event conversion path is illegal.

[0059] In one example, the second subset includes an incorrect event conversion path: event node 1 → event node 2 → event node 3 → event node 4. If an alternative event conversion path is obtained: event node 1 → event node 2 → event node 3 → event node 4 → event node 5, the path is considered to be illegal. If an alternative event conversion path is obtained by traversal: event node 1 → event node 2 → event node 3 → event node 5, and this path is not in the second subset, then the path is legal.

[0060] In another example, the first subset includes the correct event conversion path: event node 1 → event node 2 → event node 3. If the traversal obtains an alternative event conversion path: event node 1 → event node 2, the path is considered to be illegal. If the traversal obtains an alternative event conversion path: event node 1 → event node 2 → event node 3 → event node 4, and this path is not in the second subset, the path is legal.

[0061] Next, at least one test case of this round is generated based on at least one event conversion path of the target test of this round, and the test case is tested to obtain a test result.

[0062] In one implementation, the correctness of the test case may be tested on a hardware platform that supports the application.

[0063] In another implementation, the correctness test of the test case may also be performed in a simulation environment to achieve a higher test speed.

[0064] In one example, the application to be tested is written in the high-level programming language Java, and the hardware platform corresponding to the application is the Android system. First, the test case generation tool Espresso can be used to generate test cases, including building test case codes based on Espresso's code templates and event conversion paths. Insert the necessary test logs into the test case code, and generate a test case execution file for testing on the test tool. Different test logs correspond to different dynamic logical relationships. If the test process outputs a certain log, it means that the dynamic logical relationship corresponding to the log is correct, and the trigger relationship corresponding to the dynamic logical relationship is executed.

[0065] Secondly, you can use the test tool Robolectric to run test cases and test the dynamic logical relationship of test cases. Robolectric is a test framework that supports simulating the Android environment in a desktop Java virtual machine. It intercepts class calls instead of running classes. During the test, one class corresponds to one event node. Because Robolectric only supports testing of a single event node. Therefore, it is also necessary to write an interface call function that supports the Android system in the Robolectric source code, and use the interface call function to sequentially execute the jump relationship contained in the event conversion path, and output the corresponding log.

[0066] In step 202, the first set is updated based on at least the test cases with correct test results.

[0067] In this embodiment, the first set is updated based on at least the test cases with correct test results to generate at least one test case for the next round of target operations.

[0068] Specifically, the event conversion path corresponding to the test case with an incorrect test result is saved to the second subset; the event conversion path corresponding to the test case with a correct test result is saved to the first subset, the sub-path of the event conversion path is deleted from the first subset, and the sub-path of the event conversion path is saved to the second subset.

[0069] In an example, if the first subset includes a first event conversion path: event node 1→event node 2→event node 3→event node 4, a new event conversion path is obtained according to the test case with correct test results: event node 1→event node 2→event node 3→event node 4→event node 5, then the new event conversion path is saved to the first subset, the first event conversion path is deleted from the first subset, and the first event conversion path is saved to the second subset to reduce the redundancy of the first subset.

[0070] In step 203, after executing multiple rounds of target operations, a target test case is obtained based on the first set for generating test cases.

[0071] In this embodiment, the device may execute a target round of target operations according to the requirements of a specific test environment. After executing the target round of target operations, a target test case is obtained based on the updated first set.

[0072] In one example, the maximum preset number of event nodes included in the event conversion path can be set to MaxDepth, and when the event node NeedVisitDepth included in the event conversion path obtained in this round of target operation increases to MaxDepth, the execution of multiple rounds of target operation ends.

[0073] The updated first set includes event transition paths corresponding to test cases with correct test results. In one implementation, target test cases can be generated based on multiple event transition paths in the first subset; in another implementation, test cases with correct test results obtained in each round of testing can be saved in each round of target operation, and target test cases can be obtained based on the test cases saved in each round; in another implementation, an event transition graph (window transition graph, WTG) can be generated based on multiple event transition paths in the first subset, and target test cases can be generated based on the event transition graph. The event transition graph is a mesh topology graph including multiple event nodes of each event transition path in the first subset and jump relationships between multiple event nodes.

[0074] Therefore, by executing multiple rounds of test operations, a first set of test cases updated at least based on correct test results is obtained, so as to obtain target test cases based on the first set. Since at least one test case tested in each round of test operations other than the first round is determined based on the test results before this round, when generating test cases, there is no need to traverse the state transition diagram to generate all test cases, thereby avoiding the generation of a large number of invalid and redundant test cases, thereby improving the efficiency of generating valid test cases.

[0075] Figure 5 A schematic block diagram of a test case generation device provided by an embodiment of the present disclosure. Figure 5 As shown, the device comprises:

[0076] A generation module, used to generate at least one test case for this round, and test the test case to obtain a test result; wherein the test case other than the first round is determined based on the test results before this round;

[0077] a processing module, configured to update the first set used to generate the test cases based at least on the test cases with correct test results;

[0078] After completing the execution of multiple rounds of target operations, the processing module is further configured to obtain target test cases based on the first set.

[0079] Figure 6 A schematic block diagram of an electronic device provided in some embodiments of the present disclosure. Figure 6 As shown, the electronic device 910 includes a processor 911 and a memory 912, which can be used to implement a client or a server. The memory 912 is used to store computer executable instructions (e.g., one or more computer program modules) non-transiently. The processor 911 is used to run the computer executable instructions, and when the computer executable instructions are run by the processor 911, one or more steps in the test case generation method described above can be executed, thereby implementing the test case generation method described above. The memory 912 and the processor 911 can be interconnected through a bus system and / or other forms of connection mechanisms (not shown).

[0080] For example, the processor 911 may be a central processing unit (CPU), a graphics processing unit (GPU), or other forms of processing units having data processing capabilities and / or program execution capabilities. For example, the central processing unit (CPU) may be an X86 or ARM architecture, etc. The processor 911 may be a general-purpose processor or a dedicated processor, and may control other components in the electronic device 910 to perform desired functions.

[0081] For example, the memory 912 may include any combination of one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. One or more computer program modules may be stored on the computer-readable storage medium, and the processor 911 may run one or more computer program modules to implement various functions of the electronic device 910. Various applications and various data, as well as various data used and / or generated by the application, etc. may also be stored in the computer-readable storage medium.

[0082] It should be noted that, in the embodiment of the present disclosure, the specific functions and technical effects of the electronic device 910 can refer to the description of the test case generation method above, which will not be repeated here.

[0083] Figure 7A schematic block diagram of another electronic device provided for some embodiments of the present disclosure. The electronic device 920 is, for example, suitable for implementing the test case generation method provided in the embodiments of the present disclosure. The electronic device 920 may be a terminal device, etc., and may be used to implement a client or a server. The electronic device 920 may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. It should be noted that, Figure 7 The electronic device 920 shown is only an example and does not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0084] like Figure 7 As shown, the electronic device 920 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 921, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 922 or a program loaded from a storage device 928 into a random access memory (RAM) 923. In the RAM 923, various programs and data required for the operation of the electronic device 920 are also stored. The processing device 921, the ROM 922, and the RAM 923 are connected to each other via a bus 924. An input / output (I / O) interface 925 is also connected to the bus 924.

[0085] Typically, the following devices may be connected to the I / O interface 925: an input device 926 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 927 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 928 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 929. The communication device 929 may allow the electronic device 920 to communicate with other electronic devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 920 is shown to have various devices, but it should be understood that it is not required to implement or possess all of the devices shown, and the electronic device 920 may alternatively implement or possess more or fewer devices.

[0086] For example, according to an embodiment of the present disclosure, the above-mentioned test case generation method can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the above-mentioned test case generation method. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 929, or installed from the storage device 928, or installed from the ROM 922. When the computer program is executed by the processing device 921, the functions defined in the test case generation method provided in the embodiment of the present disclosure can be implemented.

[0087] Figure 8 A schematic block diagram of a storage medium provided in some embodiments of the present disclosure. Figure 8 As shown, the storage medium 930 may be a non-transitory computer-readable storage medium for storing non-transitory computer-executable instructions 931. When the non-transitory computer-executable instructions 931 are executed by a processor, the test case generation method described in the embodiment of the present disclosure may be implemented. For example, when the non-transitory computer-executable instructions 931 are executed by a processor, one or more steps in the test case generation method described above may be executed.

[0088] For example, the storage medium 930 may be applied to the above-mentioned electronic device. For example, the storage medium 930 may include a memory in the electronic device.

[0089] For example, the storage medium may include a memory card of a smart phone, a storage component of a tablet computer, a hard disk of a personal computer, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), flash memory, or any combination of the above storage media, or other applicable storage media.

[0090] For example, the description of the storage medium 930 can refer to the description of the memory in the embodiment of the electronic device, and the repeated parts are not repeated. The specific functions and technical effects of the storage medium 930 can refer to the description of the test case generation method above, and are not repeated here.

[0091] It should be noted that in the context of the present disclosure, a computer-readable medium may be a tangible medium that may contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer-readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that may be used by an instruction execution system, device or device or used in combination with it. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0092] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0093] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A test case generation method, the method comprising performing multiple rounds of target operations, wherein: Each round of target operations includes: Generate at least one test case for this round, and test the test case to obtain a test result; wherein the test case not in the first round is determined based on the test results before this round; updating the first set used to generate the test cases based at least on the test cases with correct test results; Wherein, after completing the execution of the multiple rounds of target operations, the method further includes obtaining a target test case based on the first set.

2. The method according to claim 1, wherein: The first set includes an event conversion path corresponding to a test case with a correct test result; the event conversion path includes a plurality of event nodes and jump relationships between the plurality of event nodes; wherein the event nodes correspond to test events, and the jump relationships between the event nodes correspond to the order between the test events; Wherein, for the target operation not in the first round, generating at least one test case in this round includes: Obtaining a current first set; the current first set is the first set after the last round of updates; Based on the current first set, obtaining at least one event conversion path of this round; At least one test case is generated according to the event conversion path.

3. The method according to claim 2, wherein: The acquiring at least one event conversion path of this round based on the current first set includes: Acquire a state transition graph; the state transition graph includes a plurality of ordered state nodes and connection edges between the plurality of state nodes; wherein any state node corresponds to an interface of the application to be tested; the connection edges between the plurality of state nodes correspond to the triggering relationship between the interfaces of the application to be tested; Based on the state transition diagram and the current first set, at least one event transition path of this round is obtained.

4. The method according to claim 3, wherein: The acquiring at least one event transition path of this round based on the state transition diagram and the current first set includes: Determine the preset number of event nodes corresponding to the current round of target operations; the preset number corresponding to any round of target operations is positively correlated with the round sequence number corresponding to the current round of target operations; Based on the state transition diagram, a plurality of ordered sequences are determined; the sequence elements of any sequence correspond to the connecting edges in the state transition diagram, and the order between the sequence elements is consistent with the order of the connecting edges in the state transition diagram; Based on the multiple ordered sequences, a plurality of alternative event conversion paths are obtained; The multiple candidate event conversion paths are screened using the current first set to obtain at least one event conversion path including the preset number of event nodes as the event conversion path of this round.

5. The method according to claim 4, wherein: The first set includes a first subset and a second subset, the first subset includes event conversion paths corresponding to test cases with correct test results, and the second subset includes event conversion paths corresponding to test cases with incorrect test results; The using the current first set to screen the multiple candidate event conversion paths includes: The first subset and the second subset are used to delete illegal event conversion paths from the plurality of candidate event conversion paths.

6. The method according to claim 5, wherein: For any alternative event conversion path, If any sub-path of the event conversion path exists in the second subset, or If the candidate event conversion path is any sub-path of at least one event conversion path in the first subset, the candidate event conversion path is illegal.

7. The method according to claim 5, wherein: The updating of the first set based on at least the test case with a correct test result comprises: Saving the event conversion path corresponding to the test case with an incorrect test result to the second subset; The event conversion path corresponding to the test case with a correct test result is saved to the first subset, the sub-path of the event conversion path is deleted from the first subset, and the sub-path of the event conversion path is saved to the second subset.

8. An interface test case generation device, the device is used to perform multiple rounds of target operations, for each round of the target operation, the device comprises: A generation module, used to generate at least one test case of this round, and test the test case to obtain a test result; wherein the test case other than the first round is determined based on the test results before this round; a processing module, configured to update the first set used to generate the test cases based at least on the test cases with correct test results; After completing the execution of the multiple rounds of target operations, the processing module is further configured to obtain target test cases based on the first set.

9. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 7.

10. An electronic device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 7 is implemented.