MC / DC coverage criterion-based minimum test case set generation method and system
By drawing SCADE model diagrams and determining the path analysis sequence, and generating a test case set, the problem of not being able to effectively cover the MC/DC criteria in the existing technology is solved, and efficient test case generation and coverage improvement is achieved.
Patent Information
- Application Number
- PCT/CN2023/132520
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-11-15
- Filing Date
- 2023-11-20
- Publication Date
- 2025-05-22
AI Technical Summary
The prior art cannot directly use a set of algorithms to generate a minimum set of test cases, and it is difficult to ensure that test cases can cover MC/DC coverage criteria 100%, especially when facing logical expressions with different coupling conditions.
By drawing the SCADE model diagram of the logical operator, the unactivated paths are activated, the path analysis order is determined, the path conditions are assigned in sequence, the test cases are generated, and the repeated cases are deleted, and the test case set is finally generated.
It realizes that a minimum test case set can be designed under multiple coupling conditions with just one set of algorithms, which can cover MC/DC criteria coverage requirements under zero coupling, weak coupling and strong coupling conditions by 100%, improving the efficiency and coverage of software testing.
Smart Images

Figure CN2023132520_22052025_PF_FP_ABST
Abstract
Description
A method and system for generating a minimum test case set based on MC / DC coverage criteria Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a method and system for generating a minimum test case set based on MC / DC coverage criteria. Background Art
[0002] Regarding the generation of test case sets, facing logical expressions of different coupling conditions, it is currently impossible to directly use a set of algorithms to complete the design of the minimum test case set while ensuring that the test cases can achieve 100% coverage of the MC / DC criteria.
[0003] Summary of the Invention
[0004] In order to solve the above problems, the inventors have made the present invention, and through specific implementation methods, provide a method and system for generating a minimum test case set based on the MC / DC coverage criterion.
[0005] In a first aspect, an embodiment of the present invention provides a method for generating a minimum test case set based on the MC / DC coverage criterion, comprising the following steps:
[0006] Draw the SCADE model diagram of the logical operator based on the conditional logic expression;
[0007] Based on the SCADE model diagram, draw at least one complete path from input to output;
[0008] Activate any inactivated path, determine the path analysis order, and first assign values to the conditions of the inactivated path according to the path analysis order. Then assign True and False to the conditions of the activated path respectively, to obtain two test cases.
[0009] The path analysis order is: analyze the currently activated path, then analyze the adjacent paths of the currently activated path, and then analyze other inactivated paths in descending order according to the path order on the SCADE model diagram. When the currently analyzed path includes a coupling condition, the other inactivated paths and their adjacent paths that include the same coupling condition are analyzed first before analyzing other paths.
[0010] Activate each inactivated path and obtain the corresponding test case;
[0011] Delete duplicate test cases to obtain a test case set.
[0012] In some specific embodiments, the conditional assignment of the inactivated path includes the following steps: starting from the input of each inactivated path, the condition in the And judgment in the inactivated path is assigned to True, and the condition in the Or judgment in the inactivated path is assigned to False; when a decision condition exists in the inactivated path, the judgment is continued after the current judgment of the decision condition in the path, and when a judgment of a non-decision condition is encountered, the assignment of the decision condition is determined according to the logical prefix of the judgment; in the same activation of the path, the repeated conditions retain the current value and are not re-assigned.
[0013] In some specific embodiments, the judgment condition is a coupling condition, including the following steps: when the same condition appears repeatedly in the logical expression, the condition is judged as a coupling condition; when there is a condition in the logical expression that restricts the output value of other conditions, the condition is judged as a coupling condition.
[0014] In some specific embodiments, the judgment condition is a decision condition, including the following steps: in the same round of activation of the path, the condition that is not in the judgment of the activated path and is the first condition assigned in the current judgment is determined as the decision condition; in the same round of activation of the path, the condition that is not in the same judgment as the condition in the activated path and is the basis for the judgment of the current judgment or the first condition assigned in the current judgment is determined as the decision condition.
[0015] In some specific embodiments, the value of the coupling condition is based on the previous setting value of the coupling condition in the current test case.
[0016] In a second aspect, an embodiment of the present invention provides a system for generating a minimum test case set based on the MC / DC coverage criterion, comprising:
[0017] A path generation module is used to draw a SCADE model diagram of a logic operator based on a conditional logic expression; and to draw at least one complete path from input to output based on the SCADE model diagram;
[0018] The test case generation module is used to activate any inactivated path, determine the path analysis order, and first assign values to the conditions of the inactivated path according to the path analysis order, and then assign True and False to the conditions of the activated path respectively, to obtain two test cases; the path analysis order is: analyze the currently activated path, then analyze the adjacent paths of the currently activated path, and then analyze other inactivated paths in descending order according to the path order on the SCADE model diagram, wherein, when the currently analyzed path includes a coupling condition, before analyzing other paths, other inactivated paths and their adjacent paths including the same coupling condition are preferentially analyzed; each inactivated path is activated to obtain a corresponding test case; duplicate test cases are deleted to obtain a test case set.
[0019] In some specific embodiments, the condition in the And judgment in the inactivated path defaults to True, and the condition in the Or judgment in the inactivated path defaults to False; when there is a decision condition in the inactivated path, in the path after the decision condition, when a non-decision condition judgment is encountered, the assignment of the decision condition is determined according to the logical prefix of the judgment; in the same activation of the path, the repeated conditions retain the current value and are not re-assigned.
[0020] In some specific embodiments, the same condition that appears repeatedly in a logical expression is a coupling condition; a condition that restricts the output value of other conditions in a logical expression is a coupling condition.
[0021] In some specific embodiments, the decision condition is a condition that is not in the judgment of the activated path in the same round of activation of the path and is the first condition assigned in the current judgment; the decision condition also includes a condition that is not in the same judgment as the condition in the activated path in the same round of activation of the path and is the basis for judgment of the current judgment.
[0022] In some specific embodiments, the value of the coupling condition is the previous setting value of the coupling condition in the current test case.
[0023] Based on the same inventive concept, an embodiment of the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, the method for generating a minimum test case set based on the MC / DC coverage criterion is implemented.
[0024] Based on the same inventive concept, an embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, which, when executed, implement the aforementioned method for generating a minimum test case set based on the MC / DC coverage criterion.
[0025] The beneficial effects of the above technical solutions provided by the embodiments of the present invention include at least:
[0026] Using a single algorithm, a minimal set of test cases can be designed for various coupling conditions, achieving 100% coverage of the MC / DC criterion for logical expressions under zero, weak, and strong coupling conditions. This approach can assist software test engineers in designing test case generation and improving test coverage. Compared to other test case generation processes, this approach is clearer and easier to understand, requires fewer test cases, offers higher coverage, and is highly operational, improving software testing efficiency.
[0027] Other features and advantages of the present invention will be described in the following description or understood through implementation of the present invention. The purpose and other advantages of the present invention can be realized and obtained through the structures particularly pointed out in the written description, claims, and drawings.
[0028] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0030] FIG1 is a flow chart of a method for generating a minimum test case set based on the MC / DC coverage criterion in an embodiment of the present invention;
[0031] FIG2 is a SCADE model diagram of (A&&B)&&(C&&D)||E) in an embodiment of the present invention;
[0032] FIG3 is a SCADE model diagram of (A&&B)||(!((A||B) in an embodiment of the present invention;
[0033] FIG4 is a SCADE model diagram of (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D) in an embodiment of the present invention;
[0034] FIG5 is a path identification diagram of (A&&B)&&(C&&D)||E) in an embodiment of the present invention;
[0035] FIG6 is a path identification diagram of (A&&B)||(!((A||B) in an embodiment of the present invention;
[0036] FIG7 is a path identification diagram of (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D) in an embodiment of the present invention;
[0037] FIG8 is a schematic diagram of the activation process of Path1 in the SCADE model of FIG7 according to an embodiment of the present invention;
[0038] FIG9 is a schematic diagram of the Path10 activation process in the SCADE model of FIG7 according to an embodiment of the present invention;
[0039] FIG10 is a path coverage diagram of (A&&B)&&(C&&D)||E) in an embodiment of the present invention;
[0040] FIG11 is a path coverage diagram of (A&&B)||(!((A||B)) in an embodiment of the present invention;
[0041] FIG12 is a path coverage diagram of (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D) in an embodiment of the present invention;
[0042] FIG13 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0044] In order to solve the problems existing in the prior art, an embodiment of the present invention provides a method and system for generating a minimum test case set based on the MC / DC coverage criterion. By applying model coverage testing under the security development software SCADE, a path generation algorithm is proposed to obtain a minimum test case set for Class A software that meets the MC / DC criterion with more comprehensive test case requirements. The test cases generated by this algorithm can 100% cover the MC / DC criterion coverage requirements of logical expressions under zero coupling conditions, weak coupling conditions, and strong coupling conditions. Modified Condition / Decision Coverage (MC / DC) is a software structure coverage test criterion suitable for model white box testing of Class A software in fields such as aerospace, rail transportation, etc. During the testing process, testers are required to complete the test case writing according to the model requirements, and the test quality often depends on the tester's knowledge and experience. Complex logical combination conditions and the lack of accurate understanding of the MC / DC criterion often consume a lot of testers' time.
[0045] An embodiment of the present invention provides a method for generating a minimum test case set based on the MC / DC coverage criterion. The method comprises the following steps, as shown in FIG1 :
[0046] Step S1: Draw a SCADE model diagram of the logic operator according to the conditional logic expression.
[0047] The conditional logic expression here corresponds to the actual physical condition setting, such as the status of track relays and signal lights. One of the states is set as condition A and the other state is set as condition B. A section includes multiple states. According to the status of the section, write the corresponding logic expression including multiple conditions. According to the result of the logic expression, execute operations such as train route processing.
[0048] SCADE (Safety Critical Application Development Environment), a safety-critical application development environment, is a tool certified by multiple safety-critical industry software engineering standards. It is currently widely used in sectors with stringent software safety requirements, such as aerospace, rail transit, and nuclear power. It uses a modeling language, allowing software designers to focus on graphically expressing requirements. When using SCADE QTE for model coverage analysis on the host, test cases can be written and code-level coverage testing can be performed using the MTC (Model Test Coverage) tool. The coverage of the designed test cases on the model can be directly observed within the tool.
[0049] Condition: refers to the part of a logical expression that does not contain Boolean operators such as AND, OR, and NOT, or is called a logical variable.
[0050] Decision: refers to a logical relationship containing two or more conditions.
[0051] Prefix logical operator: A logical operator ("&&", "||") that appears before the condition or judgment in a logical expression.
[0052] Modified Condition / Decision Coverage (MC / DC): Each entry point and exit point in the program is called at least once; all values of each condition in the decision appear at least once; all possible results of each decision appear at least once; each condition can independently affect the result of the decision, that is, changing the value of the condition while keeping all other conditions unchanged will change the decision result.
[0053] Coupling conditions: In a logical expression, the same condition appears repeatedly, or the output value of one condition restricts the output value of other conditions.
[0054] Path: refers to the path from input to output. When the same variable is in different paths, it is still considered as different paths.
[0055] Path activation: The shielding effect requirement in MC / DC is that only test cases with an independent impact of one input on the output result can be counted in the coverage. The principle is that there is only one path from each input to each output. At this time, this path is not shielded by other paths and its effect is counted as activation. When the path is activated, the input is True / False respectively.
[0056] Active path: The path from input to output that is currently ready to be activated.
[0057] Shielded path: A path from input to output that is not activated and is in a shielded state.
[0058] Adjacent paths: Paths under the same judgment are considered adjacent paths.
[0059] For example, according to the logical expression (A&&B)&&(C&&D)||E), the SCADE model diagram shown in Figure 2 is drawn. Figure 2 includes three AND operators and one OR operator. According to the logical expression (A&&B)||(!((A||B), the SCADE model diagram shown in Figure 3 is drawn. Figure 3 includes one AND operator, two OR operators, and one NOT operator. According to the logical expression (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D), the SCADE model diagram shown in Figure 4 is drawn. Figure 4 includes five AND operators and one OR operator.
[0060] Step S2: Based on the SCADE model diagram, draw at least one complete path from input to output.
[0061] According to the logical expression (A&&B)&&(C&&D)|| B ), a path identification diagram as shown in FIG5 is drawn, which includes Paths 1 to 5. According to the logical expression (A&&B)||(!((A||B), a path identification diagram as shown in FIG6 is drawn, which includes Paths 1 to 4. According to the logical expression (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D), a path identification diagram as shown in FIG7 is drawn, which includes Paths 1 to 10.
[0062] Step S3: Activate any inactivated path and determine the path analysis order. According to the path analysis order, first assign values to the inactivated path's conditions, then assign True and False to the activated path's conditions, respectively, to obtain two test cases. The path analysis order is as follows: analyze the currently activated path, then analyze its inactivated adjacent paths, and then analyze the remaining inactivated paths in descending order according to the path order on the SCADE model diagram. If the currently analyzed path includes a coupling condition, prioritizing analysis of other inactivated paths and their adjacent paths that include the same coupling condition before analyzing other paths. Paths in the same judgment are considered adjacent paths.
[0063] In some specific embodiments, taking the path activation of Path1 in Figure 7 as an example, the specific process is shown in Figure 8: Path1 is activated, and Path2 is the inactivated adjacent path of Path1. Path1 includes coupling condition A (circled in the figure, A1 indicates the first occurrence of condition A from top to bottom in the SCADE model diagram, and A2 indicates the second occurrence. The meanings of other letter numbers are similar). Therefore, before analyzing other paths, other inactivated paths and their adjacent paths that include the same coupling condition are prioritized. Other inactivated paths that include the same coupling condition A include Path3 and Path5, respectively. Therefore, after analyzing Path2, Path3 and its adjacent paths Path4, Path5 and its adjacent path Path6 are analyzed first. After analyzing coupling condition A, it is found that coupling condition B also appears (circled in the figure, B1 indicates the first occurrence of condition B from top to bottom in the SCADE model diagram). Path7 and its adjacent path Path8 that include coupling condition B are analyzed in sequence. The remaining paths do not include the inactivated coupling condition B. The inactive paths contain coupling condition C (circled in the figure, where C1 represents the first occurrence of condition C from top to bottom in the SCADE model diagram). Therefore, we analyze Path 9 and its adjacent path, Path 10. The analysis order is: Path 1, Path 2, Path 3, Path 4, Path 5, Path 6, Path 7, Path 8, Path 9, Path 10.
[0064] The rule for analyzing corresponding paths sequentially downward is illustrated using the path activation of Path 10 in Figure 7 as an example. The specific process is shown in Figure 9: Path 10 is activated, and its adjacent path Path 9 is analyzed first. Path 10 contains coupling condition D (D2 indicates the second occurrence of condition D in the SCADE model). Therefore, the inactivated path Path 6 and its adjacent path Path 5, which contain coupling condition D, are analyzed. Path 9 contains coupling condition C (C3 indicates the third occurrence of condition C in the SCADE model). Therefore, the inactivated path Path 8 and its adjacent path Path 7, as well as Path 4 and its adjacent path Path 3, which contain coupling condition C, are analyzed. Following the order of coupling condition appearance, coupling condition A remains unanalyzed (condition A3 under Path 5, indicating the third occurrence of condition A in the SCADE model). Inactivated path Path 1 contains coupling condition A, so Path 1 and its adjacent path Path 2 are analyzed. The analysis order is: Path 10, Path 9, Path 6, Path 5, Path 8, Path 7, Path 4, Path 3, Path 1, Path 2.
[0065] The method for determining the path analysis order in FIG5 and FIG6 is the same as that in FIG7 . The test in FIG7 is more complicated than that in FIG5 and FIG6 , so FIG7 is used as an example for explanation.
[0066] In some specific embodiments, the conditional assignment of the inactivated path includes the following steps: starting from the input of each inactivated path, the condition in the And judgment in the inactivated path is assigned to True, and the condition in the Or judgment in the inactivated path is assigned to False; when a decision condition exists in the inactivated path, the judgment is continued after the current judgment of the decision condition in the path, and when a judgment of a non-decision condition is encountered, the assignment of the decision condition is determined according to the logical prefix of the judgment; in the same activation of the path, the repeated conditions retain the current value and are not re-assigned.
[0067] In some specific embodiments, the judgment condition is a decision condition, including the following steps: in the same round of activation of the path, the condition that is not in the judgment of the activated path and is the first to be assigned in the current judgment is determined as the decision condition; in the same round of activation of the path, the condition that is not in the same judgment as the condition in the activated path and is the basis for the judgment of the current judgment is determined as the decision condition. The process from activating a path to obtaining two corresponding test cases is called a round of activation. Activating several paths includes several rounds of activation, and each round of activation includes activating paths, determining the order of path analysis, and first assigning values to the conditions of the non-activated paths according to the path analysis order, and then assigning True and False to the conditions of the activated path respectively, to obtain two test cases.
[0068] During the evaluation phase, using the activation of Path 1 in Figure 7 as an example, the conditions of the inactive paths are evaluated first, followed by the conditions of the active paths being evaluated as True and False, respectively. Following the path analysis order of Path 1, Path 2, Path 3, Path 4, Path 5, Path 6, Path 7, Path 8, Path 9, and Path 10, the order of analysis for the inactive paths is Path 2, Path 3, Path 4, Path 5, Path 6, Path 7, Path 8, Path 9, and Path 10. In Path 2, condition B is in the And decision, so B is evaluated as True. A in Path 3 already appears in the active path Path 1. During this activation of Path 1, A is evaluated after the conditions of the inactive paths are evaluated. In Path4, condition C is not in the judgment of the activated path and is the first condition assigned in the current judgment, so C is the decision condition. Specifically, C is the decision condition for judgment And2 in Figure 7 (And represents the logical symbol and, 2 represents the number of the same logical symbol, and And here is the second from top to bottom in Figure 7, so it is numbered And2). When a decision condition exists in an inactivated path, the judgment continues after the current judgment of the decision condition in the path. Therefore, after encountering decision condition C in Path4, the judgment after Path4 continues in the direction from input to output. The judgment after And2 in Path4 is Or1 (Or represents the logical symbol or, 1 represents the number of the same logical symbol, and there is only one Or in Figure 7, so it is numbered Or1). C cannot independently affect the judgment result of Or1, is not the judgment basis of Or1, and is not the first condition assigned in Or1, so C is not the decision condition of Or1. When encountering a non-deterministic condition, the evaluation of the condition is determined based on the logical prefix of the condition. In this case, the logical prefix is Or, so the evaluation of C is determined based on Or. At the same time, the conditions in the Or evaluations in the inactive paths are assigned the default value of False, so C is assigned the value of False. A in Path5 already appears in the active path Path1. During this activation of Path1, A is assigned the value after the conditions in the inactive paths are evaluated. Condition D in Path6 is the determining condition of And3 in Figure 7. Continuing along Path6, D is not the determining condition of Or1, so the evaluation of D is determined based on Or1. The conditions in the Or evaluations in the inactive paths are assigned the default value of False, so D is assigned the value of False. In Path7, B is a repeated condition and is not evaluated again during the evaluation of the conditions in the inactive paths. C in Path8 has already appeared in this activation round and retains its current value, without being re-evaluated. C in Path9 has already appeared in this activation round and retains its current value, without being re-evaluated.D in Path10 has already appeared in this round of activation and retains its current value without being re-assigned. Therefore, in this round of Path1 activation, the values of conditions B, C, and D in the unactivated path are T, F, and F, respectively, as shown in row 1 of Table 3.
[0069] After assigning values to the conditions of the inactivated path, the conditions of the activated path are assigned True and False, respectively, resulting in two test cases. Specifically, following the above example, in this round of Path1 activation, A is the condition for activating Path1, and is assigned True and False, respectively. Combined with the previously assigned values to the conditions B, C, and D of the inactivated path, two test cases are obtained. These two test cases correspond to numbers 1 and 2 in Table 3, respectively. In test case number 1, the values of A to D are T, T, F, and F, respectively, and the output is T. In test case number 2, the values of A to D are F, T, F, and F, respectively, and the output is F.
[0070] During the evaluation phase, taking the activation of Path 10 in Figure 7 as an example, the conditions of the inactive paths are evaluated first, followed by the conditions of the active paths being evaluated as True and False, respectively. Following the path analysis order of Path 10, Path 9, Path 6, Path 5, Path 8, Path 7, Path 4, Path 3, Path 1, Path 2, the analysis order for the inactive paths is Path 9, Path 6, Path 5, Path 8, Path 7, Path 4, Path 3, Path 1, Path 2. In Path 9, starting from the input, condition C is in the And decision, so C is evaluated as True. D in Path 6 already appears in the active path Path 10. During this activation of Path 10, D is evaluated after the conditions of the inactive paths are evaluated. In Path5, condition A is not in the judgment of the activated path and is the first condition to be assigned a value in the current judgment, so A is the decision condition. Specifically, A is the decision condition for judgment And3 in Figure 7 (And represents the logical symbol and, 3 represents the number of the same logical symbol, and And here is the third from top to bottom in Figure 7, so it is numbered And3). When a decision condition exists in an inactivated path, the judgment continues after the current judgment of the decision condition in the path. Therefore, after encountering decision condition A in Path5, the judgment after Path5 continues to be judged in the direction from input to output. The judgment after And3 in Path5 is Or1 (Or represents the logical symbol or, 1 represents the number of the same logical symbol, and there is only one Or here in Figure 7, so it is numbered Or1). A cannot independently affect the judgment result of Or1 and is not the judgment basis of Or1, so A is not the decision condition of Or1. When encountering a non-determining condition, the evaluation of the determining condition is determined based on the logical prefix of the determination. In this case, the logical prefix is Or, so the evaluation of A is determined based on Or. At the same time, the conditions in the Or determinations in the inactivated paths are assigned a default value of False, so A is assigned a value of False. C in Path8 already appears in the activated path Path9 and is not re-evaluated. Since condition C in the adjacent path Path8 of the same determination in Path7 has already been evaluated as True, condition B in Path7 becomes the determining condition for And4 in Figure 7. Since the evaluation of condition B directly determines the outcome of the current determination, the evaluation continues along Path7. Since B is not the determining condition for Or1, the evaluation of B is determined based on Or1. The conditions in the Or determinations in the inactivated paths are assigned a default value of False, so B is assigned a value of False. C in Path4 has already appeared in this activation round and retains its current value without being re-evaluated. A in Path3 has already appeared in this activation round and retains its current value without being re-evaluated. At this point, Path1 and Path2 remain unanalyzed.The analyzed paths in this round are checked for any unanalyzed coupling conditions. Currently, coupling condition A remains unanalyzed. Therefore, Path1, the inactive path containing coupling condition A, is analyzed first, followed by its adjacent path, Path2. A in Path1 has already appeared in this round of activation and retains its current value without being reassigned. B in Path2 has already appeared in this round of activation and retains its current value without being reassigned. Therefore, in this round of Path1 activation, conditions B, C, and D in the inactive path are assigned values of F, F, and T, respectively, as shown in row 9 of Table 3.
[0071] After assigning values to the conditions of the inactivated path, the conditions of the activated path are assigned True and False, respectively, resulting in two test cases. Specifically, following the above example, in this round of Path1 activation, A is the condition for activating Path1, and is assigned True and False, respectively. Combined with the previously assigned values to the conditions B, C, and D of the inactivated path, two test cases are obtained. These two test cases correspond to numbers 9 and 5 in Table 3, respectively. In test case number 9, the values of A to D are F, F, T, and T, respectively, and the output is T. In test case number 5, the values of A to D are F, F, T, and F, respectively, and the output is F.
[0072] In some specific embodiments, the judgment condition is a coupling condition, including the following steps: when the same condition appears repeatedly in the logical expression, the condition is judged as a coupling condition; when there is a condition in the logical expression that restricts the output value of other conditions, the condition is judged as a coupling condition.
[0073] In some specific embodiments, the value of the coupling condition is based on the previous setting value of the coupling condition in the current test case.
[0074] Step S4: Activate each inactivated path to obtain corresponding test cases; delete duplicate test cases to obtain a test case set.
[0075] The minimum test case set corresponding to the zero-coupling logical expression (A&&B)&&(C&&D)||E) is shown in Table 1.
[0076] Table 1 Test case table of (A&&B)&&(C&&D)||E)
[0077] The path coverage of the zero-coupling logic expression (A&&B)&&(C&&D)||E) is shown in Figure 10, achieving complete path coverage and a path coverage rate of 100%.
[0078] The minimum test case set corresponding to the weakly coupled logical expression (A&&B)||(!((A||B)) is shown in Table 2.
[0079] Table 2 Test case table of (A&&B)||(!((A||B)
[0080] The path coverage of the weakly coupled logical expression (A&&B)||(!((A||B)) is shown in FIG11 , achieving complete path coverage with a path coverage rate of 100%.
[0081] The minimum test case set corresponding to the strongly coupled logical expression (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D) is shown in Table 3.
[0082] Table 3 Test case table of (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D)
[0083] The path coverage of the strongly coupled logical expression (A&&B)||(A&&C)||(A&&D)||(B&&C)||(C&&D) is shown in Figure 12, achieving complete path coverage with a path coverage rate of 100%.
[0084] In a specific embodiment, the method for generating a minimum test case set based on the MC / DC coverage criterion is summarized as follows:
[0085] Step 1: Draw a model of the logical operator based on the logical expression. The path from input to output is a complete path. Starting from condition 1, N paths can be drawn and named Path1 to PathN (N≥1).
[0086] Step 2: Define the analysis order. Starting with Path 1, activate each path in sequence. The currently activated path is called the active path, and the remaining paths are called the blocked paths. The analysis order is to analyze the activated path first, then the adjacent paths below it, and then the remaining paths in descending order. It is important to note that when analyzing each path, it is necessary to determine whether the conditions under that path are coupling conditions. If the conditions under the currently analyzed path are coupling conditions, the conditions under other paths containing the coupling conditions are not analyzed again, and the analysis order is adjusted to the path after the first occurrence of the coupling condition.
[0087] Step 3: Complete the conditional assignment for the shielded path. To achieve the shielding effect, the condition for that path defaults to True when encountering an And decision, and to False when encountering an Or decision. If the condition is not a decision condition, the condition is determined by the preceding logical symbol of the current decision. If it is a decision condition, the path is evaluated from the input to the output until a decision condition is found that is not a decision condition. At this point, the condition is determined by the preceding logical symbol of the decision. The value of the coupling condition is based on the previous setting of the current test case.
[0088] Decision conditions: 1. In the test cases for this round of path activation, the condition is not in the same decision as the conditions in the activated path, and is the first condition to be evaluated in the current decision (the conditions in the activated path and their coupled conditions are not counted in this case). 2. The condition is not in the same decision as the conditions in the activated path, and is the basis for the current decision.
[0089] Step 4: Complete the conditional assignment for the activation path. Assign True and False to the conditions under this activation path, and use the values of other variables in Step 3 to form two test cases.
[0090] Step 5: Activate each path and repeat steps 2-4 until the test case for the last activated path is completed.
[0091] Step 6: Organize the test cases, delete duplicate test cases, and obtain the final test case set.
[0092] The above-described method of this embodiment utilizes a single algorithm to design a minimum set of test cases under various coupling conditions, achieving 100% coverage of the MC / DC criterion coverage requirements for logical expressions under zero, weak, and strong coupling conditions. This method can assist software test engineers in designing and generating test cases, improving test coverage. Compared to other test case generation processes, this method is clearer and easier to understand, requires fewer test cases, offers higher coverage, and is highly operational, thereby improving software testing efficiency.
[0093] Those skilled in the art can change the above sequence without departing from the scope of protection of the present disclosure.
[0094] Another embodiment of the present invention provides a system for generating a minimum test case set based on the MC / DC coverage criterion, comprising:
[0095] A path generation module is used to draw a SCADE model diagram of a logic operator based on a conditional logic expression; and to draw at least one complete path from input to output based on the SCADE model diagram;
[0096] A test case generation module is used to activate any inactivated path, determine the path analysis order, and first assign values to the conditions of the inactivated path according to the path analysis order, and then assign True and False to the conditions of the activated path respectively, to obtain two test cases; the path analysis order is: analyze the currently activated path, then analyze the inactivated adjacent paths of the currently activated path, and then analyze other inactivated paths according to the path order on the SCADE model diagram, wherein, when the currently analyzed path includes a coupling condition, before analyzing other paths, other inactivated paths including the same coupling condition are analyzed first; activate each inactivated path to obtain a corresponding test case; delete duplicate test cases to obtain a test case set.
[0097] In some specific embodiments, the condition in the And judgment in the inactivated path defaults to True, and the condition in the Or judgment in the inactivated path defaults to False; when there is a decision condition in the inactivated path, in the path after the decision condition, when a non-decision condition judgment is encountered, the assignment of the decision condition is determined according to the logical prefix of the judgment; in the same activation of the path, the repeated conditions retain the current value and are not re-assigned.
[0098] In some specific embodiments, the same condition that appears repeatedly in a logical expression is a coupling condition; a condition that restricts the output value of other conditions in a logical expression is a coupling condition.
[0099] In some specific embodiments, the decision condition is a condition that is not in the judgment of the activated path in the same round of activation of the path and is the first condition assigned in the current judgment; the decision condition also includes a condition that is not in the same judgment as the condition in the activated path in the same round of activation of the path and is the basis for judgment of the current judgment.
[0100] In some specific embodiments, the value of the coupling condition is the previous setting value of the coupling condition in the current test case.
[0101] Regarding the system in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0102] In this embodiment, a single algorithm is used to design a minimum set of test cases under various coupling conditions, achieving 100% coverage of the MC / DC criterion coverage requirements for logical expressions under zero, weak, and strong coupling conditions. This approach can assist software test engineers in designing and generating test cases, improving test coverage. Compared to other test case generation processes, this approach is clearer and easier to understand, requires fewer test cases, offers higher coverage, and is highly operational, thereby improving software testing efficiency.
[0103] Based on the same inventive concept, an embodiment of the present invention also provides an electronic device, whose structure is shown in Figure 13, including: a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the aforementioned method for generating a minimum test case set based on the MC / DC coverage criterion.
[0104] Based on the same inventive concept, an embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and when the computer executable instructions are executed by a processor, the aforementioned method for generating a minimum test case set based on the MC / DC coverage criterion is implemented.
[0105] Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention shall still fall within the scope of the patent coverage of the present invention.
Claims
1. A method for generating a minimum test case set based on MC / DC coverage criteria. It is characterized in that The following steps are involved: Draw the SCADE model diagram of the logical operator based on the conditional logic expression; Based on the SCADE model diagram, draw at least one complete path from input to output; Activate any inactivated path, determine the path analysis order, and assign values to the conditions of the inactivated path first, then assign True and False to the conditions of the activated path, respectively, to obtain two test cases. The path analysis sequence is: analyze the currently activated path, then analyze the inactivated adjacent paths of the currently activated path, and then analyze other inactivated paths in order of the paths on the SCADE model diagram, wherein when the currently analyzed path includes a coupling condition, before analyzing other paths, give priority to analyzing other inactivated paths and their adjacent paths that include the same coupling condition; Activate each unactivated path and obtain the corresponding test case; Delete duplicate test cases and get a test case set.
2. The method according to claim 1, It is characterized in that The conditional assignment of the inactivated path includes the following steps: Starting from the input of each inactivated path, assign True to the condition in the And judgment of the inactivated path, and assign False to the condition in the Or judgment of the inactivated path; When a decision condition exists in an inactivated path, the decision is continued after the current decision of the decision condition in the path, and when a decision of a non-decision condition is encountered, the assignment of the decision condition is determined according to the logical prefix of the decision; During the same activation of a path, repeated conditions retain their current values and are not re-evaluated.
3. The method according to claim 1, It is characterized in that The judgment condition is a coupling condition, which includes the following steps: When the same condition appears repeatedly in the logical expression, the condition is judged as a coupling condition; When there is a condition in the logical expression that restricts the output value of other conditions, the condition is determined to be a coupling condition.
4. The method according to claim 2, It is characterized in that The judgment condition is a decision condition, which includes the following steps: In the same round of path activation, the condition that is not in the judgment of the activated path and is the first condition to be assigned a value in the current judgment is determined as the decision condition; In the same round of activation of the path, the condition that is not in the same judgment as the condition in the activated path and is the basis for the current judgment is determined as the decision condition.
5. The method according to claim 1, It is characterized in that The value of the coupling condition is based on the previous setting value of the coupling condition described in the current test case.
6. A minimum test case set generation system based on MC / DC coverage criteria, It is characterized in that include: The path generation module is used to draw the SCADE model diagram of the logic operator based on the conditional logic expression; Based on the SCADE model diagram, draw at least one complete path from input to output; A test case generation module is used to activate any inactivated path, determine the path analysis order, and first assign values to the conditions of the inactivated path according to the path analysis order, and then assign True and False to the conditions of the activated path respectively, so as to obtain two test cases; the path analysis order is: analyze the current activated path, then analyze the inactivated adjacent paths of the current activated path, and then analyze other inactivated paths in sequence downward according to the path order on the SCADE model diagram, wherein, when the currently analyzed path includes coupling conditions, before analyzing other paths, give priority to analyzing other inactivated paths and their adjacent paths including the same coupling conditions; Activate each unactivated path to obtain the corresponding test case; delete duplicate test cases to obtain a test case set.
7. The system according to claim 6, It is characterized in that The condition in the And judgment of the inactive path is True by default, and the condition in the Or judgment of the inactive path is False by default; When a decision condition exists in the inactivated path, in the path following the decision condition, when a non-decision condition is encountered, the assignment of the decision condition is determined according to the logical prefix of the determination; During the same activation of a path, repeated conditions retain their current values and are not re-evaluated.
8. The system according to claim 6, It is characterized in that The same condition that appears repeatedly in a logical expression is a coupling condition; The conditions in a logical expression that restrict the output values of other conditions are called coupling conditions.
9. The system according to claim 7, It is characterized in that The decision condition is in the same round of path activation, is not in the judgment of the activated path, and is the first condition to be assigned a value in the current judgment; The decision conditions also include conditions that are not in the same judgment as the conditions in the activated path in the same round of activation of the path and are the basis for the current judgment.
10. The system according to claim 6, It is characterized in that The value of the coupling condition is the previous setting value of the coupling condition described in the current test case.
11. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the method for generating a minimum test case set based on the MC / DC coverage criterion as described in any one of claims 1 to 5 when executing the computer program.
12. A computer storage medium, It is characterized in that The computer storage medium stores computer executable instructions, which, when executed, implement the method for generating a minimum test case set based on the MC / DC coverage criterion as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Integrated automated test case generation for safety-critical software
CN105701008A
Test case set automatic generation method
CN107748721A
MC / DC test case set generation method for multi-value coupling signals
CN112052177A
Automatic translation of simulink models into the input language of a model checker
US20080086705A1