The content of the invention
The embodiment of the present application provides a kind of automated testing method and device, to solve daily record clothes are verified in prior art
The log content of the business device record whether relatively low problem of correct accuracy.
The embodiment of the present application provides a kind of automated testing method, including:
Obtain journal file to be matched;
The field included in the journal file is extracted by ordering;
Each field to extracting carries out matching check;
According to matching result, the test result of automatic test is determined.
Preferably, the service request for including default parameter is sent, the corresponding journal file of service request is obtained, this obtains
The journal file got is journal file to be matched.
Preferably, the corresponding a line daily record of the service request included in the journal file is extracted by sed orders
Content, according to default field isolation symbol, extracts to the field in the corresponding a line log content of the service request.
Preferably, by including in the sed orders extraction journal file except in the corresponding daily record of the service request
N row log contents beyond appearance, wherein, the N is positive integer, according to default field isolation symbol, in the N rows daily record
Field in appearance is extracted.
Preferably, each field to extracting carries out versatility matching respectively, to extracting comprising specific fields name
Field contents carry out uniformity matching.
Preferably, each field to extracting carries out versatility matching respectively.
Preferably, determine the field name of the field, corresponding matching process is obtained according to the field name, according to the correspondence
Matching process process the content of the field, determine whether the field meets versatility.
Preferably, the corresponding matching process is to process the field using built-in function and/or regular expression
Content.
The embodiment of the present application provides a kind of automatic test device, including:
Acquisition module, for obtaining journal file to be matched;
Extraction module, for by ordering the field included in the extraction journal file;
Module is checked, matching check is carried out for each field to extracting;
Test result determining module, for according to matching result, determining the test result of automatic test.
Preferably, the acquisition module is specifically for transmission includes the service request of default parameter, and obtaining business please
Corresponding journal file is sought, the journal file for getting is journal file to be matched.
Preferably, the extraction module is specifically for extracting the industry included in the journal file by sed orders
The corresponding a line log content of business request, according to default field isolation symbol, to the corresponding a line daily record of the service request
Field in content is extracted.
Preferably, the extraction module is specifically for by including in the sed orders extraction journal file except described
N row log contents beyond the corresponding log content of service request, wherein, the N is positive integer, according to default field isolation
Symbol, extracts to the field in the N rows log content.
Preferably, the inspection module is specifically for each field to extracting carries out versatility matching respectively, to carrying
The field contents comprising specific fields name for taking out carry out uniformity matching.
Preferably, the inspection module is specifically for each field to extracting carries out versatility matching respectively.
Preferably, the inspection module is specifically for determining the field name of the field, obtaining corresponding according to the field name
Matching process, processes the content of the field according to the corresponding matching process, determines whether the field meets versatility.
Preferably, the corresponding matching process is to process the field using built-in function and/or regular expression
Content.
The embodiment of the present application provides a kind of automated testing method and device, and the method obtains daily record text to be matched first
Part, extracts the field included in the journal file by ordering, and each field to extracting carries out matching check, according to matching
As a result, determine the test result of automatic test.By said method, can to journal file in all fields examine
Look into, effectively raise the whether correct accuracy of log content of checking log server record.
Specific embodiment
To make purpose, technical scheme and the advantage of the application clearer, below in conjunction with the application specific embodiment and
Corresponding accompanying drawing is clearly and completely described to technical scheme.Obviously, described embodiment is only the application one
Section Example, rather than the embodiment of whole.Based on the embodiment in the application, those of ordinary skill in the art are not doing
The every other embodiment obtained under the premise of going out creative work, belongs to the scope of the application protection.
The automatic test course that Fig. 1 is provided for the embodiment of the present application, specifically includes following steps:
S101:Obtain journal file to be matched.
In actual applications, in order to know the ruuning situation of service server, and also to service server exists
The reason for going wrong is able to know that when going wrong in running, therefore, service server is usual during operation
Journal file can be produced, operation shape that can be with different fields come record traffic server during operation in journal file
Condition, e.g., service server can record the request corresponding response time by journal file when the request that user sends is processed
Deng.
In order to reduce the operating pressure of service server, a log server generally can be all used alone and carrys out record traffic
Journal file of the server produced by during operation, specifically, the log content for needing record is sent out by service server
Log server is given, the log content of the needs record for receiving recorded in journal file and store by log server.
Further, in order to whether the log content for verifying log server record is correct, need to log server institute
The log content of record is verified.
And during verifying whether the log content of log server record correct, it is necessary first to obtain day to be matched
Will file, obtains journal file to be matched and is completed by terminal.
Further, due to needing to obtain journal file to be matched, therefore, in this application, need generation to be matched
Journal file, and obtain the journal file to be matched of generation.
The application gives a kind of method for generating journal file to be matched, can be directed to the request scene for needing simulation,
Such as, analog subscriber browses the scene of the video of certain webpage, to parameter (e.g., ID, video ID, service in service request
Device IP address) it is configured, by parameter setting into the corresponding real data of the scene, and the service request after setting is sent
To service server, service server processes the service request, and the service request corresponding log content to be recorded is sent out
Log server is given, log server records the service request corresponding log content to be recorded in journal file.
In addition, the test in order to carry out automation, the request and also to aspect is activated business, and business can be increased
The multiplexing of corresponding code is asked, the workload of the corresponding code of artificial exploitation service request is reduced, therefore, in this application,
The parameter for needing to be configured ability simulation of real scenes in service request can be listed using the mode of dictionary, wherein, dictionary
Middle stored content is storing, it is, real scene and each parameter are set up mapping in the form of key-value
Relation, e.g., the video (that is, real scene) browsed in certain website is closed with the IP address and video ID foundation mapping of the website
System, subsequently, it is desirable to which real scene simulated, if the corresponding each parameter of the scene is inquired from dictionary, and according to each ginseng
Array dresses up service request.
To sum up, in this application, obtain the process of journal file to be matched, it is necessary first to which transmission includes default ginseng
To service server, service server processes the service request to several service requests, and will be the service request corresponding to be recorded
Log content be sent to log server, the service request corresponding log content record to be recorded is existed by log server
In journal file, terminal is obtaining the corresponding journal file of the service request from log server, the daily record text that this gets
Part is journal file to be matched.
S102:The field included in the journal file is extracted by ordering.
As the log content in journal file is made up of different fields, each field can record different
Interior perhaps data, if the log content of log server record is correct, the content recorded in each field then can
With desired content be it is consistent, therefore, in this application, it is determined that content and desired content recorded in each field
Before whether consistent, need from the journal file to be matched for obtaining to extract the field included in the journal file.
As the service request for receiving corresponding log content to be recorded recorded daily record text by log server
When in part, it is log content to be recorded to be recorded in fields different in a row, therefore, in this application, extracting day
During the field included in will file, the service request corresponding a line day for including can be extracted by sed orders in journal file
Will content.
Here is it should be noted that can according to actual needs in advance to extracting which log content pair in sed orders
The parameter answered is configured, by arranging the parameter, sed orders can corresponding that a line of extracting directly parameter log content,
It is of course also possible to extract N row log contents, which extracts and is mainly determined according to the parameter in sed orders.
Further, due to journal file in before and after be by the spy comprising field isolation symbol between adjacent field
Different field (e.g., representing the field of whippletree content) come what is be separated, therefore, the business included in journal file is extracted please
After seeking corresponding a line log content, can be by the special field comprising field isolation symbol come in a line daily record to extracting
Appearance is split and is extracted, that is to say, that according to default field isolation symbol, in the corresponding a line daily record of the service request
Field in appearance is extracted.
Further, since there may exist be not special field field also can include field isolation symbol situation,
The mode for so carrying out splitting field according to field isolation symbol can be so that be that the field of an entirety is partitioned from itself, this meeting
So that subsequently carry out mistake occur when matching check, therefore, in this application, to the corresponding a line daily record of the service request
After field in content is extracted, needs judge whether the quantity of the field for extracting is identical with the quantity of default field,
If identical, execution step S103.
S103:Each field to extracting carries out matching check.
After the field included in journal file to be matched is extracted by order, each field for extracting can be entered
Row matching check.
And during matching check is carried out to each field, as some fields are without needing to know institute in the field
Comprising particular content, it is only necessary to numeral or letter, or spcial character etc. whether are should be in knowing the log content, therefore, it is right
Only need to carry out versatility matching in these fields, i.e. require no knowledge about the particular content included in field, and some
Field needs to know whether the particular content included in field is consistent with desired log content, e.g., comprising the ginseng in request
Several fields needs to know whether whether the parameter in the request included in the field consistent with the parameter in desired request,
Therefore, for these fields only need to carry out uniformity matching.
In addition, although some fields need to know whether particular content is consistent with desired log content, but if should
It is where should be letter in itself in particular content included in field, directly with into numeral, so concrete in the field
Content affirmative is inconsistent with desired log content, in this application, can first carry out versatility matching to the field, then carry out one
The matching of cause property, because versatility matching can more save computer resource than uniformity matching, carries out uniformity matching if desired
Field it is just incorrect when versatility is matched, then without carrying out again carrying out uniformity to the field have matched, so can be with
Save the resource of computer.
To sum up, during each field to extracting carries out matching check, each field to extracting is entered respectively
Row versatility is matched, then the field contents comprising specific fields name to extracting carry out uniformity matching.
Here it should be noted that need which field to carry out uniformity matching to, is according to the specific word for pre-building
Section name is determined, that is to say, that according to the specific fields name for pre-building, extracts those words comprising specific fields name
Section, and uniformity matching is carried out to the field.
In addition, during test, log server be can record business that different business server sends over please
Ask, that is to say, that, it is understood that there may be except including in S101 by simulating structure in the journal file to be matched in step S101
Into the corresponding log content of service request, the situation also comprising the corresponding log content of other service requests, test mistake
Cheng Zhong, it is also desirable to which matching check is carried out to the corresponding log content of other service requests.
Before matching check being carried out to the corresponding log content of other service requests, need to extract by sed orders and be somebody's turn to do
The N row log contents in addition to the corresponding log content of the service request included in journal file, wherein, the N is just whole
Number, that is to say, that be the corresponding N rows log content of other service requests, according to default field isolation symbol, to what is extracted
Field in N row log contents is extracted.
Further, as, during test, other service requests are constructed by way of step S101
Out, that is to say, that, in this case it is not apparent that the corresponding expectation content of the field for carrying out uniformity matching is needed, therefore, in the application
In, for the corresponding log content of other service requests, versatility matching is carried out respectively to each field to extracting directly.
In addition, in this application, its corresponding matching process can be set up for each field name in advance, it is, building
The mapping relations of the corresponding matching process of field name are erected, the matching process simply carries out versatility matching when institute to field
Using matching process, subsequently, the application each field to extracting carry out respectively versatility match when, it may be determined that the word
The field name of section, obtains corresponding matching process according to the field name, according in the corresponding matching process process field
Hold, determine whether the field meets versatility, accordingly even when the matching process of certain field changes, or increase reduces certain
The matching process of individual field, can effectively modify and extend.
It should be noted that in this application, the matching process of same field name is identical to here, can so be caused
Code reuse is strong.
Further, as versatility matching simply carries out digital scope, character position to the content included in field
Deng matching, therefore, in this application, matching process is to process the interior of the field using built-in function and/or regular expression
Hold.
For built-in function, if only needing to judge whether the content in the field is all numeric type, can be used
Built-in function " isdigit () ", the built-in function represent whether content is all numeric type;If only needing to judge the field
In content whether be all letter type, then can use built-in function " isalpha () ", the built-in function represents that content is
No is all letter type;Judge whether the content in the field is all numeric type or letter type, then can make if desired
With built-in function " isalnum () ", the built-in function represents whether content is all numeric type or letter type.
If necessary to judge whether the content in field can use canonical table comprising additional character or digital scope etc.
The content of the field is processed up to formula, for example, it is assumed that server ip address using regular expression " ^ ((2 [0-4] d | 25 [0-
5]|[01]\d\d)\.){3}(2[0-4]\d|25[0-5]|[01]\d\d) $ " and come the entitled IP of processing field field it is interior
Hold, wherein, what " ^ " was represented is the beginning of character string, and " 2 " represent numeral 2, and " [0-4] " represents any one in interval [0-4]
Integer, " d " represent numerical character, and " | " represents or, " 25 " represent numeral 25, and " [0-5] " represents any one in interval [0-5]
Individual integer, " [01]" represent can be 0 or 1, it is also possible to there is no any character, " d" represent it can is Any Digit word
Symbol, it is also possible to there is no any character, “. " point is represented, twice, " " represents word to " { 3 } " expression one group of character repetition above
Symbol string ending, that is to say, that the server ip address represented by above-mentioned regular expression should for " [0~255]. [0~
255]. [0~255]. [0~255] ", it is assumed that the content of the field comprising server ip for extracting is:178.12.124.2,
178.12.124.2 it is located at [0~255]. [0~255]. [0~255]. within [0~255], then the field meets versatility.
S104:According to matching result, the test result of automatic test is determined.
In this application, if the content of each field extracted from journal file to be matched in step S103 is equal
Matching is correct, then automatic test success, also illustrates that the log content of log server record is correct, log server
Work well, if the content of each field extracted from journal file to be matched in step S103 has matching and differs
Cause.Then automatic test failure, also illustrates the log content existing problems of log server record, and log server does not just operate
Often.
By said method, can to journal file in all fields check, effectively raise checking daily record
The whether correct accuracy of the log content of server record.
In addition, the type of journal file typically has various, and the field in each Log Types is different, at this
In application, each Log Types is designed to a class, and its field is designed as the attribute of class, and by the type of service request and day
Will type is mapped, can the corresponding daily record class of instantiation by service request.
The automated testing method for providing for the embodiment of the present application above, based on same thinking, the embodiment of the present application is also
A kind of automatic test device is provided.
As shown in Fig. 2 a kind of automatic test device that the embodiment of the present application is provided, including:
Acquisition module 201, for obtaining journal file to be matched;
Extraction module 202, for by ordering the field included in the extraction journal file;
Module 203 is checked, matching check is carried out for each field to extracting;
Test result determining module 204, for according to matching result, determining the test result of automatic test.
The acquisition module 201 is specifically for transmission includes the service request of default parameter, obtains service request pair
The journal file answered, the journal file for getting are journal file to be matched.
The extraction module 202 is specifically for extracting the business included in the journal file by sed orders please
Corresponding a line log content is sought, according to default field isolation symbol, to the corresponding a line log content of the service request
In field extracted.
The extraction module 202 is specifically for by including in the sed orders extraction journal file except the business
The N row log contents beyond corresponding log content are asked, wherein, the N is positive integer, according to default field seperator
Number, the field in the N rows log content is extracted.
The inspection module 203 is specifically for each field to extracting carries out versatility matching respectively, to extracting
The field contents comprising specific fields name carry out uniformity matching.
The inspection module 203 is specifically for each field to extracting carries out versatility matching respectively.
The inspection module 203 is specifically for determining the field name of the field, obtaining corresponding matching according to the field name
Method, processes the content of the field according to the corresponding matching process, determines whether the field meets versatility.
The corresponding matching process is the content that the field is processed using built-in function and/or regular expression.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Internal memory is computer-readable medium
Example.
Computer-readable medium includes that permanent and non-permanent, removable and non-removable media can be by any method
Or technology is realizing information Store.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus
Or any other non-transmission medium, can be used to store the information that can be accessed by a computing device.Define according to herein, calculate
Machine computer-readable recording medium does not include temporary computer readable media (transitory media), the such as data-signal and carrier wave of modulation.
Also, it should be noted that term " including ", "comprising" or its any other variant are intended to nonexcludability
Comprising so that a series of process, method, commodity or equipment including key elements not only includes those key elements, but also wrapping
Other key elements being not expressly set out are included, or also includes intrinsic for this process, method, commodity or equipment wanting
Element.In the absence of more restrictions, the key element for being limited by sentence "including a ...", it is not excluded that wanting including described
The process of element, method, also there is other identical element in commodity or equipment.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer program.
Therefore, the application can adopt complete hardware embodiment, complete software embodiment or with reference to the embodiment in terms of software and hardware
Form.And, the application can be deposited using the computer for wherein including computer usable program code at one or more is available
The shape of the computer program implemented on storage media (including but not limited to magnetic disc store, CD-ROM, optical memory etc.)
Formula.
Embodiments herein is the foregoing is only, the application is not limited to.For those skilled in the art
For, the application can have various modifications and variations.All any modifications made within spirit herein and principle, equivalent
Replace, improve etc., within the scope of should be included in claims hereof.