Disclosure of Invention
In view of the above, the present invention provides an automatic test method and system for reader interface specification, which can quickly perform interface specification conformity test on a reader and solve the problems of large workload and difficulty in traversing all possibilities during the test.
In order to solve the technical problems, the invention adopts the technical scheme that:
an automatic test method and system for reader interface specification includes the steps: inputting a test function and a test rule for setting a test data input method, traversing an interface list containing all test functions according to the test rule, extracting a plurality of data interfaces in the interface list according to the test function and the test rule, acquiring all key parameters in the data interfaces and correspondingly outputting accurately, generating a plurality of groups of messages for testing a reader, and generating message data by combining all messages in one data interface;
step two: sequentially acquiring message data, sequentially inputting messages in the message data into a reader according to a test rule, and receiving feedback data of the reader;
step three: analyzing and comparing the feedback data with the accurate output, judging the accuracy and completeness of the functions of the reader interface, traversing all message data by using the same method, and counting and storing the test result.
Further, the interface list generating process: acquiring a message body type, a test rule of the message body, a key parameter in the message body and corresponding accurate output data in interface specification, and generating a plurality of data interfaces according to the message body type, the corresponding test rule, the key parameter and the accurate output data;
and generating an xml file according to the information in the data interface, extracting the interface information in the xml file and converting the interface information into a Python type, and generating an interface list which can be conveniently called based on the Python type.
Furthermore, the test rule and the key parameter of the message body type are set according to the requirements of national standard specifications.
Furthermore, the data interface comprises a plurality of test rules, and the test function corresponds to the plurality of test rules.
Further, the message body is composed of a plurality of parameters, the parameters correspond to a plurality of key parameters, and a parameter merging strategy is arranged in the test method;
the parameter merging strategy comprises the steps of obtaining all key parameters of the same message body type, superposing the key parameters of different types in the message body as much as possible to generate a test input, correspondingly merging and accurately outputting to generate a test output, and generating a message by combining the test input, the test output and a test rule.
Further, the message data includes a test rule, a plurality of test inputs and corresponding test outputs.
Further, the testing step comprises: receiving a test function and a test rule, calling a corresponding data interface in an interface list according to the test rule, judging whether the data interface is called or not, and if not, finishing the test, and if so, generating a plurality of message data;
and if not, returning to the step of calling the interface list, if so, sending and storing the message, otherwise, returning to the step of obtaining the message, if so, receiving and analyzing the feedback data and then giving an analysis result, and after storing the feedback data and the analysis result, continuously obtaining the message.
Furthermore, the test function corresponds to a plurality of test rules, and a plurality of test functions can be simultaneously input.
The system comprises a test unit, a test unit and a database, wherein the test unit is respectively connected with a reader to be tested, a WEB interface for inputting a test function and selecting a test rule and the database for storing data;
the test unit is internally provided with an interface generation module for generating a data interface, a message generation module for generating message data, a configuration issuing module for issuing the heat preservation data to a corresponding reader, a data receiving module for receiving the feedback data of the reader, a result analysis module for analyzing the feedback data, and a persistence module for persistently processing and storing the feedback data to a database.
Further, the number of readers connected with the test unit can be multiple.
The invention has the advantages and positive effects that:
all key parameters in the data interface, corresponding accurate output and test rules are obtained by selecting the corresponding data interface in the interface list according to the test function and the test rules, and all the key parameters are convenient to traverse during testing; generating a message by each key parameter, corresponding accurate output and test rule, and generating message data by combining all messages; the method comprises the steps of sequentially inputting messages into a reader according to a test rule, receiving feedback data of the reader, judging the accuracy and completeness of the functions of the reader interface according to the feedback data, rapidly testing the interface specification conformity of the reader without manual testing, and solving the problems of large workload and difficulty in traversing all possibilities during testing.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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.
It will be understood that when an element is referred to as being "secured to" another element, it can be directly on the other element or intervening elements may also be present. When a component is referred to as being "connected" to another component, it can be directly connected to the other component or intervening components may also be present. When a component is referred to as being "disposed on" another component, it can be directly on the other component or intervening components may also be present. The terms "vertical," "horizontal," "left," "right," and the like as used herein are for illustrative purposes only.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
The invention provides an automatic test method of reader interface specification, as shown in figure 1, a reader is used for reading and processing data, and in the test process, the method is mainly used for judging whether an interface of the reader can normally receive and process the data, according to the application interface specification of automotive electronic identification read-write equipment, the data transmitted by the reader comprises a message head and a message body, the composition of the message head is fixed, but the message body comprises a plurality of parameters, so that the types of the message body comprise more than 40, the types of the parameters comprise simple parameters, structural parameters and identifiers, and the number of the structural parameters is more than 120. And when the parameters are read and tested, each parameter corresponds to a set key parameter.
Therefore, data in the specification of the application interface of the electronic identification reading and writing equipment of the motor vehicle are read, the test rules of all message bodies at the position and key parameters corresponding to the parameters are extracted, and an xml file is generated. Inputting the mode and step of reader and receiving mode when the test rule is the message body test; the key parameters are used for detecting whether the data interface can normally identify data and outputting the read data according to the standard, and the test rule and the key parameters are set according to the requirements of national standard standards.
The xml files are grouped according to the types of the message bodies, and each group comprises the test rules of the message bodies, the key parameters including all the parameters and the corresponding accurate output. Extracting all groups of the xml file to generate a plurality of data interfaces (each group is a data interface), extracting information in the data interfaces in the xml file and converting the information into a Python class, generating an interface list which is convenient to call according to the Python class, and storing the interface list into a database. When the reader is tested, different data interfaces can be conveniently and automatically called according to the test function (different message body types used by different functions are different, and the called data interfaces are also different).
Each message body type can correspond to a plurality of test functions, and different test functions correspond to different test rules. For example: the identification function is whether the reader can identify the message or not, and the access function is whether the reader can access the parameters at the fixed position in the message or not.
Therefore, when the reader is tested, the reader is connected with the testing equipment, the function to be tested is input into the testing equipment, the testing device traverses all interface information in the interface list according to the received testing function, extracts all information in the data interface meeting the testing function according to the testing rule corresponding to the testing function, generates a plurality of messages, and generates message data for testing the function by combining all messages meeting the function.
Each parameter corresponds to a plurality of fixed key parameters, and each message body can contain a large number of square parameters, so that the key parameters to be tested in one message are too large. The reader is used for transmission and data processing, and each time the reader tests one function, all the key parameters included in the message body need to be tested once, so that a large amount of time is spent, and the research and development period is increased.
In order to shorten the detection time, a parameter merging strategy is arranged in the test equipment. The merging strategy is used for merging the key parameters corresponding to a plurality of different parameters into one test parameter, so that the number of the test parameters in the message is reduced, the test time of the reader is shortened, all the key parameters are ensured to be detected, and the test accuracy is not influenced.
The merging mode is as follows: and extracting information in the interface information, wherein the information comprises key parameters and test rules of all the parameters, and each key parameter can be uniquely and correspondingly accurately output according to different test rules. According to the type of the message body, different types of key parameters are superposed in the message body as much as possible to generate a test input, and meanwhile, the test input is correspondingly combined and accurately output to generate a test output. And generating a message by testing input, testing output and testing rules, combining other key parameters by using the same method to generate a message, and generating message data by combining all messages in a message body. Thus, a function includes multiple message data, and each message data includes a combination of all key parameters.
The test device generates a plurality of message data according to the functions, selects the message data, sequentially inputs the messages in the message data into the reader according to the test rules, and the test equipment receives and stores the feedback data given by the reader and compares the feedback data with the test output for judging whether the interface is accurate and complete. Example (c): whether the reader deletes the character at the input data setting position or not is judged, and whether the reader can realize the function of deleting the character or not is judged.
The testing steps of the testing device comprise: the test function is received, the test rule is selected according to the test function (the same test function can comprise a plurality of test rules), the test function corresponds to a plurality of test rules, a plurality of test functions can be simultaneously input, and the simultaneous test of a plurality of functions of the reader is facilitated. Acquiring an interface list according to the test rule, calling a corresponding data interface, judging whether the corresponding data interface is called in the interface list, if not, finishing the test, and if so, generating a plurality of message data according to the test rule;
obtaining a message, judging whether the message is obtained or not, returning to the step of calling a corresponding data interface if the message is obtained, issuing and storing the message, judging whether the issuing is successful or not, returning to the step of judging whether the message is obtained or not, receiving feedback data of a reader, comparing and analyzing the feedback data with test output, storing the feedback data and an analysis result, and then continuing to obtain the message. And traversing all message data by using the same method, and storing the test result to finish the test of the reader.
As shown in fig. 2, the automated testing system according to the above testing method: the device comprises readers to be detected, the number of the readers can be one or more, and the simultaneous detection of the same function of the readers is facilitated. The reader is connected with a test unit for data intercommunication with the data unit, the test unit inputs the message into the reader according to the test rule, and the reader inputs the feedback data into the test unit. Preferably, the test unit is in data communication with the reader via a data receiver, the data receiver being adapted to receive the feedback data.
The test unit is connected with a WEB interface, test contents can be input into the test unit through the WEB interface, and the test contents comprise a test function and a test rule. The test unit is also connected with a database for storing test data, the test data comprises test function data, messages, feedback data output by the reader and analysis results of interface functions, and all data generated in the transmission process of each message can be conveniently checked subsequently.
The testing unit is internally provided with an interface generating module, a message generating module, a configuration issuing module, a data receiving module, a result analyzing module and a persistence module, wherein the interface generating module is used for generating a data interface according to data in the input 'motor vehicle electronic identification read-write equipment application interface specification'; the message generation module is used for calling data in the data interface according to the test content and generating message data for testing; the configuration issuing module is used for issuing the message sequence to the corresponding reader according to the test rule; the data receiving module is used for receiving feedback data output by the reader and transmitting the feedback data to the result analysis module, the result analysis module is used for comparing and backwashing the feedback data and the corresponding test output in the message and giving an analysis result, and the persistence module is used for persistently processing the feedback data and storing the feedback data in the database.
The embodiments of the present invention have been described in detail, but the description is only for the preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. All equivalent changes and modifications made within the scope of the present invention should be covered by the present patent.