Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of function test method and test macro to electronic product with keyboard, makes and can avoid manual test repeatedly to the functional test of electronic product with keyboard, improves detection efficiency.
Second goal of the invention of the present invention is to have realized the various ways output of test result.
Realize the method for testing of the function to electronic product with keyboard of the present invention, need following steps:
A, write and comprise the test file of testing expression formula, the described test file of testing expression formula that comprises is the file of writing according to predetermined format that is used for tested electronic product is carried out functional test;
B, the test file of writing is translated as a series of button port coordinate;
C, press/lift signal according to what button port coordinate was simulated tested electronic product respective keys;
D, the signal of pressing/lift by tested electronic product respective keys drive the operation of tested electronic product;
The operation result of E, the tested electronic product of acquisition is by comparing the function operation conditions of judging tested electronic product with expected results; Wherein said expected results is meant the operation result of the tested electronic product as a reference of storage in advance.
Wherein, between steps A, B, further comprise step: A1, call corresponding keyboard definition tabulation and with syntax rule the test file of writing carried out grammer and detect.
Wherein, steps A is described writes and comprises the test file of testing expression formula and comprise step: set in advance a dummy keyboard, the dummy keyboard key codes of pushbuttons clicked as character string, and is write test file with this character string according to predetermined form.
Wherein, described step D further comprises step: in driving the measurand operational process, test file and expected results are exported with voice, image or mode word.
Wherein, this method further comprises: the operation result of the tested electronic product that will obtain is converted into the operation result of discernible form as tested electronic product.
Wherein, described step e further comprises: the corresponding preservation with expected results of the function operation conditions of the operation result of the tested electronic product that will obtain and the tested electronic product of judging.
The function operation conditions of the tested electronic product that wherein, further comprise step: F after the described step e, will judge is with voice, image or mode word output.
A kind of test macro that electronic product with keyboard is carried out functional test of the present invention, comprise: translation unit, be used for to be written into test macro and comprise the test file of testing expression formula and translate into a series of button port coordinate, send to the button analogue unit successively; The button analogue unit, according to receiving the button port coordinate that translation unit sends, what simulate tested electronic product respective keys presses/lifts signal to drive tested electronic product operation; The operation result capturing unit is used for catching the operation result of tested electronic product, and sends to the interpretation of result unit; The interpretation of result unit is used for receiving the operation result of operation result capturing unit transmission and analyzing, and judges the function operation conditions of tested electronic product.
Wherein, this test macro further comprises: the grammer detecting unit be used for comprising the test file of testing expression formula and carrying out grammer and detect being written into test macro, and the test file after will detecting sends to translation unit.
Wherein, described translation unit is arranged in the computing machine, and a series of button port coordinate after translation unit will be translated by the input/output end port of computing machine sends to the button analogue unit successively.
Wherein, described grammer detecting unit, operation result capturing unit and interpretation of result unit are arranged in the computing machine at translation unit place, and the operation result capturing unit is caught the operation result of tested electronic product by the input/output end port of computing machine.
By said method as can be seen, the present invention can be written into test macro with the test file that writes in advance, button input by test macro simulation measurand, and the operation result of measurand caught automatically and store, compare with expected results, show the operation test result, analyze, draw the conclusion that measurand is detected.
Use the present invention, the button that does not need the tester to operate tested electronic product pursues the key input, has effectively reduced the operation of keystroke repeatedly of manual test, has improved the testing efficiency to the keyboard type electronic product.Since test macro can analogue-key the keystroke signal, therefore when keyboard device is still unassembled, also can test electronic product.
And, use the present invention also can realize the catching automatically of measurand operation result judged the measurand operation conditions automatically, do not need artificial judgment.In addition, also can realize using multiple modes such as voice, text, image to export, and when detecting the measurand problem, give the tester with prompting to output content and operation result.In addition, the present invention can be carried out the progress of voice broadcast service test by test macro in each step, be convenient to the tester and control testing progress.Set up test library by the accumulation test file in addition, can progressively realize generalization and the systematization tested.
Test macro of the present invention can be applicable to the field tests to any band physical keyboard or dummy keyboard (as touch-screen) electronic product, as test electronic dictionary, counter, databank, PDA, e-book and mellotron etc.
Embodiment
The invention provides a kind of test macro, be used for the electronic product of band keyboard is carried out functional test.Fig. 1 is a test macro synoptic diagram of the present invention.As shown in Figure 1, test macro of the present invention comprises grammer detecting unit, translation unit, button analogue unit, operation result capturing unit and interpretation of result unit.
Wherein, grammer detecting unit syntax format by appointment carries out the grammer detection to the test file that is written into test macro.Translation unit detects errorless test file with the grammer detecting unit and translates into a series of button port coordinate, and sends to the button analogue unit successively.The button analogue unit receives button port coordinate, decodes and exports corresponding signal, and the signal of pressing/lift that simulates the measurand respective keys is exported to measurand.After measurand obtains the signal of button analogue unit output, operation and generating run object information.The operation result file of corresponding format is caught and be converted to operation result information by capturing unit as a result, sends to the interpretation of result unit.The interpretation of result unit compares analysis with expected results file and the operation result file of being caught, and analysis result is exported to the user.
Fig. 2 is for realizing the another one embodiment of test macro of the present invention.Test macro is made up of a computing machine and a button analogue unit of comprising grammer detecting unit, translation unit, operation result capturing unit and interpretation of result unit, wherein, computing machine links to each other with the button analogue unit by input and output (I/O) interface, and the button analogue unit links to each other with the input interface of measurand by the I/O interface.Wherein, described button analogue unit is the keyboard mimic channel, and wherein the present invention adopts MT8816, and the I/O interface of described computing machine and button analogue unit can be parallel port, serial ports, USB interface etc.Wherein said grammer detecting unit, translation unit, operation result capturing unit and interpretation of result unit are realized by software.Wherein, when the button analogue unit was MT8816, as shown in Figure 2, the input port of button analogue unit was an Address Line port, and output port is the Output port.
Wherein, the grammer detecting unit syntax format by appointment that computing machine provides carries out grammer to the test file that is written into computing machine and detects processing, translation unit detects errorless test file with the grammer detecting unit and translates into a series of button port coordinate then, and send to the input port of button analogue unit successively by the I/O interface that computing machine links to each other with the button analogue unit, the button port coordinate that button analogue unit receiving computer sends, the corresponding signal of decoding output, what promptly simulate the measurand respective keys presses/lifts signal, measurand obtains by the I/O mouth, after measurand obtains the signal of button analogue unit output, operation and generating run object information.Corresponding operation result file caught and be converted to operation result information by Computer I/O interface from the corresponding interface of measurand by the capturing unit as a result of computing machine, sends to the interpretation of result unit.The interpretation of result unit compares analysis with expected results file and the operation result file of being caught, and analysis result is exported to the user.
Fig. 3 is to the process flow diagram of electronic product with keyboard test, below with reference to Fig. 3, method of testing of the present invention is elaborated:
Step 301: write in advance and be used for test expression formula that tested electronic product is detected, and save as test file (Test Pattern).
The test expression formula here is meant the specific code that is used for testing electronic product.The test expression formula can have multiple, comprises at the test expression formula of arithmetical operation, logical operation etc.The concrete test expression formula of how writing is decided according to the electronic product that will detect and the function that will detect.For example, for the counter test, can write arithmetical operation and express formula, as " 1+1="; And for example, then can write the logical operation expression formula, perhaps express the combination etc. of formula with arithmetical operation for the functional test of electronic products such as mobile phone, PDA, electronic dictionary; Mellotron for example again, the expression formula of writing can be the burst of output.Wherein, the input mode that test file is write can adopt multiple mode, as the keyboard input by test macro, phonetic entry etc.
Wherein, form that can the pre-defined test file of writing, for example in the test expression formula of regulation input, with a specific character, represent the ending of a character string as the space, like this, formula is split in the process of series of characters string at subsequent step, the grammer detecting unit can be discerned and split the character string in the expression formula easily.For example " SIN (2+3)=" should the test expression formula be " SIN (2+3)=" then according to this routine described form input, and wherein underscore is represented the space.
In addition, also can copy the keyboard arrangement of test product, a dummy keyboard is set on test macro, make the user can use the button of dummy keyboard intuitively like that according to the keyboard that uses measurand.Test macro then on the backstage by catching the dummy keyboard key codes of pushbuttons (Keycode) that the user clicks, and generate corresponding test expression formula in conjunction with employed test file form.For example, test macro whenever detects pressing of dummy keyboard button, then catches the Keycode of this virtual key correspondence, adds a space automatically simultaneously behind its Keycode, writes test file successively.Like this, click dummy keyboard by the user, test macro is the corresponding test expression formula that meets call format that generates on the backstage just.As can be seen, by the dummy keyboard input, the user has been shielded the form preparation request of testing expression formula, it is more convenient to make the user write test file.
Can test multiple electronic product more easily in order to make test macro, and the multiple function of every kind of electronic product, can be at different types of measurand, and the difference in functionality of measurand, write abundant test expression formula, and classified and stored is in different test files, and as test library, the test after being provided with is directly called.
Whether consistent in order to realize that test macro can detect the output result of measurand automatically with expected results, also to define the expected results file and store expected results, be used for comparing check at the operation result of subsequent step and measurand.Expected results is meant the correct result of the desired measurand output that obtains.Wherein, the form of destination file can be set further, and carry out corresponding stored with corresponding test file.Can certainly be stored in the same file with test file, distinguish out expected results and test expression formula with certain sign.Expected results can be caught the operation result of a measurand as a reference as expected results in advance by test macro.Can certainly be by manual input.For example, for the test expression formula of last example " 1_+_1_=_ ", can import by hand in the expected results file that " 2 " be stored in this expression formula correspondence.
Step 302: according to measurand, with write or specified test file imports test macro, call corresponding keyboard definition tabulation (Keymap) and syntax rule is carried out the grammer detection to test file by the grammer detecting unit.The grammer here detects and is meant the test expression formula in the test file is split as one by one character string according to predefined syntax rule, and whether retrieval exists these character strings in the Keymap of measurand table.
Keymap is meant the corresponding relation tabulation of button port coordinate (Scancode) and key (Keycode), in the present invention, Keymap is used for representing the corresponding relation of the Input Address (Address) and the measurand key codes of pushbuttons that output signal is simulated of translation unit.Referring to Fig. 2, be that example further specifies with MT8816 as translation unit, Scancode is the Input Address (Address) of MT8816, and Keycode is the key corresponding to the respective keys of measurand.Different measurand and by the employed Keymap difference of brake, therefore, Keymap need set in advance and storage respectively.
The grammer detecting unit at first extracts successively from test file and separates each bar test expression formula, then each expression formula syntax rule is by appointment discerned, is split, and is converted to a series of character string.For example, the test file form given according to step 301, can define syntax rule is: the space as the end of a last character string and the beginning of character late string, according to this syntax rule, can be converted to a series of character string with the test expression formula easily.For example, current test expression formula be " SIN_ (_ 2_+_3_) _=_ ", wherein underscore is represented the space, is converted to " SIN ", " (", " 2 ", "+", " 3 ", ") " and "=" 7 character strings successively according to this syntax rule.
Whether the grammer detecting unit also detects each character string and appears among the Keymap at measurand, if do not have, then contain the character string that in the key row of Keymap, does not occur in the expression test expression formula, this character string can't be converted to Scancode according to Keymap, think this test expression formula grammar mistake, for example test expression formula for " SIN_ (_ 2+_3_) _=_ " time, " 2+ " character string of not having in the key row of Keymap appears in formula, then think grammar mistake, the prompting test man carries out corresponding modify to test file; If in the key row of Keymap, retrieve current string, then carry out the judgement of character late string, up to the grammer detection end of whole test file.
Step 303: after grammer detecting unit detection test file is errorless, by the test file after the translation unit execution detection, translation unit is translated as a series of Scancode with test file according to corresponding Keymap, be the Input Address (Address) of button analogue unit, send to the button analogue unit.
Referring to MT8816 synoptic diagram shown in Figure 2, and the Keymap that is shown in Table 1 of ginseng, is that example describes with MT8816 as the button analogue unit, and it is the input Address of MT8816 that the grammer detecting unit will be tested the Scancode that expression formula is translated as one by one, exports to the MT8816 circuit board successively.For example, translation unit at first separates each bar test expression formula according to described the extraction successively of step 302 from test file, then each expression formula syntax rule is by appointment discerned, split, be converted to the method for a series of character string, the expression formula in the test file is converted to a series of character string.According to Keymap character string is translated into Scancode then.As, a series of character strings " SIN " " (" " 2 " "+" " 3 " ") " "=" are translated into a series of Scancode:0001001 0,100,000 0,010,010 0,001,011 0,010,011 0,100,001 0001111 successively according to the Keymap shown in the table 1, and promptly the input Address of MT8816 sends MT8816 to.Low four bit representation x coordinates of Scancode wherein, the Ax0 that corresponds to Address are to Ax3, Senior Three bit representation y coordinate, and the Ay0 that corresponds to Address is to Ay2.
Scancode |
Keycode |
001 0000 |
0 |
000 1001 |
SIN |
000 1010 |
COS |
000 1011 |
+ |
000 1111 |
= |
001 0001 |
1 |
001 0010 |
2 |
001 0011 |
3 |
...... |
...... |
010 0000 |
( |
010 0001 |
) |
Table 1
Step 304: the button analogue unit receives Scancode information, after being Address information, by the decoding of button analogue unit, from its output port (Output), the signal of pressing/lift of the measurand keyboard respective keys that simulates is exported to measurand, drive measurand work.
Step 305: measurand obtains the keyboard of button analogue unit output and presses/lift signal, just look like to be that to receive the pressing of self keyboard/lift signal the same, input according to the different key that is received, carry out corresponding sequential operation and go out operation result, and be shown to the user by the display mode of this measurand, as by liquid crystal display demonstration etc.
At this moment, the test man just can go to judge the ruuning situation of measurand by comparing the shown operation result of measurand and predicting the outcome, and finishes the detection to measurand.In addition, can continue to carry out following steps, finish detection automatically measurand by test macro.
Step 306: the operation result capturing unit of test macro is caught the operation result of measurand, and is converted into the destination file that test macro is discerned, and sends to the interpretation of result unit.
Test macro obtains the memory address that measurand is used for the storage running result in advance, the operation result capturing unit scans and reads data in the internal memory to this memory address of measurand automatically, be the operation result of measurand, and be converted into the form that test macro is discerned.
Because the operation result of measurand can be any form of expression, as character, text, image, sound etc.The mode of therefore catching the measurand operation result is also relevant with the product of test, is not limited to the above method.For example, for the measurand that operation result is stored in the internal memory, can be as above routine described, read the operation result data from the memory address of measurand appointment.And for example, when being mellotron for measurand, after the tested mellotron work of driving is sounding, then the operation result capturing unit can be caught the measurand operation result by sound collection, then sound is converted into the discernible file of test macro, as wave file or further digitized file.
Step 307: the interpretation of result unit compares operation result file and the expected results file that step 306 passed over, and detects the correctness of measurand operation result, judges the ruuning situation of measurand.
After catching the operation result of measurand, test macro compares detection with itself and expected results, and relatively testing result and corresponding expected results can be exported to the user in real time, and the way of output comprises modes such as voice, image, literal.And, point out the user in modes such as voice, image or literal detecting operation result file and expected results file when inconsistent, and be convenient to the user to control test process, when going wrong, can interrupt current test at any time.In addition, the testing result of operation result file and interpretation of result unit is all carried out corresponding preservation with the expected results file, is convenient to later inquiry of test man and analysis.
And test macro can be given the test man to broadcast in real time with voice, image or mode word with the process of operation, is convenient to the test man and grasps testing progress.For example, in driving the measurand operational process, test file and expected results are exported with voice, image or mode word.
Above embodiment has shown from beginning to write test file and has caught the process that the measurand operation result detects automatically to test macro.As can be seen, after writing test file, later on this test file is directly called in the test of corresponding product and get final product, and do not need the input repeatedly mentioned in the background technology.After the test file that has accumulated some is as test library, can realize generalization and the systematization tested in addition.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.