A structured requirement-based test case automatic generation method
By using an automatic test case generation method based on structured requirements, the problem of low efficiency and difficulty in guaranteeing the quality of test cases that meet the MC/DC testing standard in existing technologies is solved, and efficient and accurate test case generation is achieved.
Patent Information
- Application Number
- CN202211265346.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-17
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-10-17
AI Technical Summary
Existing technologies suffer from high resource consumption, slow processing speed, high algorithm complexity, and complex modeling when generating test cases that meet the MC/DC testing standard, resulting in low test case development efficiency and difficulty in guaranteeing quality.
Based on structured requirements, test cases are automatically generated by constructing structured flowcharts. Different algorithms are used to generate a benchmark library of test cases that meet branch coverage or MC/DC coverage. Complete test cases are generated by combining conditional value replacement.
It improves the efficiency of test case development, reduces manual input, solves the subjectivity and error rate of manually writing test cases, and achieves high-quality test case generation.
Smart Images

Figure CN115658486B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of software testing, and particularly relates to a test case automatic generation method based on structured requirements. BACKGROUND
[0002] The purpose of software testing is to verify whether the function meets the requirements, and through the execution of test cases, problems are found and defects are repaired in time before being formally put into use, which is crucial to ensure the quality of software development, and therefore the development quality of test cases is the key and difficulty of software testing. Up to now, the development of test cases is mainly manual, and the developers are required to have high professional level and certain testing experience, and can develop test cases meeting the test standard coverage according to the case design method. However, the manual development of test cases often has subjectivity, and the working condition is not considered comprehensively, which will affect the test efficiency, coverage and increase the test cost, and the software quality is difficult to guarantee, and therefore it is necessary to study the automatic generation method of test cases in order to improve the test quality and reduce the cost. In recent years, researchers have made a lot of research on various automatic generation methods of test cases, and have achieved certain results.
[0003] Among them, MC / DC (Modified Condition / Decision Coverage) is a practical software structure coverage test criterion, which is proposed by two engineers Chilenski and Miller in 1994, and has become a widely used test standard in the testing of aviation software and software in critical safety fields. The four basic requirements of the MC / DC test standard are: the entry point and the exit point of the program are run at least once; all possible results of each decision appear at least once; all values of each condition in the decision appear at least once; and each condition can independently affect the result of the decision. The last one is the most important, that is, changing the value of the condition can change the result of the decision when all other conditions remain unchanged, which can indicate that the condition can independently affect the result of the entire function decision. For example, the decision A&&B, when B is True, changing the value of condition A can independently affect the result of the decision, that is, the results of (True&&True) and (False&&True) are opposite. For simplicity, T represents True and F represents False in the following. Although the test cases meeting the software logic decision condition coverage can be developed based on the MC / DC criterion, it is not easy to accurately and quickly obtain the simplest test case set meeting the requirements of MC / DC, and researchers have also made researches for this purpose.
[0004] The prior art discloses an implementation method and system of computer software white box testing. First, all possible conditions (2n, n is the number of conditions) in the judgment are traversed, the independent pairs of each condition in the judgment are solved, then the minimum independent pair set of each condition is solved, and then the test case set corresponding to the minimum independent pair set is generated, that is, the minimum test case set. When the number of conditions is small, the method is effective, when the number of conditions is large, the method occupies more resources and storage space, and the operation speed is also reduced.
[0005] The prior art discloses an MC / DC test data automatic generation method based on a genetic algorithm. The algorithm uses the genetic algorithm theory. Similarly, the method also needs to obtain all test cases, and then uses the genetic algorithm theory for further processing. Compared with the above patent, the method is too theoretical and more difficult to use.
[0006] The prior art discloses a test case set automatic generation method. The minimum test case set algorithm meeting the MC / DC criterion is developed for zero-coupling / weak-coupling conditional logic expression and strong-coupling conditional logic expression. The zero-coupling / weak-coupling conditional logic expression algorithm step constraint condition is too much, and the test case set needs to be further expanded to generate a step-perfect test case (Test Case) that can be used to guide testing.
[0007] In addition, some researches also propose to establish a graphical expression form, and use an algorithm to generate a basic test case set meeting path coverage. Such methods generally have complex system model construction work or strong algorithm theory, and are not easy to implement.
[0008] The prior art discloses a batch test case generation method, device, equipment and storage medium. By acquiring a state transition graph, analyzing state transition relationship to generate a simplified expression, and then generating test cases in batches, the method is suitable for state machine test case generation, but the method does not explicitly explain the specific algorithm of how the simplified expression generates test cases.
[0009] The prior art also discloses a model-based spacecraft controller software test case automatic generation method. The method models the state transition of a spacecraft in a test requirement by using a UML state diagram to obtain a standard model, then pre-processes and converts the standard model into a directed graph, and then obtains a test case set meeting path coverage. The method is relatively complex for spacecraft modeling and needs to be performed by professional personnel. SUMMARY
[0010] In view of the above problems existing in the prior art, the present application aims to provide a test case automatic generation method based on structured requirements, so as to meet the test case generation for structured requirements of different structures and structure coverage requirements. The present application faces the software function requirement design specification, firstly constructs the requirement specification input from the front end into a structured flowchart specification, and then automatically generates test cases based on the method of the present application, which can be directly used to guide the test personnel to perform manual testing or automatic test script development. The method can effectively improve the development efficiency of test cases, save manual input, solve the subjectivity and error rate of manual test case writing, realize high-quality development of test cases, and further improve product quality.
[0011] The present application is implemented by the following technical solutions:
[0012] A test case automatic generation method based on structured requirements, specifically comprising the following steps:
[0013] Step one: judging whether the target structured requirement contains a branch structure and a structure coverage type to be met;
[0014] Step two: generating a test case benchmark library by calling different algorithms according to whether the branch structure is contained and the structure coverage type to be met;
[0015] Step three: counting the number N of test cases in which the condition value is 'T' and the number N of test cases in which the condition value is 'F' in the test case benchmark library. T F
[0016] Step four: replacing the condition value with the value of the corresponding input variable.
[0017] Further, in step two, the test case benchmark library is generated by calling different algorithms according to the branch structure and the structure coverage type to be met, specifically comprising:
[0018] (a) if the branch structure is contained and only the branch coverage requirement needs to be met, the following algorithm is called to generate the test case benchmark library;
[0019] Step A1: the value of the first independent condition is False, each level of sub-determination is traversed from bottom to top in turn until the current processing condition is found as a non-decision condition of a sub-determination or a determination, and the value of the current processing condition is determined by the logical operator of the determination as a non-decision condition;
[0020] Step A2: adding a complement of the first test case;
[0021] Step A3: combining all the values generated by step A1 and step A2 to obtain the test case benchmark library;
[0022] (b) If the branch structure is included and the MC / DC coverage requirement is met, the following algorithm is called to generate the test case benchmark library;
[0023] Step B1: The value of the first independent condition is False, and each level of sub-determination is traversed from bottom to top until the current processing condition is found as a non-decision condition of the sub-determination or determination, and the value of the current processing condition is determined by the logical operator of the determination as a non-decision condition;
[0024] Step B2: The subsequent condition is selected as an independent condition, and the value is opposite to that in the previous test case. Other non-independent conditions are selected as the current processing condition. The value of the current processing condition is determined according to whether it is a non-decision condition;
[0025] Step B3: The complement of the first test case is added;
[0026] Step B4: All values generated by step B1 and step B3 are combined to obtain the test case benchmark library.
[0027] Further, the independent condition refers to the condition that currently independently affects the output result of the logical expression; the non-independent condition refers to the condition other than the independent condition in the current determination; the current processing condition refers to the non-independent condition currently prepared for processing; the non-independent determination refers to the determination other than the independent determination; the non-decision condition refers to the condition that determines the output result of the current non-independent determination, usually the first condition; the complement refers to the negation of the independent condition and its repeated value of a test case, and the value of the non-independent condition remains unchanged.
[0028] Further, the logical operator of the determination: after one level of splitting, the determination can be classified into one of the following cases:
[0029] 1) Sub-determination, condition and logical operator;
[0030] 2) Condition and logical operator;
[0031] 3) Sub-determination and logical operator.
[0032] Further, the complement value method in step A2 is: the value of the independent condition is negated, and the values of other conditions remain unchanged.
[0033] Further, in step B2, the value of the current processing condition is determined according to whether it is a non-decision condition, which is as follows:
[0034] If the current processing condition is a non-determining condition, its value is determined by its preceding logical operator; if the current processing condition is a determining condition, its value is determined by the logical operator of its sub-determination as a non-determining condition, and the determination is traversed from bottom to top until the same parent determination is reached; if the determination as a non-determining condition reaches the same parent determination that has been traversed before, its value is determined by the logical operator of the same parent determination.
[0035] Further, in step two, if the target structured requirement does not contain a branch structure, the algorithm steps for generating the corresponding test case are as follows:
[0036] Step C1: select the variable representative value in the input box one by one;
[0037] C11: select the intermediate value in the value domain of the input variable as the value of the input variable, corresponding to test case 1;
[0038] C12: if the intermediate value of the value domain of a certain input variable is zero, select any non-zero value in the value domain range as the value of the input variable, corresponding to test case 2;
[0039] Step C2: boundary value analysis test case supplement;
[0040] C21: select a set of input box variable value combinations so that the output variable value in the processing box is the maximum value, corresponding to test case 3;
[0041] C22: select a set of input box variable value combinations so that the output variable value in the processing box is the minimum value, corresponding to test case 4.
[0042] Further, in step C12, any non-zero value is selected as the intermediate value between zero and the maximum value.
[0043] Further, in step four, the condition value is replaced by the corresponding input variable value, which is as follows:
[0044] If the condition value is "T", select a representative value from the set of valid equivalence class representative values of the corresponding input variable that has not been used in the current test case set for replacement, if all have been used, select a representative value in the valid equivalence class; if the condition value is "F", select a representative value from the set of invalid equivalence class representative values of the corresponding input variable that has not been used.
[0045] Compared with the prior art, the advantages of the present application are as follows:
[0046] The application discloses a test case automatic generation method based on structured requirements, which develops corresponding test case generation algorithms from aspects of structural characteristics (including branch structure, not including branch structure) of a structured flowchart, structure coverage (branch coverage, MC / DC coverage) of a use case generation, and requirement configuration, and the algorithm steps are clear and convenient for operation, and have practical guiding significance. Firstly, according to the structural characteristics and the coverage configuration, the algorithm is called to generate a test case benchmark library, then the variable value in the condition is expanded, and a complete test case meeting the test coverage requirement is generated, which contains a use case number, a use case name or a brief description, a test purpose, an initial condition, a test step, an expected result, and the like, and can be directly used to guide a tester to perform manual testing or automatic test script development; the test case meeting the branch coverage is mainly used for function point test, and the test case meeting the MC / DC coverage is used to guide perfect function test verification. BRIEF DESCRIPTION OF DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. In all the drawings, similar elements or parts are generally identified by similar reference signs. In the drawings, the elements or parts are not necessarily drawn according to the actual proportions.
[0048] Figure 1 FIG. 1 is a flow diagram of a test case automatic generation method based on structured requirements according to the present application;
[0049] Figure 2 FIG. 2 is an upper and lower relationship hierarchical splitting diagram of Example 2. DETAILED DESCRIPTION
[0050] In order to clearly and completely describe the technical solutions of the present application and the specific working process thereof, in combination with the drawings of the specification, the specific embodiments of the present application are as follows:
[0051] In the present application, unless otherwise explicitly specified and limited, the terms "mounting", "connection", "connecting", "fixing" and the like should be understood in a broad sense, for example, can be fixed connection, or detachable connection, or integral; can be mechanical connection, or electrical connection; can be directly connected, or indirectly connected through an intermediate medium, can be the internal communication of two elements or the interaction relationship between two elements, unless otherwise explicitly limited. For those skilled in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.
[0052] In the present application, unless otherwise explicitly specified and limited, the first feature is "on" or "under" the second feature can be that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, the first feature "over", "above" and "on" the second feature can be that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in horizontal height than the second feature. The first feature "under", "below" and "under" the second feature can be that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in horizontal height than the second feature.
[0053] In the description of the present application, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present application, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any suitable manner in any one or more embodiments or examples. In addition, the skilled person in the art can combine and combine the different embodiments or examples described in the present application and the features of the different embodiments or examples without contradiction.
[0054] Embodiment 1
[0055] The present embodiment discloses a structured requirement-based test case automatic generation method to meet the test case generation requirements of structured requirements and structure coverage. The present application faces the software function requirement design specification, first constructs the front-end input requirement specification into a structured flowchart specification, and then automatically generates test cases based on the method of the present application, which can be directly used to guide the test personnel to perform manual testing or automatic testing script development. Among them, the requirement specification construction work of the front-end structured flowchart is not in the scope of the present application, only the general standardized flowchart structure required by the present application can be included, including sequential, branching, loop structure and its derived structure.
[0056] The present embodiment discloses a structured requirement-based test case automatic generation method, which includes a set of test case generation algorithms, including the following specific steps:
[0057] Step 1: Determine whether the target structured requirement contains branching structure and the type of structure coverage that needs to be met:
[0058] (a) If it contains branching structure and only needs to meet the branching coverage requirement, then step 2.1 calls the following algorithm to generate the test case benchmark library;
[0059] Step 2.1.1: The first independent condition (the first condition) is assigned a value of False, and each level of sub-determination is traversed from bottom to top until a determination is found in which the current condition is a non-determining condition, and the value of the current condition is determined by the logical operator of the determination in which it is a non-determining condition;
[0060] Step 2.1.2: A complement of the first test case is added, and the complement is assigned a value by negating the value of the independent condition and keeping the values of the other conditions unchanged;
[0061] Step 2.1.3: All the values generated in steps 2.1.1 and 2.1.2 are combined to obtain a test case benchmark library;
[0062] (b) If a branch structure is included and the MC / DC coverage requirement needs to be met, step 2.2 calls the following algorithm to generate a test case benchmark library;
[0063] Step 2.2.1: The first independent condition (the first condition) is assigned a value of False, and each level of sub-determination is traversed from bottom to top until a determination is found in which the current condition is a non-determining condition, and the value of the current condition is determined by the logical operator of the determination in which it is a non-determining condition;
[0064] Step 2.2.2: Each subsequent condition is selected as an independent condition, and the value is opposite to that in the previous test case. Each other non-independent condition is selected as the current condition. If the current condition is a non-determining condition, its value is determined by the preceding logical operator. If the current condition is a determining condition, its value is determined by the logical operator of the determination in which it is a non-determining condition, and the determination is traversed from bottom to top until the same parent determination is reached. If the determination in which it is a non-determining condition has already been traversed to the same parent determination, its value is determined by the logical operator of the same parent determination;
[0065] Logical operator of a determination: after one level of splitting, each determination can be classified as follows
[0066] 1) sub-determination, condition and logical operator;
[0067] 2) condition and logical operator;
[0068] 3) sub-determination and logical operator;
[0069] For a determination that can be classified as 1): the logical operator of the determination is the logical operator between the sub-determination and the condition;
[0070] For a determination that can be classified as 2): the logical operator of the determination is the logical operator between the conditions;
[0071] For the judgment of 3), the logical operator between the sub-judgments is the logical operator of the judgment.
[0072] Step 2.2.3: Add the complement of the first test case;
[0073] Step 2.2.4: Combine all the value groups generated by step 2.2.1 and step 2.2.3 to obtain the test case benchmark library;
[0074] (c) If the target structured requirement does not contain a branch structure, the algorithm for generating test cases is described as follows:
[0075] Step 2.3.1: Select the variable representative value in the input box in turn;
[0076] ① Select the middle value in the input variable value range as the input variable value, corresponding to test case 1;
[0077] ② If the middle value of the value range of an input variable is zero, select any non-zero value in the value range (recommended to select the middle value of zero and the maximum value) as the input variable value, corresponding to test case 2;
[0078] Step 2.3.2: Boundary value analysis test case supplement;
[0079] ① Select a set of input box variable value combinations so that the output variable value in the processing box is the maximum value, corresponding to test case 3;
[0080] ② Select a set of input box variable value combinations so that the output variable value in the processing box is the minimum value, corresponding to test case 4;
[0081] Step 3: Count the number of test cases NT with condition value "T" and the number of test cases NF with condition value "F" in the test case benchmark library;
[0082] Step 4: Replace the condition value with the corresponding input variable value: if the condition value is "T", select a representative value from the set of valid equivalence class representatives of the corresponding input variable that has not been used in the current test case set for replacement, if all have been used, then select a representative value in a valid equivalence class; if the condition value is "F", select a representative value from the set of invalid equivalence class representatives of the corresponding input variable that has not been used in the current test case set for replacement, if all have been used, then select a representative value in an invalid equivalence class.
[0083] The terms involved in this embodiment are explained as follows:
[0084] Independent condition: refers to a condition that currently independently affects the output result of the logical expression;
[0085] Non-independent condition: refers to the condition other than the independent condition in the current determination;
[0086] Current processing condition: refers to the non-independent condition currently prepared for processing (value);
[0087] Same father determination: refers to the determination containing the independent condition and the current processing condition, or the determination containing the least number of conditions in the determination or sub-determination;
[0088] Independent determination: refers to the determination containing the independent condition or the determination containing the least number of conditions in the determination or sub-determination;
[0089] Non-independent determination: refers to the determination other than the independent determination in the current determination;
[0090] First condition: refers to the first condition of the determination or sub-determination;
[0091] Non-decision condition: refers to the condition that determines the output result of the current non-independent determination, usually the first condition;
[0092] Supplement: refers to the negation of the independent condition and its repeated value of a certain test case, and the value of the non-independent condition remains unchanged;
[0093] The quality of test cases directly affects the test results, which is the key to finding software problems. A complete test case needs to include case number, case name or brief, test purpose, initial condition, test steps, expected results, etc. The attributes are shown in the following table.
[0094]
[0095] Example 2
[0096] The following is an example of the method of generating a test case benchmark library according to step 2.2 of the algorithm (b) that meets the MC / DC coverage degree:
[0097] For example, there is a branch determination in a certain functional structured requirement, and the simplest expression of the functional condition determination is (A&&((B&&C)||D))||(E&&F). Based on this determination, the test case set method generated by step 2.2 of the above algorithm (b) that meets the MC / DC coverage degree is demonstrated.
[0098] Step 2.2.1: The value of the first independent condition (the first condition) is False, and each level of sub-determination is traversed from bottom to top until the sub-determination or determination of the current processing condition as a non-decision condition is found. The value of the current processing condition is determined by the logical operator of the determination of which it is a non-decision condition;
[0099] Step 2.2.2: Select the subsequent condition as the independent condition in turn, and take the value opposite to the value in the previous test case. Select other non-independent conditions as the current processing condition in turn. If the current processing condition is a non-determining condition, its value is determined by its preceding logical operator; if the current processing condition is a determining condition, its value is determined by the logical operator of the sub-determination as a non-determining condition, and the determination is traversed from bottom to top until the same parent determination is reached; if the determination as a non-determining condition reaches the same parent determination, its value is determined by the logical operator of the same parent determination;
[0100] Step 2.2.3: Add the complement of the first test case;
[0101] Step 2.2.4: Combine all the values generated by step 2.2.1 and step 2.2.3 to obtain the test case benchmark library;
[0102] The upper and lower relationship level of the determination (A&&((B&&C)||D))||(E&&F) is split as shown in Figure 2
[0103] Step 2.2.1A: Take the first condition A as the independent condition, and take the value F. B is the current condition, and each level of sub-determination is traversed from bottom to top. The smallest sub-determination of B as a non-determining condition is A&&((B&&C)||D)), so B takes the value T;
[0104] Step 2.2.1B: Take C as the current condition. The smallest sub-determination of C as a non-determining condition is B&&C, so C takes the value T;
[0105] Step 2.2.1C: Take D as the current condition. The smallest sub-determination of D as a non-determining condition is B&&C)||D, so D takes the value F;
[0106] Step 2.2.1D: Take E as the current condition. The smallest sub-determination of E as a non-determining condition is (A&&((B&&C)||D))||(E&&F), so E takes the value F;
[0107] Step 2.2.1E: Take F as the current condition. The smallest sub-determination of F as a non-determining condition is E&&F, so F takes the value T, and the first test case set takes the value [F T T F F T];
[0108] Step 2.2.2A: Select B as the independent condition in turn, and take the value opposite to the value in the previous test case set, so B takes the value F;
[0109] Step 2.2.2B: Take condition A as the current processing condition. Since A is a determining condition, the same parent determination is A&&((B&&C)||D)), so the value is determined by the logical operator of the same parent determination, which is T;
[0110] Step 2.2.2C: Take condition C as the current processing condition, since C is a non-determining condition, the value is determined by its pre-logic operator, and the value is T;
[0111] Step 2.2.2D: Take condition D as the current processing condition, since D is a non-determining condition, the value is determined by its pre-logic operator, and the value is F;
[0112] Step 2.2.2D: Take condition D as the current processing condition, since D is a non-determining condition, the value is determined by its pre-logic operator, and the value is F;
[0113] Step 2.2.2E: Take condition E as the current processing condition, since E is a non-determining condition, the value is determined by its pre-logic operator, and the value is F;
[0114] Step 2.2.2F: Take condition F as the current processing condition, since F is a non-determining condition, the value is determined by its pre-logic operator, and the value is T, so the second test case set takes the value [T F T F F T];
[0115] Step 2.2.2G: In turn, select the subsequent conditions C, D, E, F as independent conditions, and take the values opposite to those in the previous test case set, and in turn select other non-independent conditions as the current processing condition, and determine the value according to the algorithm method;
[0116] Step 2.2.3: Add the complement of the first test case set [T T T F F T];
[0117] Step 2.2.4: Combine all the values generated by step 2.2.1 and step 2.2.3 to get the minimal test case set true value table that satisfies the MC / DC coverage requirement of the decision, as shown in the following table;
[0118]
[0119]
[0120] According to the definition of MC / DC, the test case pairs of each condition independently affecting the overall decision value in the decision (A&&((B&&C)||D))||(E&&F) are shown in the following table. As can be seen from the example, the test case set generated based on algorithm (b) satisfies the MC / DC coverage requirement, that is, each condition can find a test case pair that independently affects the overall decision result, as shown in the following table, and the number of test cases is n+1, which satisfies the minimal test case set.
[0121]
[0122] The preferred embodiments of the present application are described in detail above with reference to the drawings, but the present application is not limited to the specific details of the above-described embodiments, and various simple modifications can be made to the technical solutions of the present application within the technical concept of the present application, and these simple modifications all belong to the protection scope of the present application.
[0123] In addition, it should be noted that each specific technical feature described in the above specific embodiments can be combined in any appropriate manner without contradiction, and in order to avoid unnecessary repetition, various possible combinations are not described again by the present application.
[0124] In addition, various different embodiments of the present application can also be combined in any manner, as long as it does not deviate from the idea of the present application, and it should also be considered as disclosed by the present application.
Claims
1. A method for automatically generating test cases based on structured requirements, characterized in that, Specifically comprising the following steps: Step one: judging whether the target structured requirement contains branch structure and the type of structure coverage that needs to be met; Step two: calling different algorithms to generate test case benchmark library according to whether it contains branch structure and the type of structure coverage that needs to be met; Step three: count the number of test cases N in the test case benchmark library whose condition value is "T" T and the number of test cases N whose condition value is "F" F ; Step four: replacing the condition value with the corresponding input variable value; The letter T represents True, and the letter F represents False.
2. The method for test case generation based on structured requirements as claimed in claim 1 wherein, In step two, different algorithms are called to generate test case benchmark library according to branch structure and the type of structure coverage that needs to be met, specifically including: (a) If it contains branch structure and only branch coverage requirement needs to be met, the following algorithm is called to generate test case benchmark library; Step A1: the value of the first independent condition is False, and each level of sub-determination is traversed from bottom to top until the current processing condition is found as a non-decision condition of sub-determination or determination, and the value of the current processing condition is determined by the logical operator of the determination as a non-decision condition; Step A2: adding the complement of the first test case; Step A3: combining all the values generated by step A1 and step A2 to obtain the test case benchmark library; (b) If it contains branch structure and MC / DC coverage requirement needs to be met, the following algorithm is called to generate test case benchmark library; Step B1: the value of the first independent condition is False, and each level of sub-determination is traversed from bottom to top until the current processing condition is found as a non-decision condition of sub-determination or determination, and the value of the current processing condition is determined by the logical operator of the determination as a non-decision condition; Step B2: selecting the subsequent condition as an independent condition in turn, and the value is opposite to that in the previous test case, and selecting other non-independent conditions as the current processing condition in turn; the value of the current processing condition is determined according to whether it is a non-decision condition; Step B3: adding the complement of the first test case; Step B4: combining all the values generated by step B1 and step B3 to obtain the test case benchmark library; Independent condition refers to the condition that currently independently affects the output result of the logical expression; non-independent condition refers to the condition other than the independent condition in the current determination; current processing condition refers to the non-independent condition currently being processed; independent determination refers to the determination containing the independent condition or the determination containing the least number of conditions; non-independent determination refers to the determination other than the independent determination; non-decision condition refers to the condition that determines the output result of the current non-independent determination, which is usually the first condition; complement refers to the negation of the independent condition and its repeated value of a test case, and the value of the non-independent condition remains unchanged.
3. The method as claimed in claim 2, wherein the structured requirements are obtained from the requirement specification document and the test case is generated based on the structured requirements. The logical operator of the determination: after one level of splitting, the determination can be classified into one of the following cases: 1) sub-determination, condition and logical operator; 2) condition and logical operator; 3) sub-determination and logical operator.
4. The method for test case generation based on structured requirements as claimed in claim 2, wherein, The complement value method in step A2 is: the value of the independent condition is negated, and the values of the other conditions remain unchanged.
5. The method for automatically generating test cases based on structured requirements as described in claim 2, characterized in that, In step B2, the value of the current processing condition is determined according to whether it is a non-decision condition, specifically as follows: If the current processing condition is a non-determining condition, its value is determined by its pre-logic operator; if the current processing condition is a determining condition, its value is determined by the logic operator of its sub-determination as a non-determining condition, and the determination is traversed from bottom to top until the same parent determination is reached; if the determination as a non-determining condition reaches the same parent determination that has been traversed before, its value is determined by the logic operator of the same parent determination.
6. The method for test case generation based on structured requirements as claimed in claim 1 wherein, In step two, if the target structured requirement does not contain a branch structure, the algorithm steps for generating test cases are as follows: Step C1: Select the input box variable representative value one by one; C11: Select the middle value of the input variable value domain range as the input variable value, corresponding to test case 1; C12: If there is a value domain intermediate value of zero for an input variable, select any non-zero value in the value domain range as the input variable value, corresponding to test case 2; Step C2: Boundary value analysis test case supplement; C21: Select a set of input box variable value combinations so that the output variable value in the processing box is the maximum value, corresponding to test case 3; C22: Select a set of input box variable value combinations so that the output variable value in the processing box is the minimum value, corresponding to test case 4.
7. The method for automatically generating test cases based on structured requirements as described in claim 6, characterized in that, In step C12, any non-zero value is selected as the intermediate value of zero and the maximum value.
8. The method for test case generation based on structured requirements as claimed in claim 1 wherein, In step four, replace the condition value with the corresponding input variable value, as follows: If the condition value is "T", select a representative value from the set of valid equivalence class representative values of the corresponding input variable that has not been used in the current test case set, and if all have been used, select a representative value from the set of valid equivalence class representative values; If the condition value is "F", select a representative value from the set of invalid equivalence class representative values of the corresponding input variable that has not been used.
Citation Information
Patent Citations
Path coverage software test-based automatic test case generation method
CN107590073A
Test case design method based on path depth coverage
CN111694741A