CN117407302A - Automatic test method, system, equipment and storage medium for CAN communication - Google Patents
Automatic test method, system, equipment and storage medium for CAN communication Download PDFInfo
- Publication number
- CN117407302A CN117407302A CN202311391945.6A CN202311391945A CN117407302A CN 117407302 A CN117407302 A CN 117407302A CN 202311391945 A CN202311391945 A CN 202311391945A CN 117407302 A CN117407302 A CN 117407302A
- Authority
- CN
- China
- Prior art keywords
- data
- test
- communication
- program
- test data
- 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
Links
- 238000004891 communication Methods 0.000 title claims abstract description 51
- 238000010998 test method Methods 0.000 title claims abstract description 22
- 238000012360 testing method Methods 0.000 claims abstract description 108
- 230000005540 biological transmission Effects 0.000 claims description 13
- 238000012545 processing Methods 0.000 claims description 12
- 238000000034 method Methods 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 9
- 238000004458 analytical method Methods 0.000 claims description 7
- 240000008042 Zea mays Species 0.000 description 6
- 235000005824 Zea mays ssp. parviglumis Nutrition 0.000 description 6
- 235000002017 Zea mays subsp mays Nutrition 0.000 description 6
- 235000005822 corn Nutrition 0.000 description 6
- 230000006870 function Effects 0.000 description 4
- 238000013522 software testing Methods 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3692—Test management for test results analysis
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)
- Debugging And Monitoring (AREA)
- Maintenance And Management Of Digital Transmission (AREA)
Abstract
The invention discloses an automatic test method, system, equipment and storage medium for CAN communication, the test method comprises the following steps of assembling source data according to a CAN communication protocol, automatically generating test data, setting an instruction sending interval and a total test time of the test data based on the test data, transmitting the test data to a tested program through a CAN communication code, testing based on the instruction sending interval and the total test time to obtain result data, automatically comparing and analyzing expected data and the result data, wherein the expected data is each source data assembled according to the protocol, backtracking and analyzing each test data based on the data type, and automatically generating a test report.
Description
Technical Field
The invention relates to an automatic test method, system, equipment and storage medium for CAN communication, and belongs to the technical field of software testing.
Background
The stability and the correctness of the intelligent control system of the corn machine are important, and the stable operation of the system depends on the stability and the correctness of CAN communication. If the CAN communication data is abnormal, the system operates to receive and send the error data, which CAN cause the abnormality of the whole corn machine system and bring serious influence to the production and even the safety of farmers.
At present, the traditional test method for testing the CAN communication software is to connect a computer running a program with a CAN data transmitting device, and transmit a large amount of test data for a long time through the CAN data transmitting device, so as to achieve the purposes of testing the reliability and the stability of the software.
Because of the complexity of hardware and software, electromagnetic interference, lines and other reasons, the CAN data transmitting device transmits actual service data, and for a simple software test, all test case data cannot be easily formed, and the test data has one-sided property; the CAN data transmitting device is adopted to transmit test data, so that more manual participation is needed, for example, CAN communication test of the corn harvester is needed, the corn harvester is driven for a long time to operate, and a large amount of manpower and material resources are consumed; for sporadic and irregular error data generated by electromagnetic interference and other reasons, the data is not easy to generate and capture; for the result data obtained by the test, the comparison and analysis can only be carried out manually, and the test report can only be written manually.
Disclosure of Invention
In order to solve the defects in the prior art, the invention aims to provide an automatic test method, system, equipment and storage medium for CAN communication, which solve the problem that the result data obtained by the traditional test method for CAN communication software in the prior art is inaccurate.
In order to achieve the above object, the present invention adopts the following technical scheme:
an automatic test method for CAN communication comprises the following steps:
assembling the source data according to the CAN communication protocol, and automatically generating test data;
based on the test data, setting an instruction sending interval and a total test time of the test data;
transmitting test data to a tested program through a CAN communication code, and testing based on the instruction transmission interval and the total test time to obtain result data;
automatically comparing and analyzing expected data with result data, wherein the expected data is each piece of source data assembled according to the protocol;
and backtracking and analyzing each piece of test data based on the data type, and automatically generating a test report.
Further, the step of automatically generating test data according to the CAN communication protocol includes:
and generating random numbers for each field of the CAN communication protocol, assembling a protocol test data by using a program code based on the random numbers, and generating the random numbers based on a value range specified by the CAN communication protocol.
Further, the command transmission interval and the total test time of the test data are controlled by an operator through parameters.
Further, the step of transmitting the test data to the tested program through the CAN communication code and testing based on the command transmission interval and the total test time to obtain the result data includes:
designing a bottom CAN communication code to connect a test program and a tested program;
transmitting the test data generated in the test program to the tested program through the CAN communication code for testing;
automatically injecting irrational fault error data generated in the test process into the test data to perform iterative test;
and recording CAN original data received in the test process and analyzed result data.
An automatic test system for CAN communication, comprising:
the test data generation module automatically generates test data according to the CAN communication protocol;
the parameter setting module is used for setting the instruction sending interval and the total test time of the test data;
the data transmission module transmits the test data generated in the test program to the tested program;
the data comparison analysis module is used for comparing and processing expected data with result data obtained by actual processing;
and the report generation module is used for backtracking and analyzing according to the data type based on the test data to obtain a stability and reliability report of the software system.
An electronic device comprising a processor and a memory, the memory storing a computer medium that, when executed by the processor, performs the automatic test method of CAN communication of any of the preceding claims.
A computer medium having a computer program stored thereon, which when executed by a processor performs the automatic test method of CAN communication of any of the preceding claims.
The invention has the beneficial effects that:
1. by adopting the software CAN communication automatic test method, test data CAN be automatically generated according to a CAN communication protocol, all possible test cases are covered, the data covered by the software CAN communication automatic test method is comprehensive compared with the data covered by the traditional test method, the automation degree is high, the method is simple, and the generated result data is more accurate;
2. by setting the sending time interval and the total testing time, the testing can be automatically performed, manual intervention is not needed all the day, and a large amount of manpower and material resources are saved;
3. fault data is automatically collected and injected, the problem that accidental error data such as electromagnetic interference are difficult to generate and capture is solved, and the data comparison module automatically compares and analyzes the result data and automatically generates a test report.
Drawings
FIG. 1 is a flow chart of a software testing method in an embodiment of the invention;
FIG. 2 is a schematic diagram of a software testing system according to an embodiment of the present invention.
Meaning of reference numerals in the drawings: 100-a test data generation module; 200-a parameter setting module; 300-a data transfer module; 400-a data comparison and analysis module; 500-report generation module.
Detailed Description
The following detailed description of the technical solutions of the present invention is made by the accompanying drawings and specific embodiments, and it should be understood that the specific features of the embodiments and embodiments of the present application are detailed descriptions of the technical solutions of the present application, and not limiting the technical solutions of the present application, and the technical features of the embodiments and embodiments of the present application may be combined with each other without conflict.
Example 1
The embodiment discloses an automatic test method for CAN communication, which comprises the following steps:
1) Generating test data according to CAN communication protocol
According to the CAN communication protocol design program, random numbers are generated in each field of the protocol, then source data are assembled in a test data generation module by using a program code set according to the random numbers, and test data are automatically generated. The random number is generated in a value range specified by a protocol; the random data are assembled into a piece of protocol data, and the assembly is completed by using a program code according to a data structure specified by the protocol, namely, the assembly is performed in the opposite direction of CAN data analysis in the general sense.
A number is randomly generated, including each boundary value. And (5) performing boundary value test.
2) Setting instruction sending interval and total test time
Each test data item contains a data item of the transmission time interval. The data are transmitted to the tested software at certain intervals by the transmission time interval. The time interval is adjustable by the operator.
The total test time may also be controlled by an operator via parameters. In the whole test process, an operator can fully and automatically run the test by only setting each transmission data interval and the total time parameter of the test in the parameter setting module. For example, the operator may set up to run automatically for a full day.
3) The CAN communication code sends the test data to the CAN bus for testing
Designing a bottom CAN communication code, and then connecting a computer running a test program and a code running a tested program by using a CAN line. The test program sends the designed test data to the CAN bus through the data transmission module, and transmits the test data to the tested program.
All data sent by the test software are recorded in the tested software by a log, and the received CAN source data and the analyzed result data are recorded. If the tested program crashes on a certain piece of data, the log is used for recording stack information and the time of crashing, so that the trace is convenient, and the defect of the tested program is searched. The transmitted data log record can be placed at the data generation end, so that data tracing is convenient.
The fault collecting and injecting module automatically collects irrational fault error data generated by the system, the irrational fault data are more and more along with the operation of the system, and the irrational fault data are automatically injected into test data, so that the processing capacity of the corn machine control system on the fault data is tested.
4) Automatic comparison analysis of expected and result data
And comparing and processing each piece of source data assembled according to the protocol, namely the expected data, with the data actually processed by the corn machine control system by a data comparison and analysis module.
5) Automatically generating test reports
And the report generating module automatically generates a test report, backtracks and analyzes each piece of data tested according to the data type, and obtains a stability and reliability report of the software system.
Example two
The embodiment discloses an automatic test system of CAN communication, including:
the test data generation module automatically generates test data according to the CAN communication protocol;
the parameter setting module is used for setting the instruction sending interval and the total test time of the test data;
the data transmission module transmits the test data generated in the test program to the tested program;
the data comparison analysis module is used for comparing and processing expected data with result data obtained by actual processing;
and the report generation module is used for backtracking and analyzing according to the data type based on the test data to obtain a stability and reliability report of the software system.
Example III
The embodiment discloses an electronic device, which comprises a processor and a memory, wherein at least one instruction, at least one section of program, a code set or an instruction set is stored in the memory, and the at least one instruction, the at least one section of program, the code set or the instruction set is loaded and executed by the processor to realize the automatic test method of CAN communication.
Example IV
The embodiment discloses a computer medium, in which at least one instruction, at least one section of program, code set or instruction set is stored, and the at least one instruction, the at least one section of program, code set or instruction set is loaded and executed by a processor to implement the automatic test method for CAN communication provided in the above embodiment.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each of the flows of the flowchart may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.
Claims (7)
1. An automatic test method for CAN communication is characterized by comprising the following steps:
assembling the source data according to the CAN communication protocol, and automatically generating test data;
based on the test data, setting an instruction sending interval and a total test time of the test data;
transmitting test data to a tested program through a CAN communication code, and testing based on the instruction transmission interval and the total test time to obtain result data;
automatically comparing and analyzing expected data with result data, wherein the expected data is each piece of source data assembled according to the protocol;
and backtracking and analyzing each piece of test data based on the data type, and automatically generating a test report.
2. The automatic test method of CAN communication according to claim 1, wherein the step of automatically generating test data according to CAN communication protocol comprises:
generating a random number for each field of the CAN communication protocol, and assembling the source data into protocol test data by using a program code based on the random number, wherein the random number is generated based on a value range specified by the CAN communication protocol.
3. The automatic test method of CAN communication according to claim 1, wherein the instruction transmission interval and the total test time of the test data are controlled by an operator through parameters.
4. The automatic test method of CAN communication according to claim 1, wherein the step of transmitting test data to the program under test through the CAN communication code, performing the test based on the foregoing instruction transmission interval and the test total time, and obtaining the result data includes:
designing a bottom CAN communication code to connect a test program and a tested program;
transmitting the test data generated in the test program to the tested program through the CAN communication code for testing;
automatically injecting irrational fault error data generated in the test process into the test data to perform iterative test;
and recording CAN original data received in the test process and analyzed result data.
5. An automatic test system for CAN communication, comprising:
the test data generation module automatically generates test data according to the CAN communication protocol;
the parameter setting module is used for setting the instruction sending interval and the total test time of the test data;
the data transmission module transmits the test data generated in the test program to the tested program;
the data comparison analysis module is used for comparing and processing expected data with result data obtained by actual processing;
and the report generation module is used for backtracking and analyzing according to the data type based on the test data to obtain a stability and reliability report of the software system.
6. An electronic device comprising a processor and a memory, the memory storing a computer medium that, when executed by the processor, performs the method of automatic testing of CAN communication according to any one of claims 1 to 4.
7. A computer medium, characterized in that it has stored thereon a computer program which, when executed by a processor, performs the automatic test method of CAN communication according to any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311391945.6A CN117407302A (en) | 2023-10-25 | 2023-10-25 | Automatic test method, system, equipment and storage medium for CAN communication |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311391945.6A CN117407302A (en) | 2023-10-25 | 2023-10-25 | Automatic test method, system, equipment and storage medium for CAN communication |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117407302A true CN117407302A (en) | 2024-01-16 |
Family
ID=89486633
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311391945.6A Pending CN117407302A (en) | 2023-10-25 | 2023-10-25 | Automatic test method, system, equipment and storage medium for CAN communication |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117407302A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130117609A1 (en) * | 2011-11-03 | 2013-05-09 | Tata Consultancy Services Limited | System and Method for Testing and Analyses of the Computer Applications |
CN114338451A (en) * | 2021-12-31 | 2022-04-12 | 武汉思普崚技术有限公司 | Controller local area network bus test system, method and storage medium |
CN115550228A (en) * | 2022-08-23 | 2022-12-30 | 深圳开源互联网安全技术有限公司 | Internet of vehicles bus communication network test method and system |
-
2023
- 2023-10-25 CN CN202311391945.6A patent/CN117407302A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130117609A1 (en) * | 2011-11-03 | 2013-05-09 | Tata Consultancy Services Limited | System and Method for Testing and Analyses of the Computer Applications |
CN114338451A (en) * | 2021-12-31 | 2022-04-12 | 武汉思普崚技术有限公司 | Controller local area network bus test system, method and storage medium |
CN115550228A (en) * | 2022-08-23 | 2022-12-30 | 深圳开源互联网安全技术有限公司 | Internet of vehicles bus communication network test method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107797919A (en) | The method and computing device of a kind of automatic test | |
CN107066370A (en) | A kind of automatic monitoring and the instrument and method for collecting faulty hard disk daily record | |
CN112052172B (en) | Rapid test method and device for third-party channel and electronic equipment | |
CN107193730A (en) | A kind of interface test method of automation | |
CN103279063A (en) | Detecting mistake-proof system applicable to electronic part production line and method thereof | |
CN108108445A (en) | A kind of data intelligence processing method and system | |
CN109462517A (en) | A kind of method, system and the equipment of the data monitoring towards digital electric network business | |
CN112737886A (en) | Tool testing method and system | |
CN112187589A (en) | System testing method based on flow playback | |
CN110928796B (en) | Automatic test platform | |
CN115408367A (en) | Data testing method, storage medium and electronic device | |
CN115373981A (en) | OTA (over the air) automatic testing system and method for finished automobile in production line environment | |
CN113079061A (en) | Internet of things performance testing method and system | |
CN117407302A (en) | Automatic test method, system, equipment and storage medium for CAN communication | |
CN110597198B (en) | Quality control device, quality control system and quality control method for TFT substrate glass | |
CN104678292B (en) | A kind of complex programmable logic device (CPLD) test method and device | |
CN112543110A (en) | Network communication simulation method and system of mass power distribution automatic terminal | |
CN111475358A (en) | Automatic testing method and device for controller interface | |
CN116665748A (en) | Automatic test equipment for flash memory chip and test method thereof | |
CN115080389A (en) | Test system, method, equipment and storage medium for improving index statistical efficiency | |
CN112380121A (en) | Automatic testing method and system for Internet of things equipment | |
CN112860562A (en) | Automatic testing method and device | |
CN112561388A (en) | Information processing method, device and equipment based on Internet of things | |
CN104808599A (en) | Test process management and control system, method and apparatus for filters | |
CN115826521B (en) | Production process control method and device, electronic equipment and storage medium |
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 |