A test case generation method, device and electronic device
By obtaining the test project status and project jump elements input by the user, and using preset rules to generate test cases, the problem of time-consuming writing use cases by testing engineers is solved, and automated test case generation is realized, which improves efficiency and coverage.
Patent Information
- Application Number
- CN202110214339.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-25
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2041-02-25
AI Technical Summary
Test engineers take a long time and are inefficient in writing test cases, resulting in a waste of labor costs and fail to improve the depth of testing and engineer capabilities.
By obtaining the project status and project jump elements of the tested project entered by the user, obtaining all test paths, and combining the project jump elements according to the preset jump rules to generate test cases, including condition combinations and path combinations, and using signals Elements, logical symbols and constant elements are analyzed and processed.
It realizes automated generation of test cases, reduces writing time, improves efficiency, saves costs, and achieves comprehensive test coverage.
Smart Images

Figure CN114676035B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of testing technology, and in particular to a test case generation method, device and electronic equipment. Background Art
[0002] In the field of automotive electronic controller testing, verification testing of software algorithms is generally performed through specification-based testing such as Hardware-in-the-Loop (HIL) and Safety Integrity Level (SIL), that is, test engineers write test cases and conduct tests based on the test requirements provided by development engineers to verify whether the actual performance of the software is consistent with the functional requirements. At present, test cases are basically based on modified condition / decision coverage (MC / DC), equivalence class analysis, boundary value analysis and other testing technologies, and are manually written by test engineers. Therefore, the quality and coverage of test cases vary with the experience of test engineers, and test engineers spend a lot of time on repetitive work of writing test cases based on the same test technology, but cannot improve the depth of testing. At the same time, the improvement of the ability of test engineers themselves is also restricted. Summary of the invention
[0003] The embodiments of the present invention provide a test case generation method, device and electronic device to solve the problems in the prior art that test engineers spend a long time, have low efficiency and waste manpower costs when writing test cases.
[0004] In order to solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0005] An embodiment of the present invention provides a test case generation method, comprising:
[0006] Acquire the engineering status of the tested engineering input by the user and the engineering jump elements between the engineering statuses; the engineering jump elements include jump conditions and logic condition elements between the jump conditions; the jump conditions include signal elements, logic symbols, signal assignments and constant elements;
[0007] Obtain all test paths between the engineering states;
[0008] According to the preset jump rules, the engineering jump elements on each of the test paths are jump combined to generate test cases.
[0009] Optionally, the step of performing jump combination on the engineering jump elements on each of the test paths according to a preset jump rule to generate a test case includes:
[0010] Analyze the jump conditions and generate a condition combination list;
[0011] Analyze the test paths and generate a path combination list;
[0012] According to the preset jump rule, the condition combination list and the path combination list are combined to generate the test case;
[0013] The preset jump rule is an algorithm for generating the test case according to the number of the test paths, the number of the jump conditions and the results of the jump conditions.
[0014] Optionally, before analyzing the jump conditions to generate a condition combination list, the method further includes:
[0015] Processing the signal elements according to a preset data format to obtain a digitized signal;
[0016] Perform feature analysis on the digitized signal to obtain a feature classification signal.
[0017] Optionally, analyzing the jump conditions to generate a condition combination list includes:
[0018] Analyze the time element in the constant element to obtain a time element analysis result;
[0019] Analyzing the logical condition elements to obtain a logical combination;
[0020] The condition combination list is generated according to the time element analysis result and the logical combination.
[0021] Optionally, the method further comprises:
[0022] According to the reference rule, the precondition in the jump condition is analyzed to obtain a precondition use case;
[0023] Add the precondition case to the test case.
[0024] Optionally, the analyzing the jump conditions to generate a condition combination list further includes:
[0025] Performing equivalence class analysis on the feature classification signal to obtain an equivalence analysis result;
[0026] The equivalence analysis result is added to the condition combination list.
[0027] Optionally, analyzing the test paths to generate a path combination list includes:
[0028] Performing loop processing on the test path to obtain a path loop analysis result;
[0029] Performing reference relationship analysis on the test path to obtain a path reference analysis result;
[0030] The path combination list is generated according to the path loop analysis result and the path reference analysis result.
[0031] Optionally, the signal element is called by the user from a pre-stored signal library; the signal library includes the signal element;
[0032] The constant element is called by the user from a pre-stored constant library; the constant library includes the constant element.
[0033] The embodiment of the present invention also provides a test case generation device, comprising:
[0034] An input module, used to obtain the engineering status of the tested engineering input by the user and the engineering jump elements between the engineering statuses; the engineering jump elements include jump conditions and logical condition elements between the jump conditions; the jump conditions include signal elements, logical symbols, signal assignments and constant elements;
[0035] An acquisition module, used to acquire all test paths between the engineering states;
[0036] The use case generation module is used to perform jump combinations on the engineering jump elements on each of the test paths according to preset jump rules to generate test cases.
[0037] Optionally, the use case generation module includes:
[0038] A condition analysis unit, used to analyze the jump conditions and generate a condition combination list;
[0039] A path analysis unit, used to analyze the test path and generate a path combination list;
[0040] A case generation unit, configured to combine the condition combination list and the path combination list according to the preset jump rule to generate the test case;
[0041] The preset jump rule is an algorithm for generating the test case according to the number of the test paths, the number of the jump conditions and the results of the jump conditions.
[0042] Optionally, the use case generation module further includes:
[0043] A signal data processing unit, used for processing the signal elements according to a preset data format to obtain a digitized signal;
[0044] The signal feature analysis unit is used to perform feature analysis on the digitized signal to obtain a feature classification signal.
[0045] Optionally, the condition analysis unit includes:
[0046] A time condition analysis subunit, used for analyzing the time element in the constant element to obtain a time element analysis result;
[0047] A logic condition analysis subunit, used to analyze the logic condition elements to obtain a logic combination;
[0048] The condition list generating subunit is used to generate the condition combination list according to the time element analysis result and the logical combination.
[0049] Optionally, the condition analysis unit further includes:
[0050] A precondition analysis subunit, used for analyzing the precondition in the jump condition according to the reference rule to obtain a precondition use case;
[0051] The first adding subunit is used to add the precondition case to the test case.
[0052] Optionally, the condition analysis unit further includes:
[0053] An equivalence class analysis subunit, used to perform equivalence class analysis on the feature classification signal to obtain an equivalence analysis result;
[0054] The second adding unit is used to add the equivalent analysis result to the condition combination list.
[0055] Optionally, the path analysis unit includes:
[0056] A loop analysis subunit, used to perform loop processing on the test path to obtain a path loop analysis result;
[0057] The reference analysis subunit is used to perform reference relationship analysis on the test path to obtain a path reference analysis result;
[0058] The path list generating subunit is used to generate the path combination list according to the path loop analysis result and the path reference analysis result.
[0059] Optionally, the signal element is called by the user from a pre-stored signal library; the signal library includes the signal element;
[0060] The constant element is called by the user from a pre-stored constant library; the constant library includes the constant element.
[0061] An embodiment of the present invention also provides an electronic device, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the test case generation method as described in any one of the above items.
[0062] An embodiment of the present invention further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the test case generation method as described in any one of the above items are implemented.
[0063] The beneficial effects of the present invention are:
[0064] The scheme of the present invention obtains the engineering status of the project under test input by the user and the engineering jump elements located between the engineering statuses, and obtains all test paths between the engineering statuses. According to preset jump rules, the engineering jump elements on each of the test paths are jump combined to generate test cases. This can realize automatic and comprehensive generation of test cases, reduce the time spent on writing test cases, improve efficiency, and save costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A flowchart showing a test case generation method provided by an embodiment of the present invention;
[0066] Figure 2 A flow chart showing the test requirements provided by an embodiment of the present invention;
[0067] Figure 3 A schematic diagram of a loop circuit provided by an embodiment of the present invention is shown;
[0068] Figure 4 A schematic diagram showing the structure of a test case generating device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0069] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0070] The present invention aims at the problems in the prior art that test engineers spend a long time, have low efficiency and waste manpower costs when writing test cases, and provides a test case generation method, device and electronic equipment.
[0071] like Figure 1 As shown, an embodiment of the present invention provides a test case generation method, comprising:
[0072] Step 101: Obtain the engineering status of the project under test input by the user and the engineering jump elements located between the engineering statuses; the engineering jump elements include jump conditions and logical condition elements located between the jump conditions; the jump conditions include signal elements, logical symbols, signal assignments and constant elements.
[0073] In an embodiment of the present invention, the test requirements input by the user are expressed through the engineering state and the engineering jump elements located between the engineering states. The engineering state mainly includes: elements for entering the engineering, elements for exiting the engineering, and elements for keeping the engineering running. The engineering jump element represents the transition trigger condition between two engineering states. Multiple jump conditions can be added to the engineering jump element. Each jump condition is composed of a signal element, a logic symbol, a signal assignment, and a constant element. Each transition condition is connected by a logic condition element, that is, a logic operation symbol.
[0074] It should be noted that when the user inputs the test requirements, one project state can be connected to another project state through one project jump element, or multiple project states can be connected through multiple project jump elements.
[0075] In an embodiment of the present invention, a model-based test case device is provided, that is, a test case automatic generation tool, which is composed of two parts: a host computer interface, an acquisition module and a case generation module, wherein the host computer interface is a user's demand expression interface, expressing the test demand. The host computer interface includes an input module.
[0076] The test case automatic generation tool defines a set of domain specific languages (DSL). Through the input module in the upper computer interface of the tool, that is, the use case design module, the user inputs the engineering status of the project under test and the engineering jump elements between the engineering statuses.
[0077] It should be noted that the use case design interface in the use case design module in the host computer interface is mainly a graphical interface, and its main components are the project status and the project jump elements between the project statuses. In addition, it also includes annotation elements and jump symbols. Users can use graphical language to express the project status of the project under test and the project jump elements between the project statuses in the use case design interface, that is, to express the test requirements. For example, the user enters a graphical flowchart of the test requirements through the use case design module, such as Figure 2 As shown in the figure, State represents the project status, and the element between two project statuses is the project jump element.
[0078] When designing use cases in the use case design module, the special semantics that can be supported by engineering status elements and engineering jump elements include: formula class, such as supporting complex formula algorithms such as calculus and piecewise functions, table lookup class, such as supporting two-dimensional tables, time class, reference class, such as referencing other states within the same engineering element, access class, such as declaring, initializing, assigning, and operating a signal variable of the current use case. The system can automatically deduce the type of the variable.
[0079] Step 102: Obtain all test paths between the engineering states.
[0080] In the embodiment of the present invention, all the engineering status and engineering jump elements input by the user are expanded to obtain all the test paths in the test requirement flow chart.
[0081] In the embodiment of the present invention, after the user inputs all the test requirements through the use case design interface, all the test paths on the use case design interface are obtained through the acquisition module, so that the user's test requirements can be fully covered.
[0082] Step 103: According to the preset jump rules, the engineering jump elements on each of the test paths are jump-combined to generate a test case.
[0083] In the embodiment of the present invention, according to the jump conditions in the engineering jump elements on the test path, each test path and the engineering state connected thereto are jump-combined to generate test cases that fully cover the user's test requirements.
[0084] In an embodiment of the present invention, the graphical language input by the user is parsed through the use case generation module and converted into test requirements recognizable by the computer program. According to the preset jump rules, the engineering jump elements on each test path are combined with the test path to generate a test case.
[0085] The embodiment of the present invention obtains the engineering status of the project under test input by the user and the engineering jump elements located between the engineering statuses, and obtains all test paths between the engineering statuses. According to preset jump rules, the engineering jump elements on each of the test paths are jump combined to generate test cases. Automatic and comprehensive generation of test cases can be achieved, which reduces the time spent on writing test cases, improves efficiency, and saves costs.
[0086] Optionally, the step of performing jump combination on the engineering jump elements on each of the test paths according to a preset jump rule to generate a test case includes:
[0087] Analyze the jump conditions and generate a condition combination list;
[0088] Analyze the test paths and generate a path combination list;
[0089] According to the preset jump rule, the condition combination list and the path combination list are combined to generate the test case;
[0090] The preset jump rule is an algorithm for generating the test case according to the number of the test paths, the number of the jump conditions and the results of the jump conditions.
[0091] In an embodiment of the present invention, the jump conditions in all engineering jump elements between all engineering states are analyzed to obtain condition analysis results, and a condition combination list is generated based on all condition analysis results. All test paths and engineering states on the test paths are expanded to generate a path combination list. According to the preset jump rules, the condition combination list and the path combination list are combined to generate a test case.
[0092] In the embodiment of the present invention, the use case generation module includes a condition analysis unit, which analyzes the jump conditions in the engineering jump elements to generate jump condition use cases, and all jump condition use cases constitute a condition combination list.
[0093] The use case generation module also includes a path analysis unit, through which each test path is analyzed, and then each analyzed path is expanded to generate a path combination list.
[0094] The use case generation module also includes a use case generation unit, through which the condition combination list and the path combination list are combined to generate a test case.
[0095] The following is a detailed description of the process of combining the condition combination list and the path combination list:
[0096] 1. Get all the test paths in the path combination list, use P 1 -P m 2. For the test path P 1 The initial engineering state and its first engineering jump element, that is, the first jump state, are obtained according to the condition combination list. The jump condition use case of the first jump state is assigned to the test path P one by one. 1 -P m The test path of the jump condition exists in the test path, and the jump condition with a false result in the jump condition case is assigned to the test path P. 1 -P mAny test path with this jump condition. If the number of jumps in the test path is less than the number of jump condition cases, the test path that meets the jump condition is used repeatedly in a loop. At this time, the number of test paths increases and is greater than m (there are repeated test paths, but no repeated jump conditions, assuming that there are n test paths); otherwise, the jump conditions are reused, and the number of test paths no longer increases. At this time, all test paths with this jump state have been filled with test cases. 3. For test path P 1 The first jump engineering state and its engineering jump element, that is, the jump state, also first obtain the set of its jump conditions, and then compare the set with the test path P obtained in step 2 above. 1 -P n Combine all test paths with this jump condition in the test case. If the number of jumps in the test path is less than the number of jump condition cases, the test path that meets the jump condition is used repeatedly in a loop. At this time, the number of test paths increases to more than n; otherwise, the jump condition is used repeatedly in a loop, and the number of test paths does not increase. At this time, all test paths with this jump state have been filled with test cases. 4. Test path P in turn 1 For all engineering jump elements, that is, jump states, implement the steps in steps 2 and 3 above. 5. 2 -P m All jump states in the above steps 2, 3 and 4 are implemented. If a jump state has been executed in the previous step, it is skipped, and all test case combinations, that is, the test point list, are finally completed.
[0097] Optionally, before analyzing the jump conditions to generate a condition combination list, the method further includes:
[0098] Processing the signal elements according to a preset data format to obtain a digitized signal;
[0099] Perform feature analysis on the digitized signal to obtain a feature classification signal.
[0100] In an embodiment of the present invention, signal elements mainly include conventional signals and special signals. Signal elements are normalized according to a preset data format to obtain digitized signals, and feature analysis is performed on the digitized signals. After feature analysis of conventional signals, features such as the type, accuracy, range, and error of the signal are output. After analysis of special signals, special signal features such as table lookup, formula, and logic are output, including: signal features for indexing, table lookup values, MAP tables, and feature positions of formulas.
[0101] In an embodiment of the present invention, the use case generation module also includes a signal data processing unit and a signal feature analysis unit. Before the signal feature analysis unit performs feature analysis on the signal elements, the signal data processing unit needs to perform normalization processing on the signal elements according to a preset data format. Information of various signal elements can be obtained from input files such as dbc files or hard-wired interface files, and a data format is defined to process and store these signal elements, as shown in Table 1, which is an example table of signal element normalization.
[0102] Table 1. Example of signal element normalization
[0103]
[0104] The attributes of the signal element after normalization are saved in JSON format.
[0105] Optionally, analyzing the jump conditions to generate a condition combination list includes:
[0106] Analyze the time element in the constant element to obtain a time element analysis result;
[0107] Analyzing the logical condition elements to obtain a logical combination;
[0108] The condition combination list is generated according to the time element analysis result and the logical combination.
[0109] In the embodiment of the present invention, analyzing the jump condition mainly includes analyzing the time element in the constant element and analyzing the logic condition element, and generating a condition combination list according to the analysis results of the time element and the analysis results of the logic condition element.
[0110] The analysis of time elements mainly analyzes whether the jump condition is subject to time constraints. The analysis of logical condition elements mainly uses the Modified Condition Decision Coverage (MCDC) criterion and conditional influence to analyze.
[0111] In the embodiment of the present invention, the condition analysis unit is used to analyze the time element and the logic condition element in the jump condition.
[0112] The time condition analysis subunit in the condition analysis unit is used to analyze the time element. For example, after the project state 1 meets the jump conditions A&B and maintains for 10 seconds, it jumps to the project state 2. Optionally, the time element generally includes how many seconds the timeout counter is greater than and how many seconds a certain timeout counter is equal to.
[0113] The logical condition analysis subunit in the condition analysis unit is used to analyze the logical condition elements and obtain the logical combination of the conversion conditions using the Modified Condition Decision Coverage (MCDC) criterion and the condition influence.
[0114] The condition list generation subunit in the condition analysis unit obtains a condition combination list according to the time element analysis result and logical combination.
[0115] Optionally, the method further comprises:
[0116] According to the reference rule, the precondition in the jump condition is analyzed to obtain a precondition use case;
[0117] Add the precondition case to the test case.
[0118] In an embodiment of the present invention, the jump condition also includes a special type of condition, the precondition. In this embodiment, the following settings and reference methods of the precondition are set: 1. Reference an externally generated test case Excel table as a precondition, and import the Excel table by setting node properties on the use case design interface. 2. Reference a block diagram as a precondition. The steps of referencing the precondition are: reference a program state in the current or other function description block diagram as a precondition of the current test function, use the name of the program state as an index for selection, and when the precondition is triggered, the precondition use case will be generated according to the referenced process steps, and the precondition use case will be added to the test case.
[0119] In an embodiment of the present invention, the precondition analysis subunit in the condition analysis unit is also used to analyze the preconditions in the jump conditions, and the first adding subunit, that is, the use case adding subunit, adds the precondition use case generated after analysis to the test case.
[0120] Optionally, the analyzing the jump conditions to generate a condition combination list further includes:
[0121] Performing equivalence class analysis on the feature classification signal to obtain an equivalence analysis result;
[0122] The equivalence analysis result is added to the condition combination list.
[0123] In the embodiment of the present invention, analyzing the jump condition also includes performing equivalence class analysis on the feature classification signal, and the main purpose of the equivalence class analysis is to reduce the amount of testing. The objects of equivalence class division include Boolean signals, continuous signals and enumeration signals in the feature classification signal.
[0124] In the embodiment of the present invention, the equivalence class analysis subunit in the conditional analysis unit performs equivalence class analysis on the feature classification signal, divides the input domain into several equivalent parts, and in the domain of each equivalence class, the influence of each value on the test result is the same. Due to the equivalence, when testing, a small amount of representative data can be selected in a certain equivalence class for testing.
[0125] In the embodiment of the present invention, for a Boolean type signal, its valid equivalence class is the signal value that makes the jump condition true, and the invalid equivalence class is the signal value that makes the jump condition false.
[0126] For discrete enumeration signals, the valid equivalence class is the subset of signal values that make the jump condition true, and the invalid equivalence class is the subset of signal values that make the jump condition false. When the number of subset elements is ≤5, each element in the subset is tested; when the number of subset elements is >5, in order to reduce the number of use cases, manually set or automatically randomly select less than 5 elements for testing.
[0127] For continuous signals, the valid equivalence class is the subset of signal values that make the jump condition true, and the invalid equivalence class is the subset of signal values that make the jump condition false. Continuous signals include IO analog input, float type CAN signals, and time variables. Since the values are continuous, they need to be discretized. The discretization method is to select the discretized value by selecting the upper point (point on the boundary), the distance point (the point closest to the upper point, generally obtained by adding / subtracting a precision or step size from the boundary point) or the interior point (any point in the domain) of the specified data domain.
[0128] Generally speaking, for a discrete signal, the rules for "upper point" and "outer point" are fixed, while there are countless choices for "inner point". In the embodiment of the present invention, the following rules are used: "inner point" uses the middle point of the two boundary values of the effective value range of the continuous signal. If a boundary point of the effective value range of the continuous signal is the same as the value range of the signal, then the boundary point and its corresponding physical maximum / minimum middle point are used; if the value range of the continuous signal is infinite (time signal), only its boundary value is tested.
[0129] Optionally, analyzing the test paths to generate a path combination list includes:
[0130] Performing loop processing on the test path to obtain a path loop analysis result;
[0131] Performing reference relationship analysis on the test path to obtain a path reference analysis result;
[0132] The path combination list is generated according to the path loop analysis result and the path reference analysis result.
[0133] In the embodiment of the present invention, the analysis of the test path mainly includes the analysis of the loop in the test path and the analysis of the reference relationship. Among them, the main purpose of the loop analysis is to check whether there is a loop or a loop-nested path in the test path, the position of the loop and the number of the engineering state involved in the loop. The analysis of the reference relationship is mainly to check the logic signal to determine whether the reference step conflicts with the previous operation.
[0134] In the embodiment of the present invention, the path analysis unit mainly includes a loop analysis subunit, a reference analysis subunit and a path list generation subunit.
[0135] The loop analysis subunit is mainly used to check whether there are loops or loop nesting paths in the flowchart of the graphical test requirements input by the user on the use case design interface, the location of the loop, and the labels of the engineering states involved. Figure 3 , the flowchart of the test requirements exists as follows Figure 3 The loop shown, engineering status A→engineering status C→engineering status D→engineering status A, forms a closed loop. If it is not restricted, according to the backtracking algorithm, an infinite loop will be formed. Optionally, a default maximum loop value can be added to the loop, such as 1000, to prevent the algorithm from being unable to terminate. A configuration can also be provided to the user to allow the user to manually set the loop threshold of a loop in advance.
[0136] Through the reference analysis subunit, analyze whether there are reference steps in the flowchart of the test requirements.
[0137] Sub-units are generated through the path list, and the path loop analysis results and path reference analysis results are added on the basis of conventional path coverage to output the final path combination.
[0138] Optionally, the signal element is called by the user from a pre-stored signal library; the signal library includes the signal element;
[0139] The constant element is called by the user from a pre-stored constant library; the constant library includes the constant element.
[0140] In the embodiment of the present invention, the host computer interface in the test case automatic generation tool also includes a signal management module and a constant management module.
[0141] Among them, the signal management module can manage the signal library. Users can call signal elements in the signal library and can also create, store, edit, delete and index signal elements through the signal management module. The deletion function supports batch operations, and new ones can be created by manual addition.
[0142] The signal library also supports the import and export of signal elements. The import function of the signal library supports automatic parsing of the following file formats: dbc files, a2l files.
[0143] In addition, when you need to input signal elements when designing a use case, the output window will automatically prompt a list of recently used signals or a list of signal elements used in this project.
[0144] Each signal element includes the following attributes: variable name, Chinese description name, type (CAN, CCP, IO, etc.), data type (Boolean, enumeration, continuous), value, precision, maximum value, minimum value, allowable judgment error, response delay time, send / receive, etc.
[0145] It should be noted that for the same vehicle model or the same software testing process, some parameters in the tested controller and the test environment are relatively fixed, such as the allowable opening temperature of the air conditioner, which can be called through the constant library in the constant management module of the host computer interface. The constant management module also supports the creation, storage, editing, deletion, and indexing of constants. The deletion function supports batch operations, and the constant library supports batch import and export functions.
[0146] It should be noted that the host computer interface in the test case automatic generation tool also includes a project management module. Users can manage project files in a directory-like manner through the project management module, and can manage multiple project files. Projects can be created, deleted, imported, exported, and switched. User-designed projects, including signals, constants, flowcharts and other related information, can be saved as independent project files, and have import and export functions. After importing the project file, other users can use the flowchart and signal information of the project file normally without performing other additional operations.
[0147] There can be multiple use case designs in a project, and they can be classified using a multi-level directory structure to facilitate the management of different sub-function use cases of the same function module.
[0148] The embodiment of the present invention obtains the engineering status of the project under test input by the user and the engineering jump elements located between the engineering statuses, and obtains all test paths between the engineering statuses. According to preset jump rules, the engineering jump elements on each of the test paths are jump combined to generate test cases. Automatic and comprehensive generation of test cases can be achieved, which reduces the time spent on writing test cases, improves efficiency, and saves costs.
[0149] like Figure 4 As shown, an embodiment of the present invention also provides a test case generating device, comprising:
[0150] The input module 401 is used to obtain the engineering status of the tested engineering input by the user and the engineering jump elements between the engineering statuses; the engineering jump elements include jump conditions and logical condition elements between the jump conditions; the jump conditions include signal elements, logical symbols, signal assignments and constant elements;
[0151] The acquisition module 402 is used to acquire all test paths between the engineering states;
[0152] The use case generation module 403 is used to perform jump combination on the engineering jump elements on each of the test paths according to preset jump rules to generate test cases.
[0153] The test case generation device provided by the embodiment of the present invention obtains the engineering status of the project under test input by the user and the engineering jump elements located between the engineering statuses, and obtains all test paths between the engineering statuses. According to preset jump rules, the engineering jump elements on each of the test paths are jump combined to generate test cases. Automatic and comprehensive generation of test cases can be achieved, which reduces the time spent on writing test cases, improves efficiency, and saves costs.
[0154] Optionally, the use case generation module 403 includes:
[0155] A condition analysis unit, used to analyze the jump conditions and generate a condition combination list;
[0156] A path analysis unit, used to analyze the test path and generate a path combination list;
[0157] A case generation unit, configured to combine the condition combination list and the path combination list according to the preset jump rule to generate the test case;
[0158] The preset jump rule is an algorithm for generating the test case according to the number of the test paths, the number of the jump conditions and the results of the jump conditions.
[0159] Optionally, the use case generation module 403 further includes:
[0160] A signal data processing unit, used for processing the signal elements according to a preset data format to obtain a digitized signal;
[0161] The signal feature analysis unit is used to perform feature analysis on the digitized signal to obtain a feature classification signal.
[0162] Optionally, the condition analysis unit includes:
[0163] A time condition analysis subunit, used for analyzing the time element in the constant element to obtain a time element analysis result;
[0164] A logic condition analysis subunit, used to analyze the logic condition elements to obtain a logic combination;
[0165] The condition list generating subunit is used to generate the condition combination list according to the time element analysis result and the logical combination.
[0166] Optionally, the condition analysis unit further includes:
[0167] A precondition analysis subunit, used for analyzing the precondition in the jump condition according to the reference rule to obtain a precondition use case;
[0168] The first adding subunit is used to add the precondition case to the test case.
[0169] Optionally, the condition analysis unit further includes:
[0170] An equivalence class analysis subunit, used to perform equivalence class analysis on the feature classification signal to obtain an equivalence analysis result;
[0171] The second adding unit is used to add the equivalent analysis result to the condition combination list.
[0172] Optionally, the path analysis unit includes:
[0173] A loop analysis subunit, used to perform loop processing on the test path to obtain a path loop analysis result;
[0174] The reference analysis subunit is used to perform reference relationship analysis on the test path to obtain a path reference analysis result;
[0175] The path list generating subunit is used to generate the path combination list according to the path loop analysis result and the path reference analysis result.
[0176] Optionally, the signal element is called by the user from a pre-stored signal library; the signal library includes the signal element;
[0177] The constant element is called by the user from a pre-stored constant library; the constant library includes the constant element.
[0178] It should be noted that the test case generation device provided in the embodiment of the present invention is a device capable of executing the above-mentioned test case generation method, and all embodiments of the above-mentioned test case generation method are applicable to the device and can achieve the same or similar technical effects.
[0179] An embodiment of the present invention also provides an electronic device, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the test case generation method as described in any one of the above items.
[0180] An embodiment of the present invention further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the test case generation method as described in any one of the above items are implemented.
[0181] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary personnel in this technical field, several improvements and modifications can be made without departing from the principles described in the present invention. These improvements and modifications are also within the scope of protection of the present invention.
Claims
1. A test case generation method, characterized in that: include: Acquire the engineering status of the tested engineering input by the user and the engineering jump elements between the engineering statuses; The engineering jump elements include jump conditions and logic condition elements between the jump conditions; The jump conditions include signal elements, logic symbols, signal assignments and constant elements; Obtain all test paths between the engineering states; According to the preset jump rules, the engineering jump elements on each of the test paths are jump-combined to generate test cases; The step of performing jump combination on the engineering jump elements on each of the test paths according to the preset jump rules to generate a test case includes: Analyze the jump conditions and generate a condition combination list; Analyze the test paths and generate a path combination list; According to the preset jump rule, the condition combination list and the path combination list are combined to generate the test case; The preset jump rule is an algorithm for generating the test case according to the number of the test paths, the number of the jump conditions and the results of the jump conditions.
2. The test case generation method according to claim 1, characterized in that: Before analyzing the jump conditions and generating a condition combination list, the method further includes: Processing the signal elements according to a preset data format to obtain a digitized signal; Perform feature analysis on the digitized signal to obtain a feature classification signal.
3. The test case generation method according to claim 1, characterized in that: The step of analyzing the jump conditions to generate a condition combination list includes: Analyze the time element in the constant element to obtain a time element analysis result; Analyzing the logical condition elements to obtain a logical combination; The condition combination list is generated according to the time element analysis result and the logical combination.
4. The test case generation method according to claim 3, characterized in that: The method further comprises: According to the reference rule, the precondition in the jump condition is analyzed to obtain a precondition use case; Add the precondition case to the test case.
5. The test case generation method according to claim 2, characterized in that: The analyzing the jump conditions to generate a condition combination list also includes: Performing equivalence class analysis on the feature classification signal to obtain an equivalence analysis result; The equivalence analysis result is added to the condition combination list.
6. The test case generation method according to claim 1, characterized in that: The step of analyzing the test paths to generate a path combination list includes: Performing loop processing on the test path to obtain a path loop analysis result; Performing reference relationship analysis on the test path to obtain a path reference analysis result; The path combination list is generated according to the path loop analysis result and the path reference analysis result.
7. The test case generation method according to claim 1, characterized in that: The signal element is called by the user from a pre-stored signal library; the signal library includes the signal element; The constant element is called by the user from a pre-stored constant library; the constant library includes the constant element.
8. A test case generating device, characterized in that: include: An input module, used to obtain the engineering status of the tested engineering and the engineering jump elements between the engineering statuses input by the user; The engineering jump elements include jump conditions and logic condition elements between the jump conditions; The jump conditions include signal elements, logic symbols, signal assignments and constant elements; An acquisition module, used to acquire all test paths between the engineering states; A test case generation module, used to perform jump combination on the engineering jump elements on each of the test paths according to preset jump rules to generate a test case; Wherein, the use case generation module includes: A condition analysis unit, used to analyze the jump conditions and generate a condition combination list; A path analysis unit, used to analyze the test path and generate a path combination list; A case generation unit, configured to combine the condition combination list and the path combination list according to the preset jump rule to generate the test case; The preset jump rule is an algorithm for generating the test case according to the number of the test paths, the number of the jump conditions and the results of the jump conditions.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the test case generation method as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the test case generation method according to any one of claims 1 to 7 are implemented.
