CN114676035A - Test case generation method and device and electronic equipment - Google Patents

Test case generation method and device and electronic equipment Download PDF

Info

Publication number
CN114676035A
CN114676035A CN202110214339.1A CN202110214339A CN114676035A CN 114676035 A CN114676035 A CN 114676035A CN 202110214339 A CN202110214339 A CN 202110214339A CN 114676035 A CN114676035 A CN 114676035A
Authority
CN
China
Prior art keywords
jump
test
condition
path
engineering
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110214339.1A
Other languages
Chinese (zh)
Inventor
刘希
黄颍华
邵桂欣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Electric Vehicle Co Ltd
Original Assignee
Beijing Electric Vehicle Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Electric Vehicle Co Ltd filed Critical Beijing Electric Vehicle Co Ltd
Priority to CN202110214339.1A priority Critical patent/CN114676035A/en
Publication of CN114676035A publication Critical patent/CN114676035A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Tests Of Electronic Circuits (AREA)

Abstract

The invention provides a test case generation method, a test case generation device and electronic equipment, wherein the test case generation method comprises the following steps: acquiring a project state of a tested project input by a user and a project skip element positioned between the project states; the engineering jump elements comprise jump conditions and logic condition elements positioned between the jump conditions; the jump condition comprises a signal element, a logic symbol, a signal assignment and a constant element; acquiring all test paths among the engineering states; and according to a preset jump rule, carrying out jump combination on the engineering jump elements on each test path to generate a test case. The scheme of the invention can realize automatic and comprehensive generation of the test case, reduce the time consumption for compiling the test case, improve the efficiency and save the cost.

Description

Test case generation method and device and electronic equipment
Technical Field
The invention relates to the technical field of testing, in particular to a test case generation method and device and electronic equipment.
Background
In the field of testing of automobile electronic controllers, verification testing of software algorithms is generally performed through Hardware-in-the-Loop (HIL), Safety Integrity Level (SIL) and other tests based on specification, that is, a test engineer writes test cases and tests according to test requirements provided by a development engineer to verify whether actual performance of software is consistent with functional requirements. At present, test cases are basically based on Modified Condition determination Coverage (MC/DC), equivalence class analysis, boundary value analysis and other test technologies, and are manually written by test engineers. Therefore, the quality and coverage of the test cases are different along with the experience difference of the test engineers, and a great deal of time is spent on the repetitive labor of compiling the test cases based on the same test technology by the test engineers, so that the test depth cannot be improved, and meanwhile, the improvement of the self ability of the test engineers is also restricted.
Disclosure of Invention
The embodiment of the invention provides a test case generation method, a test case generation device and electronic equipment, which are used for solving the problems that in the prior art, a test engineer writes a test case, the time consumption is long, the efficiency is low, and the labor cost is wasted.
In order to solve the above technical problem, an embodiment of the present invention provides the following technical solutions:
the embodiment of the invention provides a test case generation method, which comprises the following steps:
acquiring a project state of a tested project input by a user and a project skip element positioned between the project states; the engineering jump elements comprise jump conditions and logic condition elements positioned between the jump conditions; the jump condition comprises a signal element, a logic symbol, a signal assignment and a constant element;
acquiring all test paths among the engineering states;
and according to a preset jump rule, carrying out jump combination on the engineering jump elements on each test path to generate a test case.
Optionally, the generating a test case by performing a jump combination on the engineering jump elements on each test path according to a preset jump rule includes:
analyzing the jump condition to generate a condition combination list;
Analyzing the test path to generate a path combination list;
combining the condition combination list and the path combination list according to the preset skip 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 result of the jump conditions.
Optionally, before analyzing the jump condition and generating a condition combination list, the method further includes:
processing the signal elements according to a preset data format to obtain a data signal;
and carrying out characteristic analysis on the data signals to obtain characteristic classification signals.
Optionally, the analyzing the jump condition to generate a condition combination list includes:
analyzing time elements in the constant elements to obtain time element analysis results;
analyzing the logic condition elements to obtain a logic combination;
and generating the condition combination list according to the time element analysis result and the logic combination.
Optionally, the method further comprises:
analyzing the precondition in the skip condition according to a reference rule to obtain a precondition use case;
And adding the precondition case to the test case.
Optionally, the analyzing the jump condition to generate a condition combination list further includes:
carrying out equivalence class analysis on the characteristic classification signals to obtain equivalence analysis results;
adding the equivalent analysis result to the conditional combination list.
Optionally, the analyzing the test path to generate a path combination list includes:
performing loop processing on the test path to obtain a path loop analysis result;
analyzing the reference relation of the test path to obtain a path reference analysis result;
and generating the path combination list according to the path loop analysis result and the path reference analysis result.
Optionally, the signal element is called by the user from a pre-stored signal library; the signal library comprises the signal elements;
the constant element is called by the user from a pre-stored constant library; the constant library includes the constant elements.
An embodiment of the present invention further provides a test case generating device, including:
the input module is used for acquiring the engineering states of the tested engineering input by a user and engineering skip elements positioned between the engineering states; the engineering jump elements comprise jump conditions and logic condition elements positioned between the jump conditions; the jump condition comprises a signal element, a logic symbol, a signal assignment and a constant element;
The acquisition module is used for acquiring all the test paths among the engineering states;
and the case generation module is used for carrying out skip combination on the engineering skip elements on each test path according to a preset skip rule to generate a test case.
Optionally, the use case generating module includes:
the condition analysis unit is used for analyzing the jump condition and generating a condition combination list;
the path analysis unit is used for analyzing the test path to generate a path combination list;
the case generating unit is used for combining the condition combination list and the path combination list according to the preset skipping 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 result of the jump conditions.
Optionally, the use case generating module further includes:
the signal data processing unit is used for processing the signal elements according to a preset data format to obtain a digitalized signal;
and the signal characteristic analysis unit is used for carrying out characteristic analysis on the digitized signals to obtain characteristic classification signals.
Optionally, the condition analyzing unit includes:
the time condition analysis subunit is used for analyzing the time elements in the constant elements to obtain time element analysis results;
the logic condition analysis subunit is used for analyzing the logic condition elements to obtain a logic combination;
and the conditional list generating subunit is configured to generate the conditional combination list according to the time element analysis result and the logical combination.
Optionally, the condition analyzing unit further comprises:
the precondition analysis subunit is used for analyzing preconditions in the jump conditions according to a reference rule to obtain a precondition use case;
and the first adding subunit is used for adding the precondition case to the test case.
Optionally, the condition analyzing unit further comprises:
the equivalence class analysis subunit is used for carrying out equivalence class analysis on the characteristic classification signals to obtain equivalence analysis results;
a second adding unit configured to add the equivalent analysis result to the condition combination list.
Optionally, the path analysis unit includes:
the loop analysis subunit is used for performing loop processing on the test path to obtain a path loop analysis result;
The reference analysis subunit is used for analyzing the reference relationship of the test path to obtain a path reference analysis result;
and the path list generating subunit is configured to generate the path combination list according to the path loop analysis result and the path reference analysis result.
Optionally, the signal element is called by the user from a pre-stored signal library; the signal library comprises the signal elements;
the constant element is called by the user from a pre-stored constant library; the constant library includes the constant elements.
An embodiment of the present invention further provides an electronic device, which includes a processor, a memory, and a program or an instruction stored in the memory and executable on the processor, where the program or the instruction, when executed by the processor, implements the steps of the test case generation method according to any one of the above.
An embodiment of the present invention further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and the program or the instruction, when executed by a processor, implements the steps of the test case generation method according to any one of the above.
The invention has the beneficial effects that:
according to the scheme, the engineering jump elements between the engineering states and the engineering states input by a user are obtained, all the testing paths between the engineering states are obtained, and the engineering jump elements on each testing path are subjected to jump combination according to the preset jump rule to generate the testing case, so that the testing case can be automatically and comprehensively generated, the time consumption for compiling the testing case is reduced, the efficiency is improved, and the cost is saved.
Drawings
FIG. 1 is a flowchart illustrating a test case generation method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating test requirements provided by an embodiment of the present invention;
FIG. 3 is a schematic diagram of a loop provided by an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a test case generation apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
The invention provides a test case generation method, a test case generation device and electronic equipment, aiming at the problems that in the prior art, a test engineer writes a test case, the test engineer consumes long time, the test engineer has low efficiency and the test engineer wastes labor cost.
As shown in fig. 1, an embodiment of the present invention provides a test case generation method, including:
step 101: acquiring a project state of a tested project input by a user and a project skip element positioned between the project states; the engineering jump elements comprise jump conditions and logic condition elements positioned between the jump conditions; the jump conditions include signal elements, logic symbols, signal assignments, and constant elements.
In the embodiment of the invention, the test requirement input by the user is expressed by the engineering state and the engineering skip element positioned between the engineering states, and the engineering state mainly comprises the following steps: an element entering the project, an element exiting the project, and an element maintaining the operation of the project. The engineering jump element represents a conversion trigger condition between two engineering states, a plurality of jump conditions can be added on the engineering jump element, each jump condition is composed of a signal element, a logic symbol, a signal assignment and a constant element, and all conversion conditions are connected by the logic condition element, namely a logic operation symbol.
It should be noted that, when a user inputs a test requirement, one engineering state may be connected to another engineering state through one engineering skip element, or a plurality of engineering states may be connected through a plurality of engineering skip elements.
In the embodiment of the present invention, a test case device based on a model, that is, an automatic test case generation tool is provided, and the automatic test case generation tool is composed of two parts: the system comprises an upper computer interface, an acquisition module and a use case generation module, wherein the upper computer interface is a requirement expression interface of a user and expresses the requirement of testing. The upper computer interface comprises an input module.
The automatic test case generation tool defines a set of Domain Specific Language (DSL), and a user inputs the engineering state of a tested engineering and the engineering jump element between the engineering states through an input module, namely a case design module, in an upper computer interface in the tool.
It should be noted that, in the case design module in the upper computer interface, the case design interface is mainly a graphical interface, and the main constituent elements are the engineering states and the engineering jump elements between the engineering states, and in addition, the case design module also includes the comment elements and the jump symbols, and the user can express the engineering states of the project to be tested and the engineering jump elements between the engineering states through the graphical language, that is, the test requirements are expressed. For example, a flow chart of a user inputting a graphical test requirement through a use case design module is shown in fig. 2. Wherein, State represents the engineering State, and the two engineering states are the engineering jump elements.
When the use case design module is used for carrying out use case design, the special semantics which can be supported by the engineering state element and the engineering skip element comprise: the system comprises a formula class, a table look-up class, a reference class, an access class and a system, wherein the formula class supports complex formula algorithms such as calculus and piecewise function, the table look-up class supports a two-dimensional table and a time class, the reference class refers to other states in the same engineering element, the access class refers to a signal variable of a current use case and performs declaration, initialization, assignment and operation, and the system can automatically deduce the type of the variable.
Step 102: and acquiring all test paths between the engineering states.
In the embodiment of the invention, the engineering state and the engineering jump element input by the user are all expanded, and all test paths in the test requirement flow chart are obtained.
In the embodiment of the 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 test requirements of the user can be comprehensively covered.
Step 103: and according to a preset jump rule, carrying out jump combination on the engineering jump elements on each test path to generate a test case.
In the embodiment of the invention, according to the jump condition in the engineering jump element on the test path, each test path and the engineering state connected with the test path are subjected to jump combination to generate the test case which comprehensively covers the test requirements of users.
In the embodiment of the invention, the graphical language input by a user is analyzed through the use case generation module, the graphical language is converted into the test requirement which can be identified by a computer program, and the engineering jump elements and the test paths on each test path are combined according to the preset jump rule to generate the test case.
According to the embodiment of the invention, the engineering states of the engineering to be tested input by a user and the engineering jump elements between the engineering states are obtained, all the test paths between the engineering states are obtained, and the engineering jump elements on each test path are subjected to jump combination according to the preset jump rule to generate the test case, so that the test case can be automatically and comprehensively generated, the time consumption for compiling the test case is reduced, the efficiency is improved, and the cost is saved.
Optionally, the generating a test case by performing a jump combination on the engineering jump elements on each test path according to a preset jump rule includes:
analyzing the jump condition to generate a condition combination list;
analyzing the test path to generate a path combination list;
combining the condition combination list and the path combination list according to the preset skip 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 result of the jump conditions.
In the embodiment of the invention, the jump conditions in all the engineering jump elements among all the engineering states are analyzed to obtain the condition analysis result, and the condition combination list is generated according to all the condition analysis results. And expanding all the test paths and the engineering states on the test paths to generate a path combination list. And combining the condition combination list and the path combination list according to a preset jump rule to generate a test case.
In the embodiment of the invention, the use case generation module comprises a condition analysis unit, the condition analysis unit analyzes the jump condition in the engineering jump element to generate the jump condition use case, and all the jump condition use cases form a condition combination list.
The case generation module also comprises a path analysis unit, each test path is analyzed through the path analysis unit, and then each analyzed path is expanded to generate a path combination list.
The case generation module also comprises a case generation unit, and the condition combination list and the path combination list are combined through the case generation unit to generate the test case.
The following describes, in detail, a process of combining the condition combination list and the path combination list:
1. obtaining all test paths in the path combination list, using P1-PmAnd (4) showing. 2. For the test path P1The initial engineering state and the first engineering jump element in the same are the first jump state, the jump condition use case of the first jump state is obtained according to the condition combination list, and the jump conditions with True (True) results in the jump conditions are distributed to the test path P one by one1-PmThe test path with the jump condition exists, and the jump condition with the False (False) result in the jump condition case is allocated to the test path P 1-PmAny one of which has the jump conditionThe test path of (1). If the jumping times of the test paths are smaller than the number of the jumping condition cases, the test paths meeting the jumping conditions are circularly and repeatedly used, and the number of the test paths is increased to be larger than m (the repeated test paths exist, the repeated jumping conditions do not exist, and the test paths are assumed to be n); otherwise, the jump condition is repeatedly used, the number of the test paths is not increased, and at the moment, all the test paths with the jump state are filled with test cases. 3. For the test path P1The first jumping engineering state and its engineering jumping element, i.e. jumping state, also first obtain the set of its jumping conditions, and combine the set with the test path P obtained in the above-mentioned step 21-PnAll test paths in which the jump condition exists are combined. If the jumping times of the test paths are smaller than the number of the jumping condition cases, the test paths meeting the jumping conditions are circularly and repeatedly used, and at the moment, the number of the test paths is increased to be larger than n; otherwise, the jump condition is used repeatedly, the number of the test paths is not increased, and at the moment, all the test paths with the jump state are filled with the test cases. 4. To test path P in sequence 1All the engineering jump elements in (1), namely the jump states, implement the steps in step 2 and step 3. 5. To test path P in sequence2-PmThe steps in the step 2, the step 3 and the step 4 are implemented for all jump states in the test case list, wherein if a certain jump state is executed in the previous step, the jump is skipped, and finally all test case combinations, namely the test point list, are completed.
Optionally, before analyzing the jump condition and generating a condition combination list, the method further includes:
processing the signal elements according to a preset data format to obtain a data signal;
and carrying out characteristic analysis on the data signals to obtain characteristic classification signals.
In the embodiment of the present invention, the signal elements mainly include a conventional signal and a special signal, the signal elements are normalized according to a preset data format to obtain a digitized signal, and the digitized signal is subjected to feature analysis, wherein after the conventional signal is subjected to the feature analysis, features such as type, precision, range, and error of the output signal are output, and after the special signal is analyzed, special signal features such as table lookup, formula, logic are output, which includes: index signal characteristics, table lookup values, MAP tables, and characteristic locations of equations, etc.
In the embodiment of the present invention, the use case generating module further includes a signal data processing unit and a signal feature analyzing unit, before the signal element is subjected to feature analysis by the signal feature analyzing unit, the signal element needs to be normalized by the signal data processing unit according to a preset data format, information of various signal elements can be acquired from an input file such as a dbc file or a hard-wired interface file, and a data format is defined to process and store the signal elements, as shown in table 1, table 1 is a signal element normalization example table.
TABLE 1 signal element normalization example Table
Figure BDA0002952583580000091
And saving the attribute of the signal element after the normalization processing into a JSON format.
Optionally, the analyzing the jump condition to generate a condition combination list includes:
analyzing time elements in the constant elements to obtain time element analysis results;
analyzing the logic condition elements to obtain a logic combination;
and generating the condition combination list according to the time element analysis result and the logic combination.
In the embodiment of the invention, the analyzing of the jump condition mainly comprises analyzing the time element in the constant element and analyzing the logic condition element, and generating the condition combination list according to the time element analysis result and the logic condition element analysis result.
The time element is analyzed, and whether the jump condition is limited by time or not is mainly analyzed. The logical Condition elements are analyzed mainly by using a Modified Condition Coverage (MCDC) criterion and a Condition influence.
In the embodiment of the present invention, the condition analysis unit is configured to analyze a time element and a logical condition element in the jump condition.
The time condition analysis subunit in the condition analysis unit is configured to analyze the time element, for example, after the engineering state 1 satisfies the jump conditions a & B and is kept for 10 seconds, jump to the engineering state 2, and optionally, the time element generally includes how many seconds a timeout counter is greater than and how many seconds a timeout counter is equal to.
A logical Condition analysis subunit in the Condition analysis unit analyzes the logical Condition elements, and obtains a logical combination of conversion conditions using a Modified Condition Coverage (MCDC) criterion and a Condition influence.
And a condition list generating subunit in the condition analysis unit obtains a condition combination list according to the time element analysis result and the logic combination.
Optionally, the method further comprises:
Analyzing the precondition in the skip condition according to a reference rule to obtain a precondition use case;
and adding the precondition case to the test case.
In the embodiment of the invention, the jump condition also comprises a special condition, namely a precondition. In this embodiment, the following several ways of setting and referencing preconditions are set: 1. and introducing an externally generated test case Excel table as a precondition, and importing the Excel table by setting node attributes on a case design interface. 2. The block diagram is referred to as a precondition. The steps of quoting the precondition are as follows: and when the preposed step is triggered, developing according to the quoted flow step to generate a preposed condition case, and adding the preposed condition case to the test case.
In the embodiment of the present invention, the precondition analyzing subunit in the condition analyzing unit is further configured to analyze the precondition in the jump condition, and the first adding subunit, that is, the use case adding subunit adds the preconditioned use case generated by the analysis to the test use case.
Optionally, the analyzing the jump condition to generate a condition combination list further includes:
carrying out equivalence class analysis on the characteristic classification signals to obtain equivalence analysis results;
adding the equivalent analysis result to the conditional combination list.
In the embodiment of the invention, the step of analyzing the jump condition further comprises the step of performing equivalence class analysis on the feature classification signal, wherein the equivalence class analysis mainly aims to reduce the test quantity. The objects classified for the equivalence class include a boolean signal, a continuous signal, and an enumeration signal among the feature classification signals.
In the embodiment of the invention, an equivalence class analysis subunit in the condition analysis unit performs equivalence class analysis on the feature classification signals, an input domain is divided into a plurality of equivalent parts, and the influence of each value on the test result is the same in the domain of each equivalence class. Due to the equivalence, a small representative amount of data is selected from a certain equivalence class for testing.
In the embodiment of the present invention, for a boolean signal, the valid equivalence class is a signal value that makes the jump condition true, and the invalid equivalence class is a signal value that makes the jump condition false.
For a discrete enumeration signal, the valid equivalence class is a subset of signal values that make the jump condition true, and the invalid equivalence class is a subset of signal values that make the jump condition false. When the number of the elements in the subset is less than or equal to 5, testing each element in the subset; when the number of elements in the subset is greater than 5, in order to reduce the number of use cases, the elements less than 5 are manually set or automatically selected randomly for testing.
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. The continuous signals include IO analog input quantity, float type CAN signals, time variable and the like. Since the values are continuous, discretization is required. Discretization is performed by selecting the upper point (point on the boundary), the point closest to the upper point (typically obtained by adding/subtracting one precision or step size from the boundary point), or the inner point (any point in the domain) of the given data field.
In general, for a discrete signal, the "upper point" and "lower point" are fixed regularly, while the "inner point" can have an infinite number of choices. The following rules are used in the embodiments of the present invention: the 'inner point' uses the middle point of two boundary values of the continuous signal effective value range, if one boundary point of the continuous signal effective value range is the same as the value range of the signal, the boundary point and the corresponding physical maximum/minimum value middle point are used; if the value range of the continuous signal is infinite (time signal), only the boundary value is tested.
Optionally, the analyzing the test path to generate a path combination list includes:
performing loop processing on the test path to obtain a path loop analysis result;
analyzing the reference relation of the test path to obtain a path reference analysis result;
and generating the path combination list according to the path loop analysis result and the path reference analysis result.
In the embodiment of the present invention, analyzing the test path mainly includes analyzing a loop in the test path and analyzing a reference relationship. The main purpose of analyzing the loop is to check whether a loop or a loop nested path exists in the test path, the position of the loop, and the number of times of the engineering state the loop is involved in. The analysis of the reference relationship is mainly to check the logic signal and judge whether the reference step conflicts with the previous operation.
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.
The loop analysis subunit is mainly used for checking whether a loop or a loop nesting path exists in a flow chart of a graphical test requirement input by a user on a case design interface, and the position of the loop and a label of a related engineering state. Referring to fig. 3, the flow chart of the test requirement has a loop shown in fig. 3, where the engineering state a → the engineering state C → the engineering state D → the engineering state a forms a closed loop, and if not limited, a dead loop is formed according to a backtracking algorithm, optionally, a default maximum loop value, such as 1000, may be added to the loop to prevent the algorithm from being terminated, and a configuration may be provided for a user to manually set a loop threshold of a certain loop in advance.
And analyzing whether a reference step exists in the flow chart of the test requirement or not by using the reference analysis subunit.
And expanding and adding a path loop analysis result and a path reference analysis result on the basis of conventional path coverage through a path list generation subunit, and outputting a final path combination.
Optionally, the signal element is called by the user from a pre-stored signal library; the signal library comprises the signal elements;
the constant element is called by the user from a pre-stored constant library; the constant library includes the constant elements.
In the embodiment of the invention, the upper computer interface in the automatic test case generation tool further comprises a signal management module and a constant management module.
The signal management module can manage a signal library, a user can call signal elements in the signal library, the signal elements can be newly built, stored, edited, deleted and indexed through the signal management module, the deleting function supports batch operation, and the new signal elements can be built in a manual adding mode.
The signal library also supports import and export functionality of signal elements. The import function of the signal library supports automatic parsing of the following file formats: dbc file, a2l file.
In addition, when the design case needs to input signal elements, the output window can automatically prompt a signal list used recently or a list of signal elements used in the project.
Each signal element includes the following attributes: variable name, chinese description name, type (CAN, CCP, IO, etc.), data type (boolean, enumeration, continuation), value, precision, maximum, minimum, allowable decision error, response delay time, transmission/reception, etc.
It should be noted that, for the same vehicle type or the same software testing process, some parameters in the tested controller and the testing environment are relatively fixed and unchangeable, for example, the allowable starting temperature of the air conditioner may be called through a constant library in a constant management module of the upper computer interface, and the constant management module further supports the functions of creating, storing, editing, deleting and indexing the constant, and the deleting function supports batch operation, and the constant library supports batch import and export functions.
It should be noted that the upper computer interface in the test case automatic generation tool further includes an engineering management module, and a user can manage a plurality of engineering files by performing directory-type management on the engineering files through the engineering management module. The project can be newly built, deleted, imported, exported and switched. The project designed by the user, including the related information such as signals, constants, flow charts and the like, can be stored as an independent project file and has the function of importing and exporting. After the project file is imported by other users, the flow chart and the signal information of the project file can be normally used without other additional operations.
Multiple use cases can be designed in one project, and a multi-level directory structure is used for classification, so that different sub-function use cases of the same function module can be managed conveniently.
According to the embodiment of the invention, the engineering states of the engineering to be tested input by a user and the engineering jump elements between the engineering states are obtained, all the test paths between the engineering states are obtained, and the engineering jump elements on each test path are subjected to jump combination according to the preset jump rule to generate the test case, so that the test case can be automatically and comprehensively generated, the time consumption for compiling the test case is reduced, the efficiency is improved, and the cost is saved.
As shown in fig. 4, an embodiment of the present invention further provides a test case generating apparatus, including:
the input module 401 is used for acquiring the project states of the project to be tested and project skip elements between the project states, wherein the project states are input by a user; the engineering skip elements comprise skip conditions and logic condition elements positioned between the skip conditions; the jump condition comprises a signal element, a logic symbol, a signal assignment and a constant element;
an obtaining module 402, configured to obtain all test paths between the engineering states;
And the case generating module 403 is configured to perform a skip combination on the engineering skip elements on each test path according to a preset skip rule, so as to generate a test case.
According to the test case generation device provided by the embodiment of the invention, the engineering states of the engineering to be tested input by a user and the engineering jump elements between the engineering states are obtained, all the test paths between the engineering states are obtained, and the engineering jump elements on each test path are subjected to jump combination according to the preset jump rule to generate the test case, so that the test case can be automatically and comprehensively generated, the time consumption for compiling the test case is reduced, the efficiency is improved, and the cost is saved.
Optionally, the use case generating module 403 includes:
the condition analysis unit is used for analyzing the jump condition and generating a condition combination list;
the path analysis unit is used for analyzing the test path to generate a path combination list;
the case generating unit is used for combining the condition combination list and the path combination list according to the preset skipping 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 result of the jump conditions.
Optionally, the use case generating module 403 further includes:
the signal data processing unit is used for processing the signal elements according to a preset data format to obtain a digitalized signal;
and the signal characteristic analysis unit is used for carrying out characteristic analysis on the digitized signals to obtain characteristic classification signals.
Optionally, the condition analyzing unit includes:
the time condition analysis subunit is used for analyzing the time elements in the constant elements to obtain time element analysis results;
the logic condition analysis subunit is used for analyzing the logic condition elements to obtain a logic combination;
and the conditional list generating subunit is used for generating the conditional combination list according to the time element analysis result and the logic combination.
Optionally, the condition analyzing unit further comprises:
the precondition analysis subunit is used for analyzing preconditions in the jump conditions according to a reference rule to obtain a precondition use case;
and the first adding subunit is used for adding the precondition case to the test case.
Optionally, the condition analyzing unit further comprises:
the equivalence class analysis subunit is used for carrying out equivalence class analysis on the characteristic classification signals to obtain equivalence analysis results;
A second adding unit configured to add the equivalent analysis result to the condition combination list.
Optionally, the path analysis unit includes:
the loop analysis subunit is used for performing loop processing on the test path to obtain a path loop analysis result;
the reference analysis subunit is used for analyzing the reference relationship of the test path to obtain a path reference analysis result;
and the path list generating subunit is configured to generate the path combination list according to the path loop analysis result and the path reference analysis result.
Optionally, the signal element is called by the user from a pre-stored signal library; the signal library comprises the signal elements;
the constant element is called by the user from a pre-stored constant library; the constant library includes the constant elements.
It should be noted that, the test case generation apparatus provided in the embodiment of the present invention is an apparatus capable of executing the test case generation method, and all embodiments of the test case generation method described above are applicable to the apparatus and can achieve the same or similar technical effects.
An embodiment of the present invention further provides an electronic device, which includes a processor, a memory, and a program or an instruction stored in the memory and executable on the processor, where the program or the instruction, when executed by the processor, implements the steps of the test case generation method according to any one of the above.
An embodiment of the present invention further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and the program or the instruction, when executed by a processor, implements the steps of the test case generation method according to any one of the above.
While the foregoing is directed to the preferred embodiment of the present invention, it will be appreciated by those skilled in the art that various changes and modifications may be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (12)

1. A test case generation method is characterized by comprising the following steps:
acquiring a project state of a tested project input by a user and a project skip element positioned between the project states; the engineering jump elements comprise jump conditions and logic condition elements positioned between the jump conditions; the jump condition comprises a signal element, a logic symbol, a signal assignment and a constant element;
acquiring all test paths among the engineering states;
and according to a preset jump rule, carrying out jump combination on the engineering jump elements on each test path to generate a test case.
2. The method for generating the test case according to claim 1, wherein the generating the test case by performing the jump combination on the engineering jump elements on each of the test paths according to a preset jump rule comprises:
Analyzing the jump condition to generate a condition combination list;
analyzing the test path to generate a path combination list;
combining the condition combination list and the path combination list according to the preset skip 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 result of the jump conditions.
3. The method according to claim 2, wherein before analyzing the jump condition and generating a condition combination list, the method further comprises:
processing the signal elements according to a preset data format to obtain a data signal;
and carrying out characteristic analysis on the data signals to obtain characteristic classification signals.
4. The method according to claim 2, wherein analyzing the jump condition to generate a condition combination list comprises:
analyzing time elements in the constant elements to obtain time element analysis results;
analyzing the logic condition elements to obtain a logic combination;
And generating the condition combination list according to the time element analysis result and the logic combination.
5. The method for test case generation according to claim 4, further comprising:
analyzing the precondition in the skip condition according to a reference rule to obtain a precondition use case;
and adding the precondition case to the test case.
6. The method for generating test cases according to claim 3, wherein the analyzing the jump condition to generate a condition combination list further comprises:
carrying out equivalence class analysis on the characteristic classification signals to obtain equivalence analysis results;
adding the equivalent analysis result to the conditional combination list.
7. The method according to claim 2, wherein the analyzing the test paths to generate a path combination list comprises:
performing loop processing on the test path to obtain a path loop analysis result;
analyzing the reference relation of the test path to obtain a path reference analysis result;
and generating the path combination list according to the path loop analysis result and the path reference analysis result.
8. The test case generation method according to claim 1, wherein the signal element is called by the user from a pre-stored signal library; the signal library comprises the signal elements;
the constant element is called by the user from a pre-stored constant library; the constant library includes the constant elements.
9. A test case generation apparatus, comprising:
the input module is used for acquiring the engineering states of the tested engineering input by a user and engineering skip elements positioned between the engineering states; the engineering jump elements comprise jump conditions and logic condition elements positioned between the jump conditions; the jump condition comprises a signal element, a logic symbol, a signal assignment and a constant element;
the acquisition module is used for acquiring all the test paths among the engineering states;
and the case generation module is used for carrying out skip combination on the engineering skip elements on each test path according to a preset skip rule to generate a test case.
10. The test case generation apparatus according to claim 9, wherein the case generation module includes:
The condition analysis unit is used for analyzing the jump condition and generating a condition combination list;
the path analysis unit is used for analyzing the test path to generate a path combination list;
the case generating unit is used for combining the condition combination list and the path combination list according to the preset skipping 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 result of the jump conditions.
11. An electronic device comprising a processor, a memory, and a program or instructions stored on the memory and executable on the processor, the program or instructions when executed by the processor implementing the steps of the test case generation method of any of claims 1 to 8.
12. A readable storage medium, on which a program or instructions are stored, which when executed by a processor implement the steps of the test case generation method according to any one of claims 1 to 8.
CN202110214339.1A 2021-02-25 2021-02-25 Test case generation method and device and electronic equipment Pending CN114676035A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110214339.1A CN114676035A (en) 2021-02-25 2021-02-25 Test case generation method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110214339.1A CN114676035A (en) 2021-02-25 2021-02-25 Test case generation method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN114676035A true CN114676035A (en) 2022-06-28

Family

ID=82069911

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110214339.1A Pending CN114676035A (en) 2021-02-25 2021-02-25 Test case generation method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114676035A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115756996A (en) * 2023-01-09 2023-03-07 苏州浪潮智能科技有限公司 Chip testing method, device and equipment and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115756996A (en) * 2023-01-09 2023-03-07 苏州浪潮智能科技有限公司 Chip testing method, device and equipment and readable storage medium

Similar Documents

Publication Publication Date Title
Seger et al. Formal verification by symbolic evaluation of partially-ordered trajectories
US6321186B1 (en) Method and apparatus for integrated circuit design verification
Raymond et al. Automatic testing of reactive systems
US7523425B2 (en) Test case generation algorithm for a model checker
US8984496B2 (en) Extensible internal representation of systems with parallel and sequential implementations
US9904524B2 (en) Method and device for visually implementing software code
US20140013313A1 (en) Editor/Development Tool for Dataflow Programs
CN103052943A (en) Source code conversion method and source code conversion program
US20110145799A1 (en) Path-sensitive dataflow analysis including path refinement
CN111026670B (en) Test case generation method, test case generation device and storage medium
Ben-Amram et al. Complexity of Bradley-Manna-Sipma lexicographic ranking functions
US10915302B2 (en) Identification and visualization of associations among code generated from a model and sources that affect code generation
CN114676035A (en) Test case generation method and device and electronic equipment
Xie et al. Model checking for an executable subset of UML
US5353433A (en) Method and apparatus for organizing and analyzing timing information
CN111381828A (en) Method and device for generating syntax tree of code file and electronic equipment
CN111581101A (en) Software model testing method, device, equipment and medium
US9971676B2 (en) Systems and methods for state based test case generation for software validation
KR102550318B1 (en) Method for analyzing distributed object model based on trosar platform
CN111381826A (en) Method and device for generating syntax tree of code file and electronic equipment
Barford et al. Attribute grammars in constraint‐based graphics systems
US8954307B1 (en) Chained programming language preprocessors for circuit simulation
Zündorf A heuristic for the subgraph isomorphism problem in executing PROGRES
Toeppe et al. Automatic code generation requirements for production automotive powertrain applications
CN111381827A (en) Method and device for generating syntax tree of code file and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination