Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
At present, the complexity of automobile ECU software is higher and higher, the automobile ECU software is developed by engineers in different directions in a cooperative mode, basic software is divided into different categories such as communication, diagnosis and the like, the basic software is developed by communication engineers and diagnosis engineers respectively, application software is also divided into different categories such as transverse control, longitudinal control and the like, and the different categories are developed by corresponding engineers respectively. And modules responsible by different engineers are integrated by the integration engineer and then released after the development is completed.
The communication may refer to a communication function of the vehicle-mounted Controller, such as CAN (Controller Area Network) communication and ethernet communication. Diagnostics may refer to the functionality of the on-board controller for fault detection, fault storage, and communication protocols with diagnostics (e.g., UDS ISO 14229).
Before release, the product needs to be tested in multiple dimensions, such as testing for communication, diagnosis, control, and the like. Current software integration tests are performed by test engineers. And the test engineer formulates a test case according to the requirements proposed by the development engineer and the requirements of the project and executes the test.
The above-described method has the following problems: the communication cost between the test engineer and the development engineer is high; test cases with some requirements are difficult to develop; the time cost for the test engineer to develop the test case is high; ultimately resulting in longer product development cycles. The test engineer needs to have a certain understanding of the requirements and functions and their implementation to complete the design of the test case, so the requirements on the test engineer are also high.
For example, a state machine inside a controller is not familiar to a test engineer with the logic of the internal state machine, but the development engineer is very familiar with the logic of the internal state machine, and if the test engineer develops a test case, the development engineer needs to communicate with the test engineer for a long time, which causes great development difficulty, high time cost and long product development period.
Based on this, the test system and the test method provided by the embodiment of the invention can reduce the test difficulty, shorten the test time, and optimize and adjust the work of development engineers, integration engineers and test engineers.
To facilitate understanding of the embodiment, a detailed description will be given of a test system disclosed in the embodiment of the present invention.
The first embodiment is as follows:
an embodiment of the present invention provides a test system, referring to a schematic structural diagram of a test system shown in fig. 1, as shown in fig. 1, the test system includes: the test system comprises atest case module 1, atest frame module 2 and an input/output module 3; thetest case module 1, thetest frame module 2 and the input/output module 3 are sequentially in communication connection;
as shown in fig. 1, in order to design a part of test cases by a development engineer, the embodiment includes an upper computer and a lower computer, and the upper computer and the lower computer may be devices capable of communicating with each other, such as a computer and a server. The upper computer is used for sending a test command, receiving, analyzing and displaying a test result and generating a lower computer configuration file. The lower computer comprises three parts: the test system comprises a test case module, a test frame module and an input/output module.
The test case module is used for generating a test case so as to enable the test case to run in the test system; monitoring the running state of the test system; and if the running state represents that the test system is in an abnormal state, sending error information to the upper computer.
The test case in this embodiment may be integrated into the controller software, and executed by the controller together with the functional software, which may consume controller resources. In this embodiment, development engineers with various functions can refer to test cases in the test case module according to their own responsible contents, monitor the stable running state of the test system through the test cases, and feed back error information to the upper computer when the test system is abnormal.
It should be noted that, in this embodiment, there is not necessarily only one test case module, and each functional module of the software may correspond to one test case module, as shown in fig. 1, there may be 3 test case modules.
The test frame module is used for providing the type of the test case module, defining an interface for the input and output module, and scheduling and managing the test cases of the test case module. The test frame module can provide basic types for the test case module, can define a uniform interface for the result output module, and can also schedule and manage the test cases of each test case module and execute the output of the output module.
The input and output module is used for generating an output result based on the test case and sending the output result to the upper computer. The input and output module can generate an output result corresponding to the test case, format the output result, format a lower computer command corresponding to the output result, and then send the output result to the upper computer according to the formatted lower computer command.
According to the test system provided by the embodiment of the invention, the design of part of test cases is transferred from the test engineer to the development engineer, so that the test workload of the test engineer can be reduced, the working efficiency is improved, and the period of integrated test is shortened; the difficulty of the integration test can be reduced, and the requirements on an integration test engineer are reduced; the coverage of integrated test can be increased, and the reliability of the product is improved. Meanwhile, because the development engineer is very familiar with the module in charge of the development engineer, the difficulty in developing the test case is low, the required time is short, the design of the test case is transferred to the development engineer and is not consumed too much, and the test cases with different functions are completed by the corresponding development engineer and can be designed in parallel.
Example two:
the embodiment provides another test system, and the method is implemented on the basis of the embodiment; the present embodiment focuses on the specific structures of the test case module, the test frame module, and the input/output module. As shown in fig. 2, a schematic structural diagram of a test case module, atest case module 1 in this embodiment includes: a testcase configuration file 11, atest case file 12 and atest execution file 13;
the test case configuration file is used for setting the identification and the test function of the test case; the test case file is used for defining a monitoring mode and output content of the test system; the test execution file is used for providing an entry function for the test framework module.
Each test case module in the embodiment has the corresponding three types of files, and is independent from each other. The test case modules are independent of each other: the test case modules with various functions, such as a test case module with a communication function, a test case module with a diagnosis function, a test case module with a vehicle transverse control function and the like, are independent of one another, and can be only one test case module, a plurality of test case modules or even none.
The test case configuration file can set the ID number and the test function of the test case; the test case file defines a monitoring mode and self-defined output content; the test execution file provides an entry function for the test framework module, executes each test case, and uniformly outputs the test result of each test case.
Specifically, the test case configuration file may be _ cfg.c or _ cfg.h, the test case file may be _ testcase.c or _ testcase.h, and the test execution file may be _. The code of the test case configuration file may be:
the test case is a structure array constant, one test case corresponds to one array element, the first member of the structure is the serial number of the test case, and the second member is the name of the realization function of the test case. The code of the test case file may be:
this is a specific example of a test case, and queries whether the current CAN Pdu mode is correct. The code of the test execution file may be:
the function is an API provided for the test framework module, each test case function API is called through the structure array constant in the configuration file of the test module, and the test result of each test case is uniformly output
Referring to the structural diagram of a test framework module shown in fig. 3, thetest framework module 2 includes a testframework configuration file 21, a test framework type file 22 and a testframework execution file 23;
the test framework configuration file is used for setting the identification of the test case module and the entry function of the test case module; the test frame type file is used for providing the type of the test case module; the test framework execution file is used for testing-specific behaviors, and the testing behaviors comprise periodic execution, trigger execution or inhibition execution of test cases; and the method is also used for scheduling the entry function of the test case module.
In this embodiment, the test framework configuration file may be "cfg.c" or "cfg.h", the test framework type file may be "types.h", and the test framework execution file may be "c" or "h". The test framework configuration file can set the ID number of the test case module and the entry function of the test case module. The test framework type file may provide the types used in the integrated test system. The test framework execution file can define the test behaviors including not only periodic execution, trigger execution and inhibit the execution of test cases; the test framework execution file can also schedule the entry function of the test case module.
Specifically, the code of the test framework configuration file may be:
this is a structure array constant, one test module corresponds to one array element, the first member of the structure is the test module number, the second member is the test module entry executive function name, and the third member is the test module status (default in inactive state).
The code for testing the framework type file may be:
some basic types are defined in the test framework type file and used by the whole framework, including a test case return result type enCTst _ ResultType and a test module state type enCTst _ modulestatus type.
The code of the test framework execution file can be:
the first of the two functions executes the test case of the appointed module, and the second executes the test cases of all the modules.
Referring to a schematic structural diagram of an input/output module shown in fig. 4, the input/output module 3 includes: aprotocol layer 31 and adriver layer 32, wherein the protocol layer is also referred to as TP layer. The protocol layer is used for formatting an output result of the test case and a lower computer command; and the driving layer is used for sending the output result to the upper computer based on the lower computer command.
The protocol layer may output the result as well as the format command. The driving layer may use, but is not limited to, Uart, Can, TcpIp, etc. communication means. The output result and the upper computer command can be formatted by a TP layer, and can also be freely input and output by directly using a driving layer.
The test case module, the test frame module and the input/output module in the embodiment are all applied to the lower computer. For a test system in an upper computer, see fig. 5 for a schematic structural diagram of another test system, the test system includes aresult display module 41, acommand output module 42, and a filecode generation module 43; the result display module is used for displaying an output result sent by the lower computer; the command output module is used for sending an upper computer command to the lower computer; the file code generation module is used for generating a configuration file and a test case code of a test case module of the lower computer.
As shown in fig. 5, the result display module, the command output module, and the file code generation module in this embodiment are all applied to an upper computer.
The result display module has a result display function, can output a result without a protocol, and the upper computer directly analyzes and displays the result based on the ASCII code; the output result of the protocol can also be provided, and the upper computer analyzes and displays the protocol according to the protocol defined by the lower computer.
The command output module has a command output function: commands may be output to the lower computer according to a defined protocol.
The file code generation module can automatically generate the configuration file and the test case code of the test case module.
Generally, a test system for a test engineer generally develops a test case on a computer side based on a test tool (open source or business tool).
Example three:
the test case module, the test frame module and the input/output module in the embodiment are combined into a set of software system, and an integration engineer is required to integrate the software system into a specific embedded system. Under the condition of not influencing the original function module, a development engineer designs a test case of the original function module. The test cases refer to ranges including, but not limited to, states inside the functional modules, values of variables, the number of times the functional services are run, the order of execution, and the like.
Referring to fig. 6, a flow chart of a testing method is shown, as shown in fig. 6, the testing method includes the steps of:
step S602, determining a target test case and a target test case module corresponding to the target test case through the test framework module.
In this embodiment, the test may be periodically executed and the result may be output, or the test may be executed and the result may be returned under the control of the command of the upper computer, and the above steps may be executed in two ways:
mode 1: and the lower computer responds to the first test command and determines the target test case and a target test case module corresponding to the target test case through the test framework module.
In themode 1, that is, the case of periodically executing the test and outputting the result, referring to the sequence diagram of periodically executing the test and outputting the result shown in fig. 7, as can be seen from fig. 7, the scheduler may first send a first test command to the test frame module, determine the target test case and the target test case module corresponding to the target test case, and then execute the target test case by the target test case module.
Mode 2: the upper computer sends a first upper computer command to the input/output module, and the input/output module generates a second test command based on the first upper computer command; and responding to the second test command through the test framework module, and determining the target test case and the target test case module corresponding to the target test case.
Mode 2 is a situation that the upper computer commands to execute the test and return the result, referring to a sequence diagram of the upper computer commands to execute the test and return the result shown in fig. 8, as can be seen from fig. 8, the upper computer sends a first upper computer command to the input/output module, the input/output module sends a second test command to the test frame module, and the test frame module responds to the second test command to determine the target test case and the target test case module corresponding to the target test case.
Step S604, the target test case is executed by the target test case module.
After determining a target test case module for executing the target test case, the target test case may be executed by the target test case module.
And step S606, obtaining an output result of the target test case through the input and output module, and sending the output result of the target test case to the upper computer.
The output result of the target test case is obtained through the input and output module, and the input and output module can send the output result of the target test case to the upper computer.
Besides, the method further comprises the following steps: the upper computer sends a second upper computer command to the input/output module; the input/output module generates an attribute setting command based on the second upper computer command; and modifying the type of the test case by responding to the attribute setting command through the test framework module.
Referring to the sequence diagram of fig. 9, in which the scheduler performs attribute setting through the upper computer command, the scheduler may send a second upper computer command to the input/output module, and after the input/output module generates the attribute setting command, the test framework module responds to the attribute setting command to modify the type of the test case.
The test system and the test method provided by the embodiment of the invention have the following advantages: and (3) expandability: the number of test cases of each test case module is not limited, and the test cases can be freely expanded according to requirements. The communication mode has wide applicability: different communication modes may be selected, such as CAN, ethernet, Uart, etc. The functional module has wide applicability: the content of the functional module is not limited, and the test case can be specifically designed according to the difference of the functional module. The workload of a system integration test engineer is reduced, the working efficiency is improved, and the period of integration test is shortened; the coverage of integrated test is increased, and the reliability of the product is improved; the difficulty of the integrated test is reduced, and the requirements on an integrated test engineer are reduced.
Example four:
corresponding to the above method embodiment, an embodiment of the present invention provides a testing apparatus, as shown in fig. 10, which includes:
a target test case determining module 1001, configured to determine a target test case and a target test case module corresponding to the target test case through a test framework module;
a target testcase execution module 1002, configured to execute a target test case through the target test case module;
and the target testcase result module 1003 is used for obtaining an output result of the target test case through the input and output module and sending the output result of the target test case to the upper computer.
The target test case determining module is used for responding to the first test command by the lower computer and determining a target test case and a target test case module corresponding to the target test case through the test frame module; or the upper computer sends a first upper computer command to the input/output module, and the input/output module generates a second test command based on the first upper computer command; and responding to the second test command through the test framework module, and determining the target test case and the target test case module corresponding to the target test case.
The testing device also comprises an attribute setting module which is used for sending a second upper computer command to the input and output module by the upper computer; the input/output module generates an attribute setting command based on the second upper computer command; and modifying the type of the test case by responding to the attribute setting command through the test framework module.
Example five:
the embodiment of the invention also provides electronic equipment, which is used for operating the test method; referring to fig. 11, a schematic structural diagram of an electronic device is shown, the electronic device includes amemory 100 and aprocessor 101, where thememory 100 is used to store one or more computer instructions, and the one or more computer instructions are executed by theprocessor 101 to implement the above-mentioned test method.
Further, the electronic device shown in fig. 11 further includes a bus 102 and acommunication interface 103, and theprocessor 101, thecommunication interface 103, and thememory 100 are connected through the bus 102.
TheMemory 100 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 11, but that does not indicate only one bus or one type of bus.
Theprocessor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in theprocessor 101. TheProcessor 101 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in thememory 100, and theprocessor 101 reads the information in thememory 100, and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the test method.
The computer program product of the test system and the test method provided by the embodiment of the present invention includes a computer readable storage medium storing a program code, and instructions included in the program code may be used to execute the method in the foregoing method embodiment, and specific implementation may refer to the method embodiment, and will not be described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and/or the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In addition, in the description of the embodiments of the present invention, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.