Customizable automatic unit method of testing and system under a kind of Linux platform
Technical field
The present invention relates to software automatic test field, be specifically related to customizable automatic unit under a kind of Linux platform and survey
Method for testing and system.
Background technology
In order to control software code quality, preferably evade the appearance of program error, it is however generally that need updating software
Before or after function code, the unit testing use-case corresponding to the written in code updated, perform list after the most more fresh code
Unit's test case, verification software the most correctly runs, thus evades the appearance of program error.Existing way is typically to monitor
After code update, the artificial unit testing use-case searching correspondence is also manually started performance element test;After unit testing terminates, people
Work point analysis test structure is the most all passed through.The method defect be can not customization units test case, need manually the most single
Unit's test case is searched, takes time and effort;Effective informing mechanism is lacked for test result, needs manually test result to be carried out
Analyze, find out unsanctioned unit testing.
Summary of the invention
For defect present in prior art, it is an object of the invention to provide under a kind of Linux platform customizable
Automatic unit method of testing and system, can automatically search unit testing use-case and test with performance element.
For reaching object above, the present invention adopts the technical scheme that: customizable automatic unit under a kind of Linux platform
Method of testing, obtains the configuration information in predefined configuration file, and described configuration information includes the literary composition needing to be monitored
Part or Folder Name, corresponding document or file are the need of carrying out unit testing and corresponding document or file is the most right
The mapping address of the unit testing use-case answered;The file or folder list needing to be monitored is obtained according to configuration information, real
Time monitor the modification information of file or folder in described list;After monitoring modification information, judge to occur according to configuration information
The file or folder of change is the need of carrying out unit testing, and the file or folder carrying out unit testing as required exists
The mapping address of unit testing use-case corresponding in configuration information is searched and acquiring unit test case, then with the unit obtained
Test case performs all to occur to change and need to carry out the unit testing of the file or folder of unit testing.
On the basis of technique scheme, comprise the following steps:
S1, obtains the configuration information in predefined configuration file;
S2, obtains the file or folder list needing to be monitored according to configuration information;
S3, monitors the modification information of file or folder in described list in real time;
According to configuration information, S4, after monitoring modification information, judges that the file or folder that change occurs is the need of entering
Row unit testing;If so, step S5 is entered;If it is not, be directly entered step S7;
S5, carries out file or folder unit testing use-case of correspondence in configuration information of unit testing as required
Mapping address is searched and acquiring unit test case;
S6, performs change all occurs and need to carry out the file or folder of unit testing with the unit testing use-case obtained
Unit testing;
S7, whole unit testings are finished, print result, terminate.
On the basis of technique scheme, described configuration file has been pre-defined by developer.
On the basis of technique scheme, described configuration information includes the file or folder name needing to be monitored
Title, corresponding document or file are the need of carrying out unit testing and corresponding document or each self-corresponding unit testing of file
The mapping address of use-case.
On the basis of technique scheme, described step S7 also includes:
S701, whole unit testings are finished, it may be judged whether all files or file pass through unit testing;If it is not,
Enter step S702;If so, step S703 it is directly entered;
S702, sends mail notification developer not by the file or folder result of unit testing;
S703, print result.
Present invention additionally comprises customizable automatic unit test system under a kind of Linux platform, including: real-time files monitors
Module, test case search module and unit testing performs module, wherein:
Described real-time files monitoring module for obtaining the file needing to be monitored according to predefined configuration information
Or Folder List;Monitor the modification information of file or folder described in described list in real time;Modification information is sent to institute
State test case and search module;
Described test case is searched module and is used for receiving after described real-time files monitoring module monitors modification information, root
Judge that the file or folder that change occurs, the need of carrying out unit testing, and carries out unit survey as required according to configuration information
The file or folder of examination is searched and acquiring unit test case at the mapping address of unit testing use-case corresponding to configuration information;
Described unit testing performs module for searching, with described test case, the unit testing use-case execution that module obtains
All there is to change and need to carry out the unit testing of the file or folder of unit testing.
On the basis of technique scheme, described configuration information includes the file or folder name needing to be monitored
Title, corresponding document or file are the need of carrying out unit testing and corresponding document or each self-corresponding unit testing of file
The mapping address of use-case.
On the basis of technique scheme, automatic unit test system also includes test result reporting module, described survey
Test result reporting module is for sending mail notification developer not by the file or folder result of unit testing.
Compared with prior art, it is an advantage of the current invention that:
1, whole unit testing process is without manual intervention, saves human cost, and real-time is high.
2, it is file and file customization units test case in advance, automatically searches according to the mapping address in configuration information
Corresponding unit testing use-case carries out unit testing.
3, automatically by the test result of the file or folder of unsanctioned unit testing with mail notification developer, make
Developer learns in time and repairs problem that may be present in code.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of customizable automatic unit method of testing under Linux platform in the embodiment of the present invention;
Fig. 2 is that in the embodiment of the present invention, under Linux platform, the flow process of customizable automatic unit method of testing step S7 is shown
It is intended to;
Fig. 3 is that in the embodiment of the present invention, under Linux platform, customizable automatic unit tests the structural representation of system.
In figure: 1-real-time files monitoring module, 2-test case searches module, and 3-unit testing performs module, and 4-tests
Result reporting module.
Detailed description of the invention
Below in conjunction with drawings and Examples, the present invention is described in further detail.
Shown in Figure 1, the embodiment of the present invention provides customizable automatic unit method of testing one under a kind of Linux platform
Plant customizable automatic unit method of testing under Linux platform, including: obtain the configuration letter in predefined configuration file
Breath, configuration file has been pre-defined by developer.File or folder title that configuration information includes needing being monitored,
Corresponding document or file are the need of carrying out unit testing and corresponding document or file each self-corresponding unit testing use
The mapping address of example;The file or folder list needing to be monitored, real-time watch-list Chinese is obtained according to configuration information
Part or the modification information of file;After monitoring modification information, judge to occur the file or folder of change according to configuration information
The need of carrying out unit testing, and carry out file or folder list of correspondence in configuration information of unit testing as required
The mapping address of unit's test case is searched and acquiring unit test case, then performs all to send out with the unit testing use-case obtained
Change more and the unit testing of file or folder of unit testing need to be carried out.
Comprise the following steps:
S1, obtains the configuration information in predefined configuration file;Configuration information includes the file needing to be monitored
Or Folder Name, corresponding document or file are the need of carrying out unit testing and corresponding document or file is the most corresponding
The mapping address of unit testing use-case.
S2, obtains the file or folder list needing to be monitored according to configuration information;
S3, the modification information of file or folder in real-time watch-list;
According to configuration information, S4, after monitoring modification information, judges that the file or folder that change occurs is the need of entering
Row unit testing;If so, step S5 is entered;If it is not, be directly entered step S7;Step S4 judging, whether file or folder needs
The criterion of unit testing to be carried out is: be set to need the file or folder carrying out unit testing be in configuration information
It is to enter step S5;It is no for being set to the file or folder without carrying out unit testing in configuration information, is directly entered step
S7。
S5, carries out file or folder unit testing use-case of correspondence in configuration information of unit testing as required
Mapping address is searched and acquiring unit test case;
S6, performs change all occurs and need to carry out the file or folder of unit testing with the unit testing use-case obtained
Unit testing;
S7, whole unit testings are finished, print result, terminate.
Shown in Figure 2, step S7 also includes:
S701, whole unit testings are finished, it may be judged whether all files or file pass through unit testing;If it is not,
Enter step S702;If so, step S703 it is directly entered;
S702, sends mail notification developer not by the file or folder result of unit testing;
S703, print result.
Shown in Figure 3, the invention also discloses customizable automatic unit test system, bag under a kind of Linux platform
Include: real-time files monitoring module 1, test case search module 2 and unit testing performs module 3, wherein: real-time files monitoring mould
Block 1 for obtaining the file or folder list needing to be monitored according to the configuration information in predefined configuration file;
The modification information of file or folder in watch-list in real time;Modification information is sent to test case lookup module 2;Test is used
Example is searched module 2 and is used for receiving after real-time files monitoring module 1 monitors modification information, judges to become according to configuration information
File or folder more is the need of carrying out unit testing, and the file or folder carrying out unit testing as required is being joined
The mapping address of the unit testing use-case that confidence breath is corresponding is searched and acquiring unit test case;Unit testing performs module 3 and uses
In searching unit testing use-case execution all generation changes that module 2 obtains and the file that unit testing need to be carried out with test case
Or the unit testing of file.Configuration information includes needing the file or folder title being monitored, the file or folder are
No needs carries out unit testing and the mapping address of each self-corresponding unit testing use-case of file or folder.Automatic unit is surveyed
Test system also includes that test result reporting module 4, test result reporting module 4 are used for sending mail notification developer and do not pass through
The file or folder result of unit testing.
The present invention is not limited to above-mentioned embodiment, for those skilled in the art, without departing from
On the premise of the principle of the invention, it is also possible to make some improvements and modifications, these improvements and modifications are also considered as the protection of the present invention
Within the scope of.The content not being described in detail in this specification belongs to prior art known to professional and technical personnel in the field.