A test case automatic generation system based on probability extended finite state machine
By utilizing migration probability and feasibility measurement methods in the PEFSM model to eliminate infeasible paths and prioritize the generation of high-probability feasible paths, the problem of low efficiency in generating test cases using the PEFSM model is solved, achieving efficient and high-quality test case generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2026-03-24
AI Technical Summary
Existing test case generation based on the Probabilistic Extended Finite State Machine (PEFSM) model suffers from an excessive number of infeasible paths, resulting in low efficiency in test path generation.
By constructing a PEFSM model, using migration probability to represent the likelihood of migration occurring, and combining feasibility measurement methods, infeasible paths are eliminated, and feasible paths with a high probability of occurrence are generated first. Penalty values are used to quantify path feasibility, and high-quality test cases are generated.
It improves the efficiency and quality of test case generation, reduces useless calculations, and generates efficient and reliable test path sets and test cases.
Smart Images

Figure CN115757105B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of automatic test case generation technology, and particularly relates to an automatic test case generation system based on a probabilistic extended finite state machine. Background Technology
[0002] With the increasing demand for application software and the continuous development of various application software, software testing has become a crucial step in its deployment. Applying the FSM model and its extended models to the automatic generation of test cases can efficiently generate comprehensive test cases. Therefore, the use of the FSM model and its extended models to generate test cases has received widespread attention in both practice and research.
[0003] Currently, many researchers are studying or improving methods for automatically generating test cases based on the FSM model. Examples include generating test cases by traversing the FSM model based on the minimum test cost migration coverage criterion, and obtaining a merged test generation sequence by layering the FSM model. Some researchers are applying improved models to specific use cases, such as using the EFSM model for security testing of web applications, and extracting security test models from threat models.
[0004] Among them, the existing technology that is closest to the present invention in automatically generating test cases using the PEFSM model is reference [1]. The present invention combines the feasibility measurement method proposed in reference [2] and patent [3] to quantify the feasibility of the path in the PEFSM model. It utilizes the characteristic of the migration probability in the PEFSM model to represent the likelihood of migration to participate in the path feasibility calculation in order to exclude infeasible paths.
[0005] 1) Liang Haoran, Zhou Kuanjiu, Cui Kai, et al. A method for generating black-box test cases based on PEFSM behavioral model [J]. Computer Science, 2017, 44(4):7.
[0006] 2) Yang Rui, Chen Zhenyu, Zhang Zhiyi, et al. An automated test case generation method based on extended finite state machine [J]. Science in China: Information Science, 2014, 44(5): 588-609.
[0007] 3) Chen Zhenyu, Yang Rui, Xu Baowen, Zhang Jie, Zhang Zhiyi, et al. An automatic test case generation method based on feasible path analysis of extended finite state machine. CN102368226B[P]. 2012-03-07.
[0008] However, the existing techniques for generating test cases using the PEFSM model have the following limitations:
[0009] PEFSM is an extension of EFSM and shares similar properties with it: compared to FSM, it can better express the control flow and data flow, and provides a more accurate and richer description of object behavior. However, because the data flow and control flow of the object described by the EFSM model influence each other, some predicate conditions in the model cannot be satisfied, resulting in infeasible paths. When generating a test path candidate set based on the PEFSM model, a large number of infeasible paths are frequently encountered, which will greatly reduce the efficiency of generating test paths. Summary of the Invention
[0010] Based on this, this invention proposes an automatic test case generation system based on a probabilistic extended finite state machine (PEFSM). This invention performs behavioral modeling on the system under test to obtain a corresponding PEFSM model. Building upon this, improvements are made to eliminate infeasible paths in the PEFSM model. For paths whose feasibility cannot be determined using rules, a feasibility measurement method is used to calculate their feasibility values, thus eliminating some infeasible paths and reducing useless calculations during test case generation, thereby improving the efficiency of test case generation. When generating the feasible path set and test case set, the invention leverages the characteristic of transition probability in the PEFSM model, which represents the likelihood of a transition occurring. First, the transition probability is incorporated into the path feasibility calculation, helping to prioritize the selection of feasible paths with a high probability of occurrence. Then, the transition probability is further incorporated into the path probability selection during test case generation, helping to prioritize the generation of test cases with a high probability of occurrence, thus improving the quality of generated test cases.
[0011] The present invention is achieved through the following technical solution.
[0012] An automatic test case generation system based on probabilistic extended finite state machine (PEFSM) includes: a PEFSM model construction module, an infeasible path removal module, and a test case probability generation module; wherein,
[0013] The PEFSM model building module obtains relevant data for model building from the user's historical operation record database based on the requirements specification and interface design of the system under test, performs behavioral description of the system under test, and outputs the corresponding PEFSM model of the system.
[0014] The module for removing infeasible paths takes the PEFSM model as input, uses the evaluation path feasibility measurement method to identify and remove infeasible paths, and outputs a set of reliable test paths composed of migration paths.
[0015] The test case probability generation module takes the reliable test path set as input, initializes the context variables, instantiates the test paths in the path set, and outputs the test cases of the system under test.
[0016] The beneficial effects of this invention are:
[0017] 1. This invention differs from the method proposed in reference [1] in that it improves the elimination of infeasible paths in the PEFSM model. When determining the feasibility of each path in the candidate path set, it uses a feasibility measurement method to calculate the feasibility value of paths that cannot be determined by rules to measure the feasibility of the path, and sorts the feasibility values of each path to eliminate some infeasible paths and improve the efficiency of generating test cases.
[0018] 2. This invention differs from the methods proposed in references [2] and patent [3]. When generating feasible path sets and test case sets, it utilizes the characteristic of migration probability in the PEFSM model to represent the likelihood of migration occurring. It first incorporates migration probability into the path feasibility calculation, which can help prioritize the selection of feasible paths with a high probability of occurrence. Then, it incorporates migration probability into the path probability selection when generating test cases, which can help prioritize the generation of test cases with a high probability of occurrence and improve the quality of generated test cases.
[0019] 3. This invention uses penalty values to quantify the impact of definition-predicate-use pairs on the feasibility of a path, measures the feasibility of each path in the candidate path set, facilitates comparison of the feasibility between paths, provides a basis for removing infeasible paths, and ultimately obtains a reliable set of test paths, improving the quality of generated test cases and increasing the efficiency of test case generation.
[0020] 4. When measuring path feasibility, this invention utilizes the characteristic of migration probability in the PEFSM model to represent the likelihood of migration occurring. It integrates migration probability with the path feasibility model for calculation, uses migration probability to adjust the impact of the corresponding migration in the migration path, and uses an infeasible path removal module to identify and remove some infeasible paths, thereby reducing useless calculations when generating test cases and improving the efficiency of test case generation. Attached Figure Description
[0021] Figure 1 The system framework diagram for automatically generating test cases based on the probabilistic extended finite state machine of this invention is shown below.
[0022] Figure 2 This is a flowchart of the PEFSM model construction module of the present invention;
[0023] Figure 3 This is the system login and registration interface design for an embodiment of the present invention;
[0024] Figure 4 This is a schematic diagram of an intermediate model during the construction of the PEFSM model in an embodiment of the present invention;
[0025] Figure 5 A PEFSM model diagram constructed for an embodiment of the present invention;
[0026] Figure 6 The flowchart for removing infeasible paths in this invention is shown below;
[0027] Figure 7 This is a flowchart of the test case probability generation module of the present invention. Detailed Implementation
[0028] Exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be understood that the embodiments shown and described in the drawings are merely exemplary and are intended to illustrate the principles and spirit of the present invention, and are not intended to limit the scope of the present invention.
[0029] First, the technical terms used in the embodiments of this invention will be explained:
[0030] Simple state path: In the PFESM model, a state path is a path in which all vertices are different.
[0031] Simple state loop: In the PFESM model, a state loop is a path in which all vertices are different except for the first and last vertices.
[0032] like Figure 1 As shown, the present invention provides an automatic test case generation system based on a probabilistic extended finite state machine (PEFSM), specifically comprising: a PEFSM model construction module, an infeasible path removal module, and a test case probability generation module; wherein,
[0033] The PEFSM model building module obtains relevant data for model building from the user's historical operation record database based on the requirements specification and interface design of the system under test, performs behavioral description of the system under test, and outputs the corresponding PEFSM model of the system.
[0034] In existing technologies, a PEFSM model of a system under test (SUT) can be represented by a 7-tuple: Model = (I, O, S, V, P, A, T). Here, I represents the input set, O represents the output set, S represents the state set of the SUT, V represents the set of context variables, P represents the set of predicate expressions composed of variables, A represents the set of transfer actions, and T represents the set of probabilistic transfers. The transfer set T consists of several specific transfers t, and a specific transfer t can be represented by a 7-tuple: t = (s... i ,i,p,a,o,s j b), where s i s j Let represent the immigration and immigration states of transition t, respectively; let i and o represent the input and output of transition t, respectively; let p represent the predicate expression (guard) satisfied by transition t; let a represent the operation (behavior) of transition t on the context variable; and let b represent the state s from which transition t originates. iThe probability that input i triggers the corresponding migration in the outflow migration.
[0035] Based on this, such as Figure 2 As shown, the specific steps for constructing the PEFSM model are as follows:
[0036] ① Based on the requirements specification and interface design of the system under test, abstract the state set S, input set I, and output set O of the system under test;
[0037] ②Analyze and extract the variables involved in the transitions between the states of the system under test, and add them to the variable set V mentioned above;
[0038] ③ Based on the migration conditions and migration actions for each migration, extract the predicate expression set P and the migration action set A;
[0039] ④ Calculate and analyze the execution frequency of each user operation in the user's historical operation record database to obtain the migration probability of each migration, and form a migration set T with probability.
[0040] In practice, the data in the user history operation record database is obtained using user behavior data analysis tools. The user history operation record database records the number of times a user performs various operations when using the system under test. The frequency is calculated from this, and this frequency is used as the migration probability b in subsequent calculations. Once the migration probability is calculated and generated, its value is not changed.
[0041] Finally, a PEFSM model of the tested system is obtained.
[0042] The following uses the system's login and registration function as a specific example to illustrate the process of building the PEFSM model:
[0043] The design of the system login and registration interface, such as Figure 3 As shown, abstraction is performed to construct the PEFSM model, and the model is built sequentially. Figure 4 , Figure 5 The state machine shown is as follows: The various interfaces and pop-up displays of the system are abstracted into different states, resulting in a state set S. In this example, state set S is {username / password login page, main page, error message box, registration page}. It can be further abstracted as follows: Figure 5The system's state set S = {S0, S1, S2, S3}, where S0 represents the login page, S1 represents the main page, S2 represents the error message box, and S3 represents the registration page. User clicks on page buttons and input in text boxes are abstracted into different inputs to obtain input set I. In this example, input set I is {click "Login", click "Mobile Verification Login", click "Register", content entered into inputAccount, content entered into inputPwd, and agreementBox checked}. In this example, output set O is empty. The information recorded for the system's functionality is abstracted into context variables to obtain context variable set V. In this example, context variable set V is... ={inputAccount,inputPwd,agreementBox,currentAccount}, where each variable represents the user's entered account, the user's entered password, the status of the "agree" checkbox, and the logged-in user account, respectively; Based on the system requirements, the transition conditions between states are obtained, and the transition conditions are expressions represented by context variables. The set of all transition conditions forms the system's predicate expression set P; Based on the system requirements, the transition actions between states are obtained, and the transition actions are expressions represented by context variables. The set of all transition actions forms the system's migration action set A; Based on user usage habits statistically analyzed from the user's historical operation record database, the migration probability b for each migration is calculated.
[0044] by Figure 4 Taking migration t1 as an example, the input for migration t1 is {click "Login", input content into inputAccount, input content into inputPwd, check agreementBox}. The output of migration t1 is empty. The transition conditions are {inputAccount exists, inputPwd is correct, and agreementBox = 1}. The transition action is {currentAccount = inputAccount}. When calculating the migration probability, the required data is obtained from the user's historical operation record database: There are 100 records in the user's historical operation record database where the user is in the "Account and Password Login Page" state, i.e., in state S0. Among them, 30 records show that the user entered the "Error Prompt Box" state after performing some operation, i.e., state S2. Among them, 50 records show that the user entered the "Main Page" state after performing some operation, i.e., state S1. Among them, 20 records show that the user entered the "Registration Page" state after performing some operation, i.e., state S3. After calculation, the migration probability of t1 should be 50 ÷ 100 = 0.5.
[0045] The module for removing infeasible paths takes the PEFSM model as input, uses rules and path feasibility measurement methods to identify and remove infeasible paths, and outputs a set of reliable test paths composed of migration paths.
[0046] The implementation idea of this module is to use penalty values to quantify the impact of definition-predicate-use pairs on the feasibility of a path. When a definition-predicate-use pair is found in a migration path, its feasibility is determined by rules. If the path is determined to be infeasible by the rules, it is not added to the reliable test path set. If it does not fall under the situation described in the rules, a path feasibility state model combining the corresponding test coverage criteria and probability is used to calculate the path penalty value. The path feasibility is measured based on the magnitude of the penalty value, thereby removing some infeasible paths and finally outputting a reliable test path set. Based on this, as... Figure 6 As shown, the specific steps for removing infeasible paths are as follows:
[0047] ① Generate a set of candidate paths;
[0048] Specifically, firstly, obtain the system's initial state S0 to each final state S... f The process involves identifying simple state paths, then identifying existing simple state loops, inserting the simple state loops into the simple state paths, and inserting the loops into the paths a finite number of times to obtain comprehensive and non-redundant state paths. Then, each obtained state path is fully combined to obtain multiple migration paths, and all migration paths are combined into a candidate path set.
[0049] ② Process migration paths within the candidate path set;
[0050] Specifically, determine whether the migration paths in the candidate path set have been processed. If there are unprocessed migration paths, proceed to step ③. Otherwise, if the feasibility judgment or calculation of all paths in the candidate path set has been completed, proceed to step ⑦.
[0051] ③ Select an unprocessed migration path from the candidate path set;
[0052] ④ Identify definition-predicate-use pairs;
[0053] Specifically, a variable operation record table is maintained for each migration path, specifically: when the migration t i When there is an assignment operation 'a' on variable x, the variable-assignment pair (x, a) is written to the variable operation record table. When migration t... iWhen there is a judgment operation p on variable x or an expression containing variable x, query the variable operation record table. If the variable-assignment pair (x, a) of variable x is found, then there is a definition-predicate-use pair in the migration path, and step ⑤ is executed; otherwise, step ⑥ is executed.
[0054] ⑤ Use rules to determine whether the path is feasible. If the path is determined to be infeasible by the rules, the current migration path will not be added to the reliable test path set, and step ② will be executed. Otherwise, step ⑥ will be executed.
[0055] Here is a specific example illustrating one of the scenarios where a path is deemed infeasible based on rules:
[0056] The definition-predicate-use pair assignment transfer assigns a constant C1 to variable v. The definition-predicate-use pair decision transfer determines the numerical relationship between variable v and another constant C2. Obviously, this case can be directly simplified to determining the numerical relationship between the two constants C1 and C2. If the numerical values of constants C1 and C2 do not meet the decision condition, then the path is directly determined to be infeasible.
[0057] Specifically, in a definition-predicate-use assignment transition, the operation on variable v is v = 5, while in a decision transition, the decision condition for variable v is v = 4. Since 5 and 4 are not equal, it can be directly determined that this path is not feasible.
[0058] ⑥ Use a path feasibility state model combined with probability to measure the feasibility of the path. After calculating the feasibility value of a migration path, return to step ②.
[0059] Specifically, the penalty value of a definition-predicate-use pair is retrieved from the definition-predicate-use pair penalty value table, and the penalty value of a more complex path is calculated using a path feasibility model combined with probability.
[0060] The penalty values in the penalty value table are determined based on experience. The smaller the penalty value for a given path, the greater its feasibility. The penalty values in the table are non-negative. After generating test cases using a set of empirical values, the penalty values in the table can be adjusted by observing the quality of the generated test cases.
[0061] The feasibility model follows the full migration coverage criterion, and the feasibility model is shown in the following formula (1);
[0062]
[0063] Among them, df i It is the definition-predicate-use pair in the migration path, v(df i ) is the definition-predicate-use penalty value in the migration path, b mIt is the definition-predicate-transition probability of the transfer using the midpoint assignment, b n is the migration probability of determining the migration in the definition-predicate-use pair, |TP| is the path length, α is the factor that adjusts the influence of the path length, and k is the number of definition-predicate-use pairs in the path.
[0064] when This indicates the presence of definition-predicate-use pairs within the path. The higher the migration probability value of each definition-predicate-use pair, the more frequently it is used, and the higher the priority should be given to generating test cases for that path. Therefore, (1-b) m ) and (1-b n The value of b is multiplied by the penalty value, thus reducing the penalty value. Considering that a definition-predicate-use pair involves assignment transfer and decision transfer, the impact of both assignment transfer and decision transfer on the penalty value should be considered when calculating its penalty value. m With b n These should be included in the calculation simultaneously. Generally, a longer path may result in more definition-predicate-use pairs, potentially leading to a larger overall penalty value. However, it should not be assumed that a longer path is less feasible; therefore, the calculation should be divided by the path length at the end to eliminate the impact of path length on path feasibility. This indicates that the path does not contain a definition-predicate-use pair. When generating test cases, prioritize generating paths with longer lengths. In this case, using a negative path length as a path penalty value ensures that longer paths are given priority.
[0065] ⑦ Obtain a feasible path;
[0066] Specifically, the penalty values of the paths are sorted in ascending order, and the top N paths in the sorted list are selected as feasible migration paths and added to the set of reliable test paths. Here, N is a positive integer, representing the threshold for the number of feasible paths to select, and its value can be adjusted as needed.
[0067] Finally, a reliable set of test paths is obtained.
[0068] The test case probability generation module takes the reliable test path set as input, first performs probability selection on the test cases to obtain the top N test paths with higher probability of occurrence, then instantiates them, and outputs the test cases of the system under test, where N is a positive integer.
[0069] The specific steps for generating test cases are as follows: Figure 7 As shown:
[0070] (1) Probability selection: Calculate the probability of each migration path in the reliable test path set, that is, measure the probability that a specific migration path is used by users in the actual scenario, and then sort the test paths according to the probability of the path.
[0071] In this embodiment, calculating the probability of each migration path in the reliable test path set includes the following steps:
[0072] ① Initialize all context variables in the system under test;
[0073] ② Determine whether the migration paths in the reliable test path set have been processed: If there are unprocessed paths in the test path set, then select a specific migration path and execute step ③; otherwise, execute step ④.
[0074] ③ Calculate the probability of a migration path according to formula (2): Initialize the path probability W to 1, process each migration sequentially according to the migration sequence of the migration path, and first judge the predicate expression for each migration. If it is true, execute the assignment statement in the migration action and multiply the migration probability of this migration into the probability W. Otherwise, the probability W is 0. After calculating the probability of a migration path, execute step ②.
[0075] In this embodiment, the state at the next moment in the PEFSM model is only related to the state at the previous moment. Therefore, the state path in the PEFSM model is regarded as a Markov chain. The path probability is calculated using the properties of the Markov chain, that is, the product of the migration probabilities in the migration path is used as the probability of this migration path. The calculation is shown in formula (2).
[0076] W(X m+1 =s mj ,X m =s mi ,X m-1 =s (m-1)i ,...,X1=s 1i )
[0077] =W(X) m+1 =s mj |X m =s mi )W(X m =s mi |X m-1 =s (m-1)i ...W(X2=s) 2i |X1
[0078] =s 1i )
[0079] =b m b m-1...b1 (2)
[0080] ④ Sort the test paths in descending order based on their probabilities.
[0081] (2) Test case generation: Based on the probability of the sorted paths, the migration paths with higher probabilities are selected first to generate test cases, and each migration path is instantiated in turn.
[0082] In this embodiment, instantiating each migration path includes the following steps:
[0083] ① Determine if there are N test cases in the test case set. If there are no N test cases, proceed to step ②. Otherwise, output the final test case set and terminate execution. Here, N is the threshold for selecting a migration path for instantiation, which is a positive integer and its value can be set as needed.
[0084] ② Select the sorted migration paths in sequence, assign values to the context variables of the PEFSM model, perform calculations along the migration paths, and obtain the input sequence and output sequence corresponding to the migration path. The initialization of variables, input sequence and output sequence of a migration path are combined to form a test case.
[0085] ③ Add the migration path instance to the test case set and return to step ①.
[0086] Finally, a final test case set is obtained.
[0087] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.
Claims
1. A test case automatic generation system based on probabilistic extended finite state machine, characterized in that, include: The PEFSM model building module, the infeasible path removal module, and the test case probability generation module are included. The PEFSM model building module obtains relevant data for model building from the user's historical operation record database based on the requirements specification and interface design of the system under test, performs behavioral description of the system under test, and outputs the corresponding PEFSM model of the system. The module for removing infeasible paths takes the PEFSM model as input, uses rules and path feasibility measurement methods to identify and remove infeasible paths, and outputs a set of reliable test paths composed of migration paths. The test case probability generation module takes the reliable test path set as input, first performs probability selection on the test cases to obtain the top N test paths with higher probability of occurrence, then instantiates them and outputs the test cases of the system under test. The specific steps for removing infeasible paths are as follows: ① Generate a set of candidate paths; ② Process the migration paths in the candidate path set: Determine whether the migration paths in the candidate path set have been processed. If there are unprocessed migration paths, proceed to step ③. Otherwise, if the feasibility judgment or calculation of all paths in the candidate path set has been completed, proceed to step ⑦. ③ Select one unprocessed migration path from the candidate path set; ④ Identify definition-predicate-use pairs, and maintain a variable operation record table for each migration path. When migration t q When there is an assignment operation 'a' on variable x, the variable-assignment pair (x, a) is written to the variable operation record table. When migration t... q When there is a judgment operation p on variable x or an expression containing variable x, query the variable operation record table. If the variable-assignment pair (x, a) of variable x is found, then there is a definition-predicate-use pair in the migration path, and step ⑤ is executed; otherwise, step ⑥ is executed. ⑤ Use rules to determine whether the path is feasible. If the path is determined to be infeasible by the rules, the current migration path will not be added to the reliable test path set, and step ② will be executed. Otherwise, step ⑥ will be executed. ⑥ Use a path feasibility state model combined with probability to measure the feasibility of the path. After calculating the feasibility value of a migration path, return to step ②. ⑦ Obtain feasible paths; sort the penalty values of the paths in ascending order, select the top N paths in the sort, determine them as feasible migration paths, and add them to the set of reliable test paths; where N is the threshold for the number of feasible paths to select, and is a positive integer; The path feasibility state model combined with probability specifically adopts the following formula; Among them, df i It is the definition-predicate-use pair in the migration path, v(df i ) is the definition of the predicate in the migration path - using the penalty value, b m It is the definition-predicate-transition probability of the transfer using the midpoint assignment, b n It is a definition-predicate-use method to determine the migration probability of a pair, where |TP| is the path length. It is a factor that adjusts the influence of path length, and k is the number of definition-predicate-use pairs in the path.
2. The system as described in claim 1, characterized in that, The specific steps for constructing the PEFSM model are as follows: ① Based on the requirements specification and interface design of the system under test, abstract the state set S, input set I, and output set O of the system under test; ②Analyze and extract the variables involved in the transitions between the states of the system under test, and add them to the variable set V mentioned above; ③ Based on the migration conditions and migration actions for each migration, extract the predicate expression set P and the migration action set A; ④ Calculate and analyze the execution frequency of each user operation in the user's historical operation record database to obtain the migration probability of each migration, and form a migration set T with probability.
3. The system as described in claim 1, characterized in that, The generation of the candidate path set is specifically carried out in the following manner: First, obtain the path set from the initial state S0 of the system to each termination state S0. f The process involves identifying simple state paths, then identifying existing simple state loops, inserting these loops into the simple state paths, and inserting them into the paths a finite number of times to obtain comprehensive and non-redundant state paths. Finally, each obtained state path is fully combined to obtain multiple migration paths, and all migration paths are combined into a candidate path set.
4. The system as described in claim 1 or 2, characterized in that: The specific steps for generating test case probabilities are as follows: (1) Calculate the probability of each migration path in the reliable test path set, that is, measure the probability that a specific migration path is used by the user in the actual scenario, and then sort the test paths according to the probability of the path. (2) Based on the probability of the sorted paths, select the migration path with the higher probability to generate test cases, and instantiate each migration path in turn.
5. The system as described in claim 4, characterized in that: Calculating the probability of each migration path in the reliable test path set includes the following steps: ① Initialize all context variables in the system under test; ② Determine whether the migration paths in the reliable test path set have been processed: If there are unprocessed paths in the test path set, then select a specific migration path and execute step ③; otherwise, execute step ④. ③ Calculate the probability of a migration path: Initialize the path probability W to 1, process each migration sequentially according to the migration sequence of the migration path, and first judge the predicate expression for each migration. If it is true, execute the assignment statement in the migration action and multiply the migration probability of this migration into the probability W. Otherwise, the probability W is 0. After calculating the probability of a migration path, proceed to step ②; ④ Sort the test paths in descending order based on their probabilities.
6. The system as described in claim 4, characterized in that: Instantiating each migration path includes the following steps: ① Determine if there are N test cases in the test case set. If there are no N test cases, proceed to step ②. Otherwise, output the final test case set and terminate execution. Here, N is the threshold for selecting a migration path for instantiation, which is a positive integer and its value can be set as needed. ② Select the sorted migration paths in sequence, assign values to the context variables of the PEFSM model, perform calculations along the migration paths, and obtain the input sequence and output sequence corresponding to the migration path. The initialization of variables, input sequence and output sequence of a migration path are combined to form a test case. ③ Add the migration path instance to the test case set and return to step ①.
Citation Information
Patent Citations
Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine)
CN102368226A