A use case generation method, device, server and storage medium
By comparing the log chains of seed use cases and the first derivative use case, determining the target use cases and deriveing the second derivative use case, the problem of low generation efficiency of exception test cases in the prior art is solved, and efficient batch generation of use cases suitable for exception tests is achieved. , expands the scope of use cases.
Patent Information
- Application Number
- CN202010504770.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-05
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2040-06-05
AI Technical Summary
The prior art is difficult to efficiently generate use cases suitable for abnormal tests in batches, resulting in low efficiency of abnormal tests and limited number of used cases generated.
By obtaining the first derivative use case derived from the seed use case, comparing it with the log chain generated by the seed use case, determining the target use case with error information, and deriveing the second derivative use case based on the target use case parameters, expanding the scope of the exception test case.
It realizes efficient batch generation of use cases suitable for exception testing, improves the efficiency and number of use cases of exception testing, and can more comprehensively mine out exception test cases suitable for business systems.
Smart Images

Figure CN113297063B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of testing technology, and specifically to a use case generation method, device, server and storage medium. Background Art
[0002] In order to ensure the operation of the business system, various types of tests need to be performed on the business system, including exception testing. Abnormal testing is a testing process that uses incorrect operations, incorrect data, etc. to test the business system, causing abnormalities such as program crashes and log errors in the business system.
[0003] Abnormal testing requires the use of use cases suitable for abnormal testing. Currently, based on the derivation of a large number of use cases, the business system is mainly tested using the derived use cases, and then the business system is observed to see whether abnormalities will occur, in the hope of obtaining use cases suitable for abnormal testing from the derived use cases. This method cannot efficiently and in batches obtain use cases suitable for abnormal testing. Therefore, in order to improve the efficiency of abnormal testing, how to efficiently and in batches generate use cases suitable for abnormal testing has become an urgent problem that technical personnel in this field need to solve. Summary of the invention
[0004] In view of this, embodiments of the present application provide a use case generation method, device, server and storage medium to efficiently and batch generate use cases suitable for exception testing.
[0005] To achieve the above objectives, the present application provides the following technical solutions:
[0006] A use case generation method, wherein the method comprises:
[0007] Obtain a first derived use case derived from the seed use case;
[0008] Determine a seed log chain generated by executing a test on the business system using the seed use case, and a first log chain generated by executing a test on the business system using the first derivative use case;
[0009] Comparing the seed log chain with the first log chain, and based on the comparison result, determining, from the first derived use case, a target use case in which the log information of the first log chain has at least new error information compared with the log information of the seed log chain;
[0010] Deriving a second derived use case based at least on the target use case parameters of the target use case derived from the seed use case;
[0011] A use case that causes an exception in the business system is determined from the second derived use case, and the use case is suitable for exception testing of the business system.
[0012] The present application also provides a use case generation device, including:
[0013] A first derivative module, used to obtain a first derivative use case derived from the seed use case;
[0014] A log chain determination module, used to determine a seed log chain generated by executing a test on the business system using the seed use case, and a first log chain generated by executing a test on the business system using the first derivative use case;
[0015] a target use case determination module, configured to compare the seed log chain with the first log chain, and based on the comparison result, determine, from a first derived use case, a target use case in which log information of the first log chain at least has new error information compared to log information of the seed log chain;
[0016] A second derivation module, configured to derive a target use case parameter of the target use case based at least on the seed use case, and derive a second derived use case;
[0017] A use case determination module is used to determine a use case that causes an exception in the business system from the second derived use case, and the use case is suitable for exception testing of the business system.
[0018] An embodiment of the present application also provides a server, comprising: at least one memory and at least one processor; the memory stores one or more computer executable instructions, and the processor calls the one or more computer executable instructions to execute the use case generation method as described above.
[0019] An embodiment of the present application also provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the use case generation method described above.
[0020] The use case generation method provided in the embodiment of the present application can obtain a first derived use case derived from a seed use case, and compare the seed log chain generated by executing the test on the business system with the seed use case, and the first log chain generated by executing the test on the business system with the first derived use case; based on the comparison result, the embodiment of the present application can determine from the first derived use case a target use case whose log information of the first log chain at least has new error information compared with the log information of the seed log chain, and the target use case can be considered as a use case that is likely to be suitable for exception testing; thus, the embodiment of the present application can derive the target use case parameters of the target use case based on at least the seed use case, derive a second derived use case, and expand the number of use cases that are likely to be suitable for exception testing; further, the use case that causes the business system to become abnormal is determined from the second derived use case, and the number of generated use cases that are suitable for exception testing can be increased. It can be seen that in the embodiment of the present application, since the target use case is a use case that is potentially suitable for exception testing, and the target use case parameters are use case parameters of the target use case derived from the seed use case, a second derived use case is further derived based on the target use case parameters. The embodiment of the present application can expand the scope of use cases that can be mined that are suitable for exception testing, thereby determining the use case that causes the business system to become abnormal from the second derived use case, and can generate more use cases suitable for exception testing of the business system, thereby achieving the effect of efficiently and batch-generating use cases suitable for exception testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0022] Figure 1 A flowchart of a use case generation method provided in an embodiment of the present application;
[0023] Figure 2 A flowchart of deriving a second derivative use case provided by an embodiment of the present application;
[0024] Figure 3 An example diagram of iteratively deriving a second derivative use case provided in an embodiment of the present application;
[0025] Figure 4 Another flow chart of the use case generation method provided in an embodiment of the present application;
[0026] Figure 5 Another flow chart of the use case generation method provided in the embodiment of the present application;
[0027] Figure 6 An example diagram of the abnormal use case generation process provided in the embodiment of the present application;
[0028] Figure 7 A block diagram of a use case generation device provided in an embodiment of the present application;
[0029] Figure 8 Another block diagram of the use case generation device provided in an embodiment of the present application;
[0030] Fig. 9 An optional block diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The traditional way to generate use cases suitable for exception testing is mainly: based on seed use cases, multiple use cases are derived from the seed use cases, and then the use cases suitable for exception testing are manually screened out from the derived use cases. For example, the business system is tested using the derived use cases, and the business system is manually observed to see whether program crashes, log errors, and other anomalies occur based on the derived use cases, thereby manually screening out use cases suitable for exception testing from the derived use cases. The above-mentioned method of generating use cases suitable for exception testing involves a large amount of manual observation and screening work, and there is undoubtedly a problem of low use case generation efficiency; at the same time, the scope of the generated use cases is limited to the use cases derived from the seed use cases, resulting in a relatively limited number of generated use cases suitable for exception testing, and the inability to achieve batch generation of use cases.
[0032] Based on this, the embodiments of the present application provide a use case generation method, device, server and storage medium to efficiently and batch generate use cases suitable for exception testing. The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0033] In an alternative implementation, Figure 1 The optional process of the use case generation method provided in the embodiment of the present application is shown, which can be executed by the server, referring to Figure 1 , the process may include:
[0034] Step S100: Obtain a first derived use case derived from a seed use case.
[0035] In an optional implementation, the seed case may be a case suitable for normal testing; the server may determine the seed case from the generated case suitable for normal testing, for example, the seed case is any generated case suitable for normal testing, or the seed case is a case selected from the generated case suitable for normal testing. It should be noted that normal testing is the process of testing a business system using normal operations, normal data, etc., and normal testing requires the use of case suitable for normal testing. Conversely, abnormal testing is the process of testing a business system using erroneous operations, erroneous data, etc., and abnormal testing requires the use of case suitable for abnormal testing.
[0036] The embodiment of the present application can derive a first derived use case based on a seed use case. In an optional implementation of deriving the first derived use case based on the seed use case, the embodiment of the present application can adjust the use case parameters in the seed use case, for example, mutate (modify), combine, and other operations on the use case parameters in the seed use case to obtain the first derived use case. A use case parameter after adjustment of the seed use case can correspond to a derived first derived use case, so that the embodiment of the present application can obtain multiple first derived use cases;
[0037] Optionally, the seed case may include test input, test data and expected results, etc., and the test input, test data and expected results may have multiple test case parameters; as an example of combining the test case parameters of the seed case to obtain the first derived case, assuming that the test input of the seed case has three parameters a, b, and c, and the data type of each parameter is int / boolen / String, then theoretically, the parameters a, b, and c can have multiple parameter combinations, and the use case corresponding to each parameter combination can be used as a first derived use case; where int is an identifier for defining an integer type variable, boolen is a value stored by a Boolean object or a value to be converted into a Boolean value, and String represents the data type of a string;
[0038] Of course, the embodiment of the present application may also modify (i.e., mutate) the use case parameters of the seed use case to obtain a first derived use case; in an optional implementation, the embodiment of the present application may utilize a preset multi-factor model to derive multiple first derived use cases based on the seed use case, and the multi-factor model may associate multiple mutation factors for modifying the use case parameters to modify the use case parameters in the seed use case.
[0039] Step S110: Determine a seed log chain generated by executing a test on the business system using the seed use case, and a first log chain generated by executing a test on the business system using the first derived use case.
[0040] The first derived use case may include use cases applicable to normal testing, use cases applicable to abnormal testing, use cases with the possibility of being applicable to abnormal testing, etc. For ease of description, the embodiment of the present application refers to the use cases with the possibility of being applicable to abnormal testing in the first derived use case as target use cases;
[0041] Generally speaking, the number of use cases suitable for exception testing in the first derived use case is smaller than the target use case, or even there is no use case suitable for exception testing in the first derived use case. Directly determining the use cases suitable for exception testing from the first derived use case can often only obtain a small number of use cases suitable for exception testing, or no use cases suitable for exception testing can be obtained. Although the target use case cannot be directly used as a use case suitable for exception testing, the target use case has the possibility of being suitable for exception testing, and the target use case occupies a certain proportion in the first derived use case. Therefore, in order to achieve efficient batch generation of use cases suitable for exception testing, the embodiment of the present application can determine the target use case that has the possibility of being suitable for exception testing from the first derived use case, thereby mining more use cases suitable for exception testing based on the target use case, which provides the possibility for achieving efficient batch generation of use cases suitable for exception testing.
[0042] Based on this, the embodiments of the present application can use the seed use case to test the business system, obtain the generated seed log chain, and use the first derivative use case to test the business system, obtain the generated first log chain, so that by subsequently comparing the first log chain and the seed log chain, the target use case that may be suitable for exception testing can be determined from the first derivative use case, thereby providing the possibility of expanding the scope of use cases suitable for exception testing.
[0043] In an optional implementation, the process of executing a test case on a business system involves multiple execution nodes of the business system, and each execution node completes its own execution logic, so that the business system finally outputs the test results. When executing a test on a business system with a use case (such as a seed use case, a first derivative use case, etc.), the embodiment of the present application can collect the log information of each execution node of the business system involved in the test, and link the log information in the execution order of the execution node to obtain the log chain generated by executing the test on the business system with the use case;
[0044] The log chain can be understood as a sequential data chain including log information of execution nodes; the embodiment of the present application can collect log information of each execution node of the business system involved in the execution test when the business system is tested with a seed use case, and link the log information with the execution order of the execution nodes, so as to determine the seed log chain generated by the execution test of the business system with the seed use case; for example, the seed log chain can be expressed as: [debug, execution node 1]=>[debug, execution node 2]=>[warn, execution node 3]=>[error, execution node 4], wherein debug represents debugging, warn represents warning, and error represents error; it can be seen from the seed log chain of the above example that the seed log chain can record the execution nodes of the business system involved in the execution process of the seed use case, the execution order of the execution nodes, and the log information of the execution nodes; for example, in the above example, the execution nodes represented by the seed log chain are execution nodes 1, 2, 3 and 4; the execution order of the execution nodes is: execution node 1-execution node 2-execution node 3-execution node 4; in the above example, warn is the warning information in the log information of execution node 3, and error is the error information in the log information of execution node 4.
[0045] Similarly, when testing the business system with the first derivative use case, the embodiment of the present application can collect the log information of each execution node of the business system involved in the test, and link the log information according to the execution order of the execution nodes, so as to determine the first log chain generated by testing the business system with the first derivative use case. It can be understood that when testing the business system with a first derivative use case, a first log chain can be generated. When multiple first derivative use cases are used to test the business system, the embodiment of the present application can obtain multiple first log chains.
[0046] Step S120: Compare the seed log chain and the first log chain, and based on the comparison result, determine, from the first derived use case, a target use case in which the log information of the first log chain has at least new error information compared with the log information of the seed log chain.
[0047] Based on the obtained seed log chain and the first log chain, in an optional implementation, the embodiment of the present application can determine a target use case that has the possibility of being suitable for anomaly testing from the first derived use case by comparing the first log chain and the seed log chain.
[0048] Optionally, the embodiment of the present application may define the target use case as: in the first derived use case, the log information of the first log chain has at least new error information compared to the log information of the seed log chain. Therefore, in the optional implementation of determining the target use case from the first derived use case, the embodiment of the present application may compare the first log chain and the seed log chain. If it is determined that the log information of the first log chain has at least new error information compared to the log information of the seed log chain, then the first derived use case with the first log chain is the target use case, that is, the log information of the first log chain has redundant new errors (error information) compared to the log information of the seed log chain, then the first derived use case with the first log chain can be used as the target use case.
[0049] In a further optional implementation, there may also be use cases suitable for exception testing in the first derived use case. The embodiment of the present application may also directly determine the use cases suitable for exception testing from the first derived use case. For example, the embodiment of the present application may analyze the first log chain and directly determine the use cases suitable for exception testing from the first derived use case. The embodiment of the present application may define the use cases suitable for exception testing as: use cases that cause exceptions in the business system, such as causing a program crash in the business system, and / or causing log confusion in the business system due to process restart. Thus, if the embodiment of the present application determines that there is program crash information in the log information of the first log chain, and / or that the log information of the first log chain is confused due to process restart, then the first derived use case having the first log chain is a use case suitable for exception testing.
[0050] Step S130: derive a second derived use case based at least on the target use case parameters of the target use case derived from the seed use case.
[0051] The target use case is determined from the first derived use case, and the first derived use case is obtained by adjusting the use case parameters of the seed use case. After determining the target use case, the embodiment of the present application can determine the target use case parameters of the target use case derived from the seed use case, that is, the target use case parameters are the use case parameters of the target use case obtained by adjusting the seed use case. It can be understood that by adjusting the target use case parameters in the seed use case, a target use case with the possibility of being suitable for abnormal testing can be obtained. Therefore, the target use case parameters in the seed use case are adjusted several times in different ways, or, based on the target use case, the use case inheritance is performed with the target use case parameters, which may dig out more potential use cases suitable for abnormal testing. Therefore, the embodiment of the present application can derive more use cases (the embodiment of the present application may be referred to as the second derived use case) based on the target use case parameters to provide the possibility of digging out more use cases suitable for abnormal testing.
[0052] Step S140: Determine a use case that causes an exception in the business system from the second derived use case, where the use case is suitable for exception testing of the business system.
[0053] Optionally, use cases suitable for exception testing may be: use cases that cause exceptions to occur in the business system, such as causing a program crash in the business system, and / or causing log errors in the business system due to process restart; after obtaining the second derived use case, the embodiment of the present application may determine the use case that causes the business system to become abnormal from the second derived use case, thereby obtaining use cases suitable for exception testing of the business system; compared to directly determining the use case suitable for exception testing from the first derived use case, the embodiment of the present application determines the use case suitable for exception testing from the second derived use case, and can thereby discover more use cases suitable for exception testing.
[0054] In an optional implementation of determining a use case suitable for exception testing from a second derived use case, an embodiment of the present application can determine a second log chain generated by executing a test on a business system using the second derived use case. If the log information of the second log chain contains program crash information, and / or the log information of the second log chain is disordered due to a process restart, then the embodiment of the present application can determine that the second derived use case having the second log chain is a use case suitable for exception testing.
[0055] The use case generation method provided in the embodiment of the present application can obtain a first derived use case derived from a seed use case, and compare the seed log chain generated by executing the test on the business system with the seed use case, and the first log chain generated by executing the test on the business system with the first derived use case; based on the comparison result, the embodiment of the present application can determine from the first derived use case a target use case whose log information of the first log chain at least has new error information compared with the log information of the seed log chain, and the target use case can be considered as a use case that is likely to be suitable for exception testing; thus, the embodiment of the present application can derive the target use case parameters of the target use case based on at least the seed use case, derive a second derived use case, and expand the number of use cases that are likely to be suitable for exception testing; further, the use case that causes the business system to become abnormal is determined from the second derived use case, and the number of generated use cases that are suitable for exception testing can be increased. It can be seen that in the embodiment of the present application, since the target use case is a use case that is potentially suitable for exception testing, and the target use case parameters are use case parameters of the target use case derived from the seed use case, a second derived use case is further derived based on the target use case parameters. The embodiment of the present application can expand the scope of use cases that can be mined that are suitable for exception testing, thereby determining the use case that causes the business system to become abnormal from the second derived use case, and can generate more use cases suitable for exception testing of the business system, thereby achieving the effect of efficiently and batch-generating use cases suitable for exception testing.
[0056] In the optional implementation of determining the target use case from the first derived use case, if the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain contains new error information compared to the log information of the seed log chain, then the embodiment of the present application can determine that the first derived use case having the first log chain is the first target use case; the first target use case can be an optional form of the target use case in the embodiment of the present application. Although the first target use case is not directly used as a use case suitable for exception testing, it has a strong possibility of being suitable for exception testing.
[0057] For the first target use case, the embodiment of the present application can derive a second derived use case. In an optional implementation, the embodiment of the present application can derive the target use case parameters of the first target use case based on the seed use case, and iteratively derive the second derived use case based on the first target use case. In an optional implementation, Figure 2 The optional process of deriving the second derivative use case provided in the embodiment of the present application is shown, such as Figure 2 As shown, the process may include:
[0058] Step S200: During the first iteration, the target use case parameters in the first target use case are adjusted multiple times to obtain a second derived use case derived from the first iteration.
[0059] In the first iteration of the embodiment of the present application, the target use case parameters of the first target use case can be derived from the seed use case, and based on the first target use case, the target use case parameters in the first target use case can be adjusted multiple times (such as multiple modifications) to obtain a second derived use case derived from the first iteration. Specifically, a second derived use case can be derived by adjusting the target use case parameters in the first target use case once, and thus multiple second derived use cases can be derived by adjusting the target use case parameters in the first target use case multiple times.
[0060] For example, Figure 3 As shown, by making different modifications to the use case parameters of the seed use case 1, the first derived use cases 11, 12, 13 and 14 can be obtained. If the first derived use case 13 is the first target use case, and the first target use case is obtained by modifying the use case parameter M in the seed use case; that is, modifying the use case parameter M in the seed use case will derive use case descendants with a stronger possibility of being suitable for abnormal testing, then after obtaining the first target use case, the embodiment of the present application can modify the use case parameter M in the first target use case as many times as possible during the first iteration, based on the first target use case, so as to inherit more use case descendants with a stronger possibility of being suitable for abnormal testing, so as to mine more use cases suitable for abnormal testing from these use case descendants. For example, Figure 3As shown, during the first iteration, the embodiment of the present application can modify the use case parameter M in the first derived use case 13 as many times as possible to obtain second derived use cases 131, 132, 133 derived from the first iteration.
[0061] Step S210: When it is not the first iteration, determine the log chain generated by executing the test on the business system using the second derivative use case derived from the previous iteration, and from the second derivative use case derived from the previous iteration, determine the use case in which the log information of the log chain has new error information at least compared to the log information of the seed log chain, and adjust the target use case parameters in the determined use case multiple times to obtain the second derivative use case derived from this iteration.
[0062] In the case of a non-first iteration, the embodiment of the present application can determine a use case that is likely to be suitable for anomaly testing from the second derivative use case derived from the previous iteration; in an optional implementation, the embodiment of the present application can test the business system using the second derivative use case derived from the previous iteration to obtain a generated log chain, and compare the obtained log chain with the seed log chain. If the log information of the log chain contains at least new error information compared to the log information of the seed log chain, then the second derivative use case derived from the previous iteration with the log chain can be determined to be a use case that is likely to be suitable for anomaly testing. After determining a use case that is likely to be suitable for anomaly testing from the second derivative use case derived from the previous iteration, the embodiment of the present application can adjust the target use case parameters in the use case multiple times to obtain the second derivative use case derived from this iteration.
[0063] Example, combined Figure 3 As shown, in the second iteration, if the second derived use case 132 in the second derived use case derived from the first iteration is a use case that has the possibility of being suitable for abnormal testing, then the embodiment of the present application can modify the target use case parameter M in the second derived use case 132 multiple times to obtain the second derived use case derived from the second iteration.
[0064] The embodiment of the present application can set the number of iterations of the above-mentioned iterative process, for example, set the number of iterations to a set number, that is, the iteration ends after the set number of times. The specific value of the set number of times can be set according to actual conditions, and the embodiment of the present application is not limited.
[0065] Furthermore, the embodiment of the present application can determine the use case suitable for abnormal testing from the second derived use case derived from each iteration. In an optional implementation, for the second derived use case derived from each iteration, the embodiment of the present application can determine the second log chain generated by executing the test on the business system with the second derived use case; if the log information of the second log chain contains program crash information, and / or the log information of the second log chain is disordered due to process restart, then the second derived use case with the second log chain can be determined as a use case suitable for abnormal testing.
[0066] On the basis of determining the first target use case, the embodiment of the present application may also provide other possible ways to derive the second derived use case. In an optional implementation, the embodiment of the present application may derive the target use case parameters of the first target use case based on the seed use case, and adjust the target use case parameters in the seed use case multiple times to obtain the second derived use case derived from the seed use case; it can be understood that the first target use case is obtained by adjusting the target use case parameters of the seed use case, then the embodiment of the present application may perform the same operation on the seed use case to obtain the first target use case (i.e., adjust the target use case parameters in the seed use case multiple times again) to obtain more use case descendants with a strong possibility of being suitable for abnormal testing, so as to mine more use cases suitable for abnormal testing from these use case descendants. Based on the second derived use case derived from the seed use case, the embodiment of the present application may determine the second log chain generated by the test of the business system with the second derived use case. If there is program crash information in the log information of the second log chain, and / or, the second log chain is disordered due to the restart of the process, then the embodiment of the present application may determine that the second derived use case with the second log chain is a use case suitable for abnormal testing.
[0067] In another optional implementation, the target use case may be a second target use case, and the second target use case has a moderate possibility of being suitable for exception testing; after comparing the first log chain and the seed log chain, if the first log chain has new node branches compared to the seed log chain (it can be understood that the first log chain and the seed log chain can both represent the execution nodes of the business system, so that the first log chain and the seed log chain can both have one or more execution node branches. Here, the embodiment of the present application determines that the first log chain has redundant new execution node branches compared to the seed log chain), and the log information of the first log chain has new error information compared to the log information of the seed log chain, then the first derivative use case with the first log chain is determined to be the second target use case. For the second target use case, the embodiment of the present application can perform homogeneous operations on the seed use case to obtain the second target use case, so as to obtain more use case descendants with a moderate possibility of being suitable for exception testing. Optionally, Figure 4 Another process of the use case generation method provided in the embodiment of the present application is shown. Figure 4 As shown, the process may include:
[0068] Step S300: Obtain a seed use case.
[0069] Step S310: derive a first derived use case of the seed use case based on the use case parameters of the seed use case.
[0070] Step S320: determine a seed log chain generated by executing a test on the business system using the seed use case, and determine a first log chain generated by executing a test on the business system using the first derivative use case.
[0071] Step S330: compare the seed log chain and the first log chain. If the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain has new error information compared to the log information of the seed log chain, determine that the first derivative use case with the first log chain is the second target use case.
[0072] Step S340: determine target use case parameters of a second target use case derived from the seed use case, adjust the target use case parameters in the seed use case multiple times, and obtain a second derived use case derived from the seed use case.
[0073] Step S350: Determine a second log chain generated by executing the test on the business system using the second derived use case.
[0074] Step S360: If there is program crash information in the log information of the second log chain, and / or the log information of the second log chain is disordered due to process restart, determine that the second derivative use case with the second log chain is a use case suitable for exception testing.
[0075] After determining a second target use case with a moderate possibility of being suitable for abnormal testing from the first derived use case, the embodiment of the present application can derive target use case parameters of the second target use case based on the seed use case, and perform multiple homogeneous operations on the seed use case to obtain the second target use case, so as to obtain more use case descendants with a moderate possibility of being suitable for abnormal testing, and then mine more use cases suitable for abnormal testing from these use case descendants, thereby expanding the scope of the mineable use cases suitable for abnormal testing.
[0076] It can be understood that if the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, the embodiment of the present application can determine that the first derivative use case with the first log chain is a non-target use case, and the embodiment of the present application can not process the first derivative use case of the non-target use case; in a more specific optional implementation, if the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, then the first derivative use case with the first log chain is a non-target use case, and the non-target use case does not have the possibility of being applicable to abnormal testing;
[0077] In other optional implementations, if the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain does not have new error information compared to the log information of the seed log chain, then the first derivative use case with the first log chain is a non-target use case.
[0078] In a more complete alternative implementation, Figure 5 Another process of the use case generation method provided in the embodiment of the present application is shown. Figure 5 As shown, the process may include:
[0079] Step S400: Obtain a seed use case.
[0080] Step S410: derive a first derived use case of the seed use case based on the use case parameters of the seed use case.
[0081] Step S420: determine a seed log chain generated by executing a test on the business system using the seed use case, and determine a first log chain generated by executing a test on the business system using the first derived use case.
[0082] Step S430: If there is program crash information in the log information of the first log chain, and / or the log information of the first log chain is disordered due to process restart, determine that the first derivative use case with the first log chain is a use case suitable for exception testing.
[0083] Step S440: If the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain contains new error information compared to the log information of the seed log chain, determine that the first derived use case with the first log chain is the first target use case.
[0084] Step S450, deriving the target use case parameters of the first target use case at least based on the seed use case, iteratively deriving the second derived use case based on the first target use case; and adjusting the target use case parameters of the first target use case derived from the seed use case multiple times to obtain the second derived use case derived from the seed use case.
[0085] For the first target use case determined in step S440, the embodiment of the present application is based on the first target use case, and through the target use case parameters, inherits more use case offspring with a stronger possibility of being suitable for abnormal testing; for more specific iterative processes, please refer to the description of the corresponding part of the previous text, which will not be repeated here.
[0086] At the same time, the embodiment of the present application can derive the target case parameters of the first target case based on the seed case, and perform homogeneous operations on the seed case to obtain the first target case, so as to obtain more case descendants with a stronger possibility of being suitable for exception testing.
[0087] Step S460: If the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain has new error information compared to the log information of the seed log chain, determine that the first derived use case with the first log chain is the second target use case.
[0088] Step S470: Adjust the target use case parameters of the second target use case derived from the seed use case multiple times to obtain a second derived use case derived from the seed use case.
[0089] For the second target use case determined in step S460, the embodiment of the present application can derive the target use case parameters of the second target use case based on the seed use case, and perform homogeneous operations on the seed use case to obtain the second target use case, so as to obtain more use case offspring with a moderate possibility of being suitable for abnormal testing.
[0090] Step S480: Determine a second log chain generated by executing the test on the business system using the second derived use case.
[0091] Step S490: If there is program crash information in the log information of the second log chain, and / or the log information of the second log chain is disordered due to process restart, determine that the second derivative use case with the second log chain is a use case suitable for exception testing.
[0092] For the second derivative use case derived from the embodiment of the present application, for example, the second derivative use case derived based on step S450 and / or step S470, the embodiment of the present application can use the second derivative use case to test the business system to obtain the generated second log chain. If there is program crash information in the log information of the second log chain, and / or the log information of the second log chain is disordered due to process restart, then the second derivative use case with the second log chain can be determined as a use case suitable for exception testing.
[0093] It should be noted that further Figure 5 As shown, the process may also include:
[0094] Step S500: If the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, determine that the first derived use case having the first log chain is a non-target use case.
[0095] In the process of comparing the first log chain and the seed log chain, if the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, it can be determined that the first derivative use case with the first log chain is a non-target use case, and the embodiment of the present application may not process the non-target use case.
[0096] The embodiment of the present application further derives a second derived use case based on the target use case parameters derived from the seed use case, thereby expanding the scope of use cases that can be mined that are suitable for exception testing. Compared with directly mining use cases suitable for exception testing from the first derived use case derived from the seed use case, the embodiment of the present application can mine more use cases suitable for exception testing, achieving the effect of efficiently and batch-generating use cases suitable for exception testing. At the same time, by comparing the first log chain corresponding to the execution of the first derived use case with the seed log chain corresponding to the seed use case, the embodiment of the present application can determine the possibility that each first derived use case is suitable for exception testing, and perform different subsequent processing on the first derived use cases with different possibilities, thereby achieving the effect of more accurately mining use cases suitable for exception testing.
[0097] As an optional implementation, the embodiment of the present application may define a sharp change relationship rule, which may define the log chain characteristics of the abnormal use case and the target use case. For example, the sharp change relationship rule may at least define:
[0098] If the log information of the use case contains at least new error information compared to the log information of the seed log chain, then the use case is the target use case; the definition of the target use case is specifically the first target use case and the second target use case, which can be referred to the corresponding part of the previous text and will not be repeated here;
[0099] If the log information of a use case contains program crash information and / or the log information is disordered due to process restart, then the use case is suitable for exception testing.
[0100] Based on the defined sharp change relationship rules, Figure 6 An example of the abnormal use case generation process provided by the embodiment of the present application is shown, referring to Figure 6 :
[0101] After determining the seed use case, the embodiment of the present application may derive a first derived use case of the seed use case based on the seed use case;
[0102] At the same time, for the seed use case, the embodiment of the present application can perform a test on the business system based on the seed use case, collect the log information of the execution nodes of the business system when the test is performed, and link them into a seed log chain according to the execution order of the execution nodes; for any first derivative use case, the embodiment of the present application can perform a test on the business system based on the first derivative use case, thereby collecting the log information of the execution nodes of the business system when the test is performed, and linking them into a first log chain according to the execution order of the execution nodes;
[0103] Furthermore, the embodiment of the present application can compare the first log chain and the seed log chain, and determine the use cases suitable for abnormal testing, target use cases with the possibility of being suitable for abnormal testing, non-target use cases, etc. from the first derived use cases based on the preset sharp change relationship rule;
[0104] For a determined target use case, the embodiment of the present application may derive target use case parameters of the target use case based on the seed use case, and perform use case inheritance to derive a second derived use case; for example, for a first target use case, the embodiment of the present application may derive target use case parameters of the first target use case based on the seed use case, iteratively derive a second derived use case based on the first target use case, and perform the same operation of deriving the first target use case on the seed use case to derive the second derived use case;
[0105] Based on the derived second derivative use case, the embodiment of the present application can determine the second log chain generated by executing the test on the business system with the second derivative use case. If there is program crash information in the second log chain, and / or the log information is disordered due to process restart, then the second derivative use case with the second log chain is a use case suitable for exception testing.
[0106] In addition to mining use cases suitable for exception testing from the first derived use case, the embodiment of the present application can also mine use cases suitable for exception testing from the further derived second derived use case, thereby expanding the scope of use cases suitable for exception testing that can be mined and enabling efficient batch generation of use cases suitable for exception testing.
[0107] The above describes multiple implementation schemes provided by the embodiments of the present application. The various optional methods introduced in each implementation scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible implementation schemes, which can all be considered as implementation schemes disclosed and open in the embodiments of the present application.
[0108] The use case generation device provided in the embodiment of the present application is introduced below. The use case generation device described below can be considered as a functional module that the server needs to set up to implement the use case generation method provided in the embodiment of the present application. The content of the use case generation device described below can be referenced to the content of the use case generation method described above.
[0109] Optional, Figure 7 A block diagram of a use case generation device provided in an embodiment of the present application is shown. Figure 7 As shown, the device may include:
[0110] A first derivation module 100, used to obtain a first derived use case derived from a seed use case;
[0111] The log chain determination module 110 is used to determine a seed log chain generated by executing a test on the business system using the seed use case, and a first log chain generated by executing a test on the business system using the first derivative use case;
[0112] A target use case determination module 120 is used to compare the seed log chain and the first log chain, and based on the comparison result, determine, from the first derived use case, a target use case in which the log information of the first log chain has at least new error information compared with the log information of the seed log chain;
[0113] A second derivation module 130, configured to derive a target use case parameter of the target use case based at least on the seed use case, and derive a second derived use case;
[0114] The use case determination module 140 is used to determine the use case that causes the business system to be abnormal from the second derived use case, and the use case is suitable for abnormal testing of the business system.
[0115] Optionally, the target use case determination module 120 is used to determine, based on the comparison result, from the first derived use case, a target use case in which the log information of the first log chain has at least new error information compared with the log information of the seed log chain, including:
[0116] If the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain contains new error information compared to the log information of the seed log chain, the first derivative use case with the first log chain is determined to be the first target use case.
[0117] Optionally, based on the first target use case, the second derivation module 130 is configured to derive a target use case parameter of the target use case based at least on the seed use case, and derive a second derived use case, including:
[0118] At least based on the target use case parameters, a second derived use case is iteratively derived based on the first target use case.
[0119] Optionally, the second derivation module 130 is configured to iteratively derive a second derived use case based on at least the target use case parameter and the first target use case, including:
[0120] In the first iteration, the target use case parameters in the first target use case are adjusted multiple times to obtain a second derived use case derived from the first iteration, wherein the target use case parameters in the first target use case are adjusted once to obtain a second derived use case;
[0121] When it is not the first iteration, determine the log chain generated by executing the test on the business system using the second derivative use case derived from the previous iteration, and from the second derivative use case derived from the previous iteration, determine the use case in which the log information of the log chain has new error information at least compared to the log information of the seed log chain, adjust the target use case parameters in the determined use case multiple times, and obtain the second derivative use case derived from this iteration.
[0122] Optionally, in another optional implementation of the target use case, the target use case may be a second target use case; the target use case determination module 120 is used to determine, based on the comparison result, from the first derived use case, a target use case in which the log information of the first log chain has at least new error information compared to the log information of the seed log chain, including:
[0123] If the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain has new error information compared to the log information of the seed log chain, determine that the first derivative use case with the first log chain is the second target use case.
[0124] In another optional implementation of deriving a second derived use case from the second derivation module 130 based on the first target use case and / or the second target use case, the second derivation module 130 is configured to derive a second derived use case based on at least a target use case parameter of the target use case derived from the seed use case, and includes:
[0125] The target use case parameters in the seed use case are adjusted multiple times to obtain a second derived use case derived from the seed use case.
[0126] Based on the obtained second derived use case, in an optional implementation, the use case determination module 140 is used to determine the use case that causes the business system to be abnormal from the second derived use case, including:
[0127] Determine a second log chain generated by executing a test on the business system using the second derivative use case;
[0128] If the log information of the second log chain contains program crash information, and / or the log information of the second log chain is disordered due to process restart, the second derivative use case having the second log chain is determined to be the use case that causes the business system to become abnormal.
[0129] Optional, Figure 8 Another block diagram of the use case generation device provided in the embodiment of the present application is shown, Figure 7 and Figure 8 As shown, the device may also include:
[0130] The use case direct determination module 150 is used to determine that the first derivative use case with the first log chain is the use case that causes the business system to become abnormal if there is program crash information in the log information of the first log chain and / or the log information of the first log chain is disordered due to process restart.
[0131] Optional, combined Figure 8 As shown, the use case generating device may also include:
[0132] The non-target use case determination module 160 is configured to determine that the first derivative use case having the first log chain is a non-target use case if the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain.
[0133] Optionally, the embodiments of the present application do not process non-target use cases.
[0134] In an optional implementation, the non-target use case determination module 160 is configured to determine that the first derivative use case having the first log chain is a non-target use case if the log information of the first log chain does not contain new error information compared to the log information of the seed log chain, including:
[0135] If the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, it is determined that the first derivative use case with the first log chain is a non-target use case;
[0136] and / or,
[0137] If the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain does not have new error information compared to the log information of the seed log chain, it is determined that the first derivative use case with the first log chain is a non-target use case.
[0138] Optionally, the first derivation module 100, for obtaining a first derived use case derived from a seed use case, may include:
[0139] A seed use case is obtained, and based on the use case parameters of the seed use case, a first derived use case of the seed use case is derived.
[0140] The use case generation device provided in the embodiment of the present application can realize efficient and batch generation of use cases suitable for exception testing.
[0141] The embodiment of the present application also provides a server. Optionally, the server can be loaded with the above-mentioned use case generation device in the form of a program to implement the use case generation method provided in the embodiment of the present application. In an optional implementation, Fig. 9 An optional block diagram of a server provided in an embodiment of the present application is shown, such as Fig. 9 As shown, the server may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;
[0142] In the embodiment of the present application, the number of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 is at least one, and the processor 1, the communication interface 2, and the memory 3 communicate with each other through the communication bus 4; obviously, the communication connection diagram of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 shown in the figure is only optional;
[0143] Optionally, the communication interface 2 may be an interface of a communication module for performing network communication;
[0144] Optionally, processor 1 may be a CPU (central processing unit), a GPU (Graphics Processing Unit), an NPU (embedded neural network processor), an FPGA (Field Programmable Gate Array), a TPU (tensor processing unit), an AI chip, an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement an embodiment of the present application.
[0145] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0146] Among them, the memory 3 stores one or more computer-executable instructions, and the processor 1 calls the one or more computer-executable instructions to execute the use case generation method provided in the embodiment of the present application.
[0147] An embodiment of the present application also provides a storage medium, which can store one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the use case generation method provided in the embodiment of the present application.
[0148] Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be subject to the scope defined by the claims.
Claims
1. A method for generating a use case, wherein: The method comprises: Obtain a first derived use case derived from the seed use case; Determine a seed log chain generated by executing a test on the business system using the seed use case, and a first log chain generated by executing a test on the business system using the first derivative use case; Comparing the seed log chain with the first log chain, and based on the comparison result, determining, from the first derived use case, a target use case in which the log information of the first log chain has at least new error information compared with the log information of the seed log chain; Deriving a second derived use case based at least on the target use case parameters of the target use case derived from the seed use case; A use case that causes an exception in the business system is determined from the second derived use case, and the use case is suitable for exception testing of the business system.
2. The use case generation method according to claim 1, wherein: The target use case of determining, based on the comparison result, from the first derived use case, that the log information of the first log chain has new error information at least compared with the log information of the seed log chain includes: If the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain contains new error information compared to the log information of the seed log chain, the first derivative use case with the first log chain is determined to be the first target use case.
3. The use case generation method according to claim 2, wherein: The step of deriving the target use case parameter of the target use case at least based on the seed use case, and deriving the second derived use case comprises: At least based on the target use case parameters, a second derived use case is iteratively derived based on the first target use case.
4. The use case generation method according to claim 3, wherein: The iteratively deriving a second derived use case based on at least the target use case parameter and the first target use case comprises: In the first iteration, the target use case parameters in the first target use case are adjusted multiple times to obtain a second derived use case derived from the first iteration, wherein the target use case parameters in the first target use case are adjusted once to obtain a second derived use case; When it is not the first iteration, determine the log chain generated by executing the test on the business system using the second derivative use case derived from the previous iteration, and from the second derivative use case derived from the previous iteration, determine the use case in which the log information of the log chain has new error information at least compared to the log information of the seed log chain, adjust the target use case parameters in the determined use case multiple times, and obtain the second derivative use case derived from this iteration.
5. The use case generation method according to claim 1, wherein: The target use case of determining, based on the comparison result, from the first derived use case, that the log information of the first log chain has new error information at least compared with the log information of the seed log chain includes: If the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain has new error information compared to the log information of the seed log chain, determine that the first derivative use case with the first log chain is the second target use case.
6. The use case generation method according to claim 2 or 5, wherein: The step of deriving the target use case parameter of the target use case at least based on the seed use case, and deriving the second derived use case comprises: The target use case parameters in the seed use case are adjusted multiple times to obtain a second derived use case derived from the seed use case.
7. The use case generation method according to claim 1, wherein: The use case that causes the business system to be abnormal is determined from the second derived use case, including: Determine a second log chain generated by executing a test on the business system using the second derivative use case; If the log information of the second log chain contains program crash information, and / or the log information of the second log chain is disordered due to process restart, the second derivative use case having the second log chain is determined to be the use case that causes the business system to become abnormal.
8. The use case generation method according to claim 1, wherein: The method further comprises: If there is program crash information in the log information of the first log chain, and / or the log information of the first log chain is disordered due to process restart, it is determined that the first derivative use case with the first log chain is the use case that causes the business system to become abnormal.
9. The use case generation method according to claim 1, wherein: The method further comprises: If the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, it is determined that the first derived use case having the first log chain is a non-target use case.
10. The use case generation method according to claim 9, wherein: If the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, determining that the first derivative use case having the first log chain is a non-target use case includes: If the execution nodes and execution order of the first log chain are consistent with those of the seed log chain, and the log information of the first log chain does not contain any new error information compared to the log information of the seed log chain, it is determined that the first derivative use case with the first log chain is a non-target use case; and / or, If the first log chain has a new node branch compared to the seed log chain, and the log information of the first log chain does not have new error information compared to the log information of the seed log chain, it is determined that the first derivative use case with the first log chain is a non-target use case.
11. The use case generation method according to claim 1, wherein: The obtaining of a first derived use case derived from the seed use case includes: A seed use case is obtained, and based on the use case parameters of the seed use case, a first derived use case of the seed use case is derived.
12. A use case generation device, wherein: The device comprises: A first derivative module, used to obtain a first derivative use case derived from the seed use case; A log chain determination module, used to determine a seed log chain generated by executing a test on the business system using the seed use case, and a first log chain generated by executing a test on the business system using the first derivative use case; a target use case determination module, configured to compare the seed log chain with the first log chain, and based on the comparison result, determine, from a first derived use case, a target use case in which log information of the first log chain at least has new error information compared to log information of the seed log chain; A second derivation module, configured to derive a target use case parameter of the target use case based at least on the seed use case, and derive a second derived use case; A use case determination module is used to determine a use case that causes an exception in the business system from the second derived use case, and the use case is suitable for exception testing of the business system.
13. A server, wherein: The server includes: at least one memory and at least one processor; the memory stores one or more computer-executable instructions, and the processor calls the one or more computer-executable instructions to execute the use case generation method as described in any one of claims 1-11.
14. A storage medium, wherein: The storage medium stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the use case generation method as described in any one of claims 1-11.
