CN110083523A - Interface test method, device, computer installation and readable storage medium storing program for executing - Google Patents

Interface test method, device, computer installation and readable storage medium storing program for executing Download PDF

Info

Publication number
CN110083523A
CN110083523A CN201910190770.XA CN201910190770A CN110083523A CN 110083523 A CN110083523 A CN 110083523A CN 201910190770 A CN201910190770 A CN 201910190770A CN 110083523 A CN110083523 A CN 110083523A
Authority
CN
China
Prior art keywords
service
service provider
testing
information
test
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
Application number
CN201910190770.XA
Other languages
Chinese (zh)
Inventor
高雪松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201910190770.XA priority Critical patent/CN110083523A/en
Publication of CN110083523A publication Critical patent/CN110083523A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing

Abstract

The present invention provides a kind of interface test method, it include: the demand file for generating the attribute information including service provider, the service provider provides at least one testing service, and the attribute information of the service provider includes the host address and port numbers of the service provider;The demand file is executed, is issued and is requested to the service provider according to the host address of the service provider and port numbers, the test information of each testing service provided by the service provider is obtained from the service provider;And judge whether the service provider passes through interface testing according to the test information of each testing service, and issue prompt information prompt test result.The present invention also provides device, computer installation and the readable storage medium storing program for executing of realizing the interface test method.The technical issues of present invention needs to carry out the setting of associated profile when can solve interface testing, heavy workload, code redundancy.

Description

Interface test method, device, computer installation and readable storage medium storing program for executing
Technical field
The present invention relates to field of computer technology, and in particular to a kind of interface test method, device, computer installation and Readable storage medium storing program for executing.
Background technique
Dubbo is the Distributed Architecture of alibaba open source, and many company's projects all use.For dubbo interface from Dynamicization test, the java used in the industry at present call the method for dubbo interface more troublesome, code redundancy.Protobuf is A kind of efficient structural data storage format of google open source, is equivalent to json+gzip, network transfer speeds faster, band Width occupancy is smaller, and many company's projects all use.For the interface automatic test of protobuf, use in the industry at present Java calls the method for protobuf interface more troublesome, code redundancy.
Summary of the invention
In view of the foregoing, it is necessary to propose a kind of interface test method, device, computer installation and readable storage medium The technical issues of matter, needs to carry out the setting of associated profile when solving interface testing, heavy workload, code redundancy.
The first aspect of the present invention provides a kind of interface test method, which comprises
Compilation operations are executed to the file where request data, to generate corresponding demand file, the demand file packet Include the attribute information of service provider, wherein the service provider provides at least one testing service, the service provider Attribute information include the service provider host address and port numbers;
The demand file is executed, according to the host address of the service provider and port numbers to the service provider Request is issued, the test information of each testing service provided by the service provider is obtained from the service provider;
The test information of each testing service is formatted and is stored described every after format is converted The test information of item testing service;And
Judge whether the service provider passes through interface testing according to the test information of each testing service, concurrently Prompt information prompts test result out.
Preferably, the attribute information of the service provider further includes each test clothes provided by the service provider The parameter information of business, the parameter information of each testing service include the Service name of each testing service, call method and defeated Enter data, each testing service at least one of described testing service is distinguished by Service name as mark.
Preferably, described to be asked according to the host address and port numbers of the service provider to service provider sending It asks, the test information of each testing service provided by the service provider is obtained from the service provider:
Using the library telnetlib in Python according to the host address of the service provider and port numbers to the clothes Business provider issues request;And
The test information of corresponding testing service is obtained from the service provider by tn.read_until ().
Preferably, when the service provider provides multiple testing services, interval preset time will by the request The parameter information of each testing service is sent to the service provider.
Preferably, when the service provider provides multiple testing services, one of them are tested by the request After the parameter information of service is sent to the service provider, and receive that the service provider returned described wherein one After the test information of testing service, then by described request the parameter information of the next item down testing service being sent to the service Provider.
Preferably, the test information of each testing service according to judges whether the service provider passes through and connects Mouth test, and issue prompt information prompt test result and include:
Compare the test information of each testing service and corresponding reference information;
When the test information of each testing service is identical as corresponding reference information, determine that the service provider is logical Interface testing is crossed, and issues prompt information prompt and is successfully tested;And
When the test information of at least one testing service and not identical corresponding reference information, determine that the service provides Side issues prompt information prompt test crash not over interface testing.
Preferably, the test information of each testing service according to judges whether the service provider passes through and connects Mouth test, and issue prompt information prompt test result and include:
Calculate time interval corresponding to each testing service, wherein time interval root corresponding to each testing service According to calculating at the first time with the second time, the first time, which refers to, sends the clothes for the parameter information of each testing service Be engaged in provider time, second time refer to the corresponding test information for receiving that the service provider is returned when Between;
Judge time interval corresponding to each testing service whether within preset time range;
If time interval corresponding to each testing service within the preset time range, determines that the service mentions Supplier is issued prompt information prompt and is successfully tested by interface testing;And
If time interval corresponding at least one testing service determines the clothes not within the preset time range Provider be engaged in not over interface testing, and issues prompt information prompt test crash.
Second aspect of the present invention provides a kind of computer installation, and the computer installation includes memory and processor, institute Memory is stated for storing at least one instruction, the processor is for realizing the interface testing when at least one described instruction Method.
Third aspect present invention provides a kind of computer readable storage medium, is stored thereon at least one instruction, described At least one instruction realizes the interface test method when being executed by processor.
Fourth aspect present invention provides a kind of interface test device, and described device includes:
Execution module, for executing compilation operations to the file where request data, to generate corresponding demand file, institute State the attribute information that demand file includes service provider, wherein the service provider provides at least one testing service, institute The attribute information for stating service provider includes the host address and port numbers of the service provider;
The execution module is also used to execute the demand file, according to the host address of the service provider and end Slogan is issued to the service provider and is requested, and obtains each survey provided by the service provider from the service provider Try the test information of service;
The execution module is also used to format the test information of each testing service and stores process The test information of each testing service after format conversion;And
Determining module, for judging whether the service provider passes through according to the test information of each testing service Interface testing, and issue prompt information prompt test result.
Interface test method described in the embodiment of the present invention, device, computer installation and readable storage medium storing program for executing, pass through Compilation operations are executed to the file where request data, to generate corresponding demand file, the demand file includes that service mentions The attribute information of supplier, wherein the service provider provides at least one testing service, the attribute letter of the service provider Breath includes the host address and port numbers of the service provider;The demand file is executed, according to the service provider Host address and port numbers are issued to the service provider requests, and obtains the service provider institute from the service provider The test information of each testing service provided;And judge that the service provides according to the test information of each testing service Whether side issues prompt information prompt test result by interface testing.The present invention needs to carry out when solving interface testing The technical issues of setting of associated profile, heavy workload, code redundancy, realizes interface testing automation, improves interface Testing efficiency.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is the flow chart for the interface test method that the embodiment of the present invention one provides.
Fig. 2 is the structure chart of interface test device provided by Embodiment 2 of the present invention.
Fig. 3 is the schematic diagram for the computer installation that the embodiment of the present invention three provides.
The present invention that the following detailed description will be further explained with reference to the above drawings.
Specific embodiment
To better understand the objects, features and advantages of the present invention, with reference to the accompanying drawing and specific real Applying example, the present invention will be described in detail.It should be noted that in the absence of conflict, the embodiment of the present invention and embodiment In feature can be combined with each other.
In the following description, numerous specific details are set forth in order to facilitate a full understanding of the present invention, described embodiment is only It is only a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill Personnel's every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Unless otherwise defined, all technical and scientific terms used herein and belong to technical field of the invention The normally understood meaning of technical staff is identical.Term as used herein in the specification of the present invention is intended merely to description tool The purpose of the embodiment of body, it is not intended that in the limitation present invention.
Embodiment one
Fig. 1 is the flow chart for the interface test method that the embodiment of the present invention one provides.
In the present embodiment, the interface test method can be applied in computer installation, for needing to carry out interface The computer installation of test can be integrated directly provided by method of the invention on a computing means for interface testing function Can, or computer installation is operated in the form of Software Development Kit (Software Development Kit, SDK) On.
As shown in Figure 1, the interface test method specifically includes following steps, according to different requirements, in the flow chart The sequence of step can change, and certain steps can be omitted.
Step S100, computer installation executes compilation operations to the file where request data, to generate corresponding request File, wherein the demand file includes the attribute information of service provider.Wherein, the service provider can provide one Or multinomial testing service.The attribute information of the service provider may include host address and the port of the service provider Number, the parameter information of each testing service provided by the service provider.
It is to be appreciated that Dubbo provides a set of distributed type open service framework, service framework may include in registration The heart, service consumer, service provider, service operation container and calling monitoring center etc..In order to ensure Dubbo service routine It operates normally, needs to carry out interface testing to the service that Dubbo is provided.
For Dubbo, service provider can register service provided by it to registration center on startup.It is real one It applies in mode, the registration center can be Multicast registration center, Zookeeper registration center, Redis registration center An or seed type in Simple registration center.
In one embodiment, the file where the request data can be .proto file (such as request.proto)。
In one embodiment, the parameter information of each testing service may include each testing service Service name, The parameters such as call method and input data.
In one embodiment, each testing service in one or more of testing services can pass through Service name conduct Mark is to be distinguished.
In one embodiment, the computer installation can compile the file where the request data by Python. It is produced afterwards for example, " protoc-I=.--python_out=.request.proto " can be inputted in the console The demand file of request_pb.py.
In present embodiment, the service provider, can be by the service provider when registering to the registration center Attribute information such as host address and port numbers etc. be supplied to the registration center.In one embodiment, the host Location can be used as the mark of Differentiated Services provider.
In one embodiment, the computer installation can obtain the host of the service provider from the registration center Address and port numbers.
In the first embodiment, host address and the port that the service provider is obtained from the registration center Number include step s11-s12:
(s11) Xiang Suoshu registration center sends request, wherein return service provides after the registration center receives request The address list of side gives the computer installation.
(s12) address list for the service provider that the registration center is returned is received, wherein the address list packet Include the attribute informations such as host address and the port numbers of service provider.
In this second embodiment, host address and the port that the service provider is obtained from the registration center Number include step s21-s22:
(s21) address list of the service provider is subscribed to by Xiang Suoshu registration center, and the address list includes described The attribute informations such as the host address of service provider and corresponding port numbers.
In the present embodiment, registration center MD5 value according to corresponding to the address list is to determine whether in the presence of more New address list, when the registration center determines that address list has update, the registration center can be by updated institute It states address list and is transferred to the computer installation.
For example, may include the first host address and first end slogan at the first moment, in the address list, at this point, institute State the first MD5 value corresponding to address list;The second host address and second end are increased newly within the second moment, the address list Slogan, at this point, the address list can correspond to the 2nd MD5 value.Since the 2nd MD5 value is different from the first MD5 value, because This, the registration center can determine whether that the address list exists and update.
(s22) address list that the registration center is transmitted is received.
Therefore, according to above embodiment, the computer installation can obtain the service from the registration center and provide The attribute informations such as the host address of side and port numbers.
Step S102, the computer installation executes the demand file, according to the host address of the service provider And port numbers are issued to the service provider and are requested, and are obtained from the service provider every provided by the service provider The test information of item testing service.
In present embodiment, the test information of a certain testing service that is to say test number corresponding to a certain testing service According to/test result.
It is when the computer installation executes the demand file, it can be achieved that corresponding in Dubbo in present embodiment The test function of service consumer.The demand file can be realized by Python, be conducive to avoid only to prop up in existing Dubbo Hold the deficiency of Java.
In present embodiment, the host address and port numbers according to the service provider is to the service provider Request is issued, the test information for obtaining each testing service provided by the service provider from the service provider includes Step s31-s32:
(s31) using the library telnetlib in Python according to the host address of the service provider and port numbers to The service provider issues request.
(s32) the test information of corresponding testing service is obtained from the service provider by tn.read_until ().
Specifically, the computer installation can set object tn=telnetlib.Telnet (Host, Port, timeout =10), wherein Host indicates host address parameter, and Port indicates port numbers parameter, and timeout indicates request timed out parameter.? In other embodiments, the request timed out parameter can also be omitted.
In one embodiment, the computer installation to the request that the service provider is issued further include the clothes The parameter information (i.e. the parameters such as Service name, call method, input data) of testing service provided by business provider.The i.e. described meter The parameter information of testing service provided by the service provider can be sent to described by calculation machine device by the request Service provider.
For example, by taking the parameter information of testing service includes Service name a, call method b and input data c as an example, the meter Calculation machine device can be sent by tn.write (" invoke a.b (c) ") Xiang Suoshu service provider and be requested, wherein invoke table Show the function for calling specified services.The computer installation can also be obtained by tn.read_until () from the service provider Take the test information of corresponding testing service.When the service provider receives request, the service provider can be according to clothes The test information of corresponding testing service is sent to the calculating to execute test by business name a, call method b and input data c Machine device.
In one embodiment, when the service provider provides survey of multiple testing services for example more than two or three When examination service, the computer installation can be spaced preset time and be sent the parameter information of each testing service by the request To the service provider.
For example, it is assumed that the service provider provides the first testing service, (parameter information of first testing service includes Service name a1, call method b1 and input data c1), the second testing service (parameter information of second testing service include clothes Be engaged in name a2, call method b2 and input data c2) and third testing service (parameter information of the third testing service include service Name a3, call method b3 and input data c3).The computer installation can pass through tn.write (" invoke at the first moment A1.b1 (c1) ") Xiang Suoshu service provider sends request, and passes through tn.write (" invoke a2.b2 at the second moment (c2) ") Xiang Suoshu service provider sends request, wherein the second moment and the first moment are separated by the preset time;It also can be The third moment sends request by tn.write (" invoke a3.b3 (c3) ") Xiang Suoshu service provider, wherein the third Moment and the second moment are separated by the preset time.
In another embodiment, when the service provider provides multiple testing services for example more than two or three When testing service, the parameter information of one of them testing service is sent to the clothes by the request by the computer installation It is engaged in after provider, and after receiving the test information for the one of them testing service that the service provider is returned, then The parameter information of the next item down testing service is sent to the service provider by the request.
For example, the computer installation can pass through tn.write (" invoke a1.b1 (c1) ") Xiang Suoshu at the first moment Service provider sends request, and judges whether to get by tn.read_until () corresponding with first testing service Test information, after receiving the test information of the first testing service, then the second moment pass through tn.write (" invoke A2.b2 (c2) ") the transmission request of Xiang Suoshu service provider.Similarly, the computer installation judges whether to pass through tn.read_ Until () gets test information corresponding with second testing service, when the test information for receiving the second testing service Afterwards, then at the third moment request is sent by tn.write (" invoke a3.b3 (c3) ") Xiang Suoshu service provider.That is institute It states after the parameter information of one of them testing service is sent to the service provider by computer installation, and receives the clothes After the test information of the one of them testing service that business provider is returned, then by the parameter information of the next item down testing service It is sent to the service provider.
In one embodiment, the computer installation also may include test mapping table, and the test mapping table may include The host address of the service provider and the parameter information of one or more testing services corresponding with the host address, The parameter information of middle each single item testing service includes the parameters such as Service name, call method and input data.Therefore, the computer Device is when sending request to the service provider, the host of the service provider can be obtained from the address list Location, and the parameter information that obtains with the host address corresponding one or more testing services is irradiated in table from the test. The parameter information of one or more testing services corresponding with the host address can be encapsulated into demand file later, such as This can automatically survey one or more testing service provided by the service provider when demand file is performed Examination.
The test information of each testing service is formatted and is deposited by step S104, the computer installation Storage.
It is to be appreciated that protobuf is a kind of efficient structural data storage format of comparison, it is equivalent to json+ Gzip, faster, bandwidth occupancy is smaller for network transfer speeds.Therefore, the computer installation is receiving the testing service After testing information, the test information can be stored in protobuf.
In present embodiment, the computer installation is by executing response file for the test information of each testing service The data of json format are converted to, and the data after conversion are stored in protobuf.
In present embodiment, the computer installation can by where response data file execute compilation operations, with Generate the response file, wherein the response data may include for carrying out format to the test information of each testing service The content of conversion.
In present embodiment, the response data be can be stored in .proto file (such as response.proto), described Computer installation can compile the file where the response data by Python.For example, inputting " protoc-I in the console =.--python_out=.response.proto " produces the response file of response_pb.py afterwards.
Step S106, the computer installation judge that the service provides according to the test information of each testing service Whether side issues prompt information prompt test result by interface testing.
In one embodiment, the test information of each testing service according to judges that the service provider is It is no by interface testing, and issue prompt information prompt test result include step s41-s43:
(s41) compare the test information of each testing service and corresponding reference information.
In present embodiment, reference information corresponding with each testing service has been stored in advance in the computer installation.
(s42) when the test information of each testing service is identical as corresponding reference information, determine that the service mentions Supplier is issued prompt information prompt and is successfully tested by interface testing.
(s43) when the test information of at least one testing service and not identical corresponding reference information, the clothes are determined Provider be engaged in not over interface testing, and issues prompt information prompt test crash.
In another embodiment, the test information of each testing service according to judges the service provider Whether by interface testing, and issuing prompt information prompt test result includes step s51-s54:
(s51) time interval corresponding to each testing service is calculated, wherein between the time corresponding to each testing service Every according to calculating at the first time with the second time, the first time, which refers to, sends institute for the parameter information of each testing service The time of service provider is stated, second time, which refers to, receives the corresponding test information that the service provider is returned Time;
(s52) judge time interval corresponding to each testing service whether within preset time range;
(s53) if time interval corresponding to each testing service is within the preset time range, described in determination Service provider is issued prompt information prompt and is successfully tested by interface testing.
(s54) it if time interval corresponding at least one testing service is not within the preset time range, determines The service provider issues prompt information prompt test crash not over interface testing.
In conclusion interface test method described in the embodiment of the present invention, by being held to the file where request data Row compilation operations, to generate corresponding demand file, the demand file includes the attribute information of service provider, wherein institute It states service provider and at least one testing service is provided, the attribute information of the service provider includes the service provider Host address and port numbers;The demand file is executed, according to the host address of the service provider and port numbers to described Service provider issues request, and the survey of each testing service provided by the service provider is obtained from the service provider Try information;And judge whether the service provider passes through interface testing according to the test information of each testing service, and It issues prompt information and prompts test result.The present invention realizes interface testing automation, improves interface testing efficiency.
Above-mentioned Fig. 1 describes interface test method of the invention in detail, below with reference to Fig. 2 and Fig. 3, to the realization interface The functional module of the software service of test method and the hardware device framework of the realization interface test method are introduced.
It should be appreciated that the embodiment is only purposes of discussion, do not limited by this structure in patent claim.
Embodiment two
As shown in fig.2, being the structure chart of interface test device provided by Embodiment 2 of the present invention.
In some embodiments, the interface test device 30 is run in computer installation.The interface test device 30 may include multiple functional modules as composed by program code segments.Each program segment in the interface test device 30 Program code can store in the memory of computer installation, and as performed by least one described processor, (in detail with realization See that Fig. 2 is described) interface testing function.
In the present embodiment, function of the interface test device 30 according to performed by it can be divided into multiple functions Module.The functional module may include: execution module 301, determining module 302.The so-called module of the present invention refers to a kind of energy Reach performed by least one processor and can complete the program segment of the series of computation machine program of fixed function, storage In memory.In the present embodiment, it will be described in detail in subsequent embodiment about the function of each module.
Execution module 301 executes compilation operations to the file where request data, to generate corresponding demand file, In, the demand file includes the attribute information of service provider.Wherein, the service provider can provide one or more surveys Examination service.The attribute information of the service provider may include the host address of the service provider and port numbers, described The parameter information of each testing service provided by service provider.
It is to be appreciated that Dubbo provides a set of distributed type open service framework, service framework may include in registration The heart, service consumer, service provider, service operation container and calling monitoring center etc..In order to ensure Dubbo service routine It operates normally, needs to carry out interface testing to the service that Dubbo is provided.
For Dubbo, service provider can register service provided by it to registration center on startup.It is real one It applies in mode, the registration center can be Multicast registration center, Zookeeper registration center, Redis registration center An or seed type in Simple registration center.
In one embodiment, the file where the request data can be .proto file (such as request.proto)。
In one embodiment, the parameter information of each testing service may include each testing service Service name, The parameters such as call method and input data.
In one embodiment, each testing service in one or more of testing services can pass through Service name conduct Mark is to be distinguished.
In one embodiment, the execution module 301 can compile the file where the request data by Python. It is produced afterwards for example, " protoc-I=.--python_out=.request.proto " can be inputted in the console The demand file of request_pb.py.
In present embodiment, the service provider, can be by the service provider when registering to the registration center Attribute information such as host address and port numbers etc. be supplied to the registration center.In one embodiment, the host Location can be used as the mark of Differentiated Services provider.
In one embodiment, the execution module 301 obtains the host of the service provider from the registration center Address and port numbers.
In the first embodiment, host address and the port that the service provider is obtained from the registration center Number include step s11-s12:
(s11) Xiang Suoshu registration center sends request, wherein return service provides after the registration center receives request The address list of side gives the computer installation.
(s12) address list for the service provider that the registration center is returned is received, wherein the address list packet Include the attribute informations such as host address and the port numbers of service provider.
In this second embodiment, host address and the port that the service provider is obtained from the registration center Number include step s21-s22:
(s21) address list of the service provider is subscribed to by Xiang Suoshu registration center, and the address list includes described The attribute informations such as the host address of service provider and corresponding port numbers.
In the present embodiment, registration center MD5 value according to corresponding to the address list is to determine whether in the presence of more New address list, when the registration center determines that address list has update, the registration center can be by updated institute It states address list and is transferred to the computer installation.
For example, may include the first host address and first end slogan at the first moment, in the address list, at this point, institute State the first MD5 value corresponding to address list;The second host address and second end are increased newly within the second moment, the address list Slogan, at this point, the address list can correspond to the 2nd MD5 value.Since the 2nd MD5 value is different from the first MD5 value, because This, the registration center can determine whether that the address list exists and update.
(s22) address list that the registration center is transmitted is received.
Therefore, according to above embodiment, the execution module 301 can obtain the service from the registration center and provide The attribute informations such as the host address of side and port numbers.
The execution module 301 executes the demand file, according to the host address and port numbers of the service provider It issues and requests to the service provider, obtain each test clothes provided by the service provider from the service provider The test information of business.
In present embodiment, the test information of a certain testing service that is to say test number corresponding to a certain testing service According to/test result.
It is when the execution module 301 executes the demand file, it can be achieved that corresponding in Dubbo in present embodiment Service consumer test function.The demand file can be realized by Python, be conducive to avoid in existing Dubbo only Support the deficiency of Java.
In present embodiment, the host address and port numbers according to the service provider is to the service provider Request is issued, the test information for obtaining each testing service provided by the service provider from the service provider includes Step s31-s32:
(s31) using the library telnetlib in Python according to the host address of the service provider and port numbers to The service provider issues request.
(s32) the test information of corresponding testing service is obtained from the service provider by tn.read_until ().
Specifically, the execution module 301 can set object tn=telnetlib.Telnet (Host, Port, Timeout=10), wherein Host indicates host address parameter, and Port indicates port numbers parameter, and timeout indicates request timed out Parameter.In other embodiments, the request timed out parameter can also be omitted.
In one embodiment, the execution module 301 further includes described to the request that the service provider is issued The parameter information (i.e. the parameters such as Service name, call method, input data) of testing service provided by service provider.It is i.e. described The parameter information of testing service provided by the service provider can be sent to institute by the request by execution module 301 State service provider.
For example, by taking the parameter information of testing service includes Service name a, call method b and input data c as an example, it is described to hold Row module 301 can be sent by tn.write (" invoke a.b (c) ") Xiang Suoshu service provider and be requested, wherein invoke table Show the function for calling specified services.The execution module 301 can also be by tn.read_until () from the service provider Obtain the test information of corresponding testing service.When the service provider receives request, the service provider can basis The test information of corresponding testing service is sent to the meter to execute test by Service name a, call method b and input data c Calculation machine device.
In one embodiment, when the service provider provides survey of multiple testing services for example more than two or three When examination service, the execution module 301 can be spaced preset time and be sent out the parameter information of each testing service by the request It send to the service provider.
For example, it is assumed that the service provider provides the first testing service, (parameter information of first testing service includes Service name a1, call method b1 and input data c1), the second testing service (parameter information of second testing service include clothes Be engaged in name a2, call method b2 and input data c2) and third testing service (parameter information of the third testing service include service Name a3, call method b3 and input data c3).The execution module 301 can pass through tn.write (" invoke at the first moment A1.b1 (c1) ") Xiang Suoshu service provider sends request, and passes through tn.write (" invoke a2.b2 at the second moment (c2) ") Xiang Suoshu service provider sends request, wherein the second moment and the first moment are separated by the preset time;It also can be The third moment sends request by tn.write (" invoke a3.b3 (c3) ") Xiang Suoshu service provider, wherein the third Moment and the second moment are separated by the preset time.
In another embodiment, when the service provider provides multiple testing services for example more than two or three When testing service, the parameter information of one of them testing service is sent to described by the execution module 301 by the request After service provider, and after receiving the test information for the one of them testing service that the service provider is returned, The parameter information of the next item down testing service is sent to by the service provider by the request again.
For example, the execution module 301 can pass through tn.write (" invoke a1.b1 (c1) ") to institute at the first moment It states service provider and sends request, and judge whether to get by tn.read_until () and first testing service pair The test information answered, after receiving the test information of the first testing service, then the second moment by tn.write (" Invoke a2.b2 (c2) ") the transmission request of Xiang Suoshu service provider.Similarly, the execution module 301 judges whether to pass through Tn.read_until () gets test information corresponding with second testing service, when receiving the second testing service After testing information, then is sent and asked by tn.write (" invoke a3.b3 (c3) ") Xiang Suoshu service provider at the third moment It asks.After the parameter information of one of them testing service is sent to the service provider by the i.e. described execution module 301, and receive After the test information of the one of them testing service returned to the service provider, then by the next item down testing service Parameter information is sent to the service provider.
In one embodiment, test mapping table has been stored in advance in the execution module 301 in computer installation, described Test the host address and one or more tests corresponding with the host address that mapping table may include the service provider The parameter information of service, wherein the parameter information of each single item testing service includes the ginseng such as Service name, call method and input data Number.Therefore, the execution module 301 can obtain institute when sending request to the service provider from the address list The host address of service provider is stated, and acquisition is corresponding with the host address one or more from test irradiation table The parameter information of testing service.The parameter information of one or more testing services corresponding with the host address can be sealed later It is attached in demand file, in this way, when demand file is performed, it can be automatically to one provided by the service provider or more A testing service is tested.
The test information of each testing service is formatted and is stored by the execution module 301.
It is to be appreciated that protobuf is a kind of efficient structural data storage format of comparison, it is equivalent to json+ Gzip, faster, bandwidth occupancy is smaller for network transfer speeds.Therefore, the computer installation is receiving the testing service After testing information, the test information can be stored in protobuf.
In present embodiment, the execution module 301 is believed the test of each testing service by executing response file Breath is converted to the data of json format, and the data after conversion are stored in protobuf.
In present embodiment, the execution module 301 can by where response data file execute compilation operations, with Generate the response file, wherein the response data may include for carrying out format to the test information of each testing service The content of conversion.
In present embodiment, the response data be can be stored in .proto file (such as response.proto), described Execution module 301 can compile the file where the response data by Python.For example, inputting " protoc- in the console I=.--python_out=.response.proto " produces the response file of response_pb.py afterwards.
Determining module 302 judges whether the service provider passes through according to the test information of each testing service and connects Mouth test, and issue prompt information prompt test result.
In one embodiment, the test information of each testing service according to judges that the service provider is It is no by interface testing, and issue prompt information prompt test result include step s41-s43:
(s41) compare the test information of each testing service and corresponding reference information.
In present embodiment, the determining module 302 has been stored in advance and each testing service pair in computer installation The reference information answered.
(s42) when the test information of each testing service is identical as corresponding reference information, determine that the service mentions Supplier is issued prompt information prompt and is successfully tested by interface testing.
(s43) when the test information of at least one testing service and not identical corresponding reference information, the clothes are determined Provider be engaged in not over interface testing, and issues prompt information prompt test crash.
In another embodiment, the test information of each testing service according to judges the service provider Whether by interface testing, and issuing prompt information prompt test result includes step s51-s54:
(s51) time interval corresponding to each testing service is calculated, wherein between the time corresponding to each testing service Every according to calculating at the first time with the second time, the first time, which refers to, sends institute for the parameter information of each testing service The time of service provider is stated, second time, which refers to, receives the corresponding test information that the service provider is returned Time;
(s52) judge time interval corresponding to each testing service whether within preset time range;
(s53) if time interval corresponding to each testing service is within the preset time range, described in determination Service provider is issued prompt information prompt and is successfully tested by interface testing.
(s54) it if time interval corresponding at least one testing service is not within the preset time range, determines The service provider issues prompt information prompt test crash not over interface testing.
In conclusion interface test device described in the embodiment of the present invention, by being held to the file where request data Row compilation operations, to generate corresponding demand file, the demand file includes the attribute information of service provider, wherein institute It states service provider and at least one testing service is provided, the attribute information of the service provider includes the service provider Host address and port numbers;The demand file is executed, according to the host address of the service provider and port numbers to described Service provider issues request, and the survey of each testing service provided by the service provider is obtained from the service provider Try information;And judge whether the service provider passes through interface testing according to the test information of each testing service, and It issues prompt information and prompts test result.The present invention realizes interface testing automation, improves interface testing efficiency.
Embodiment three
As shown in fig.3, the structural schematic diagram of the computer installation provided for the embodiment of the present invention three.Of the invention preferable In embodiment, the computer installation 3 includes memory 31, at least one processor 32, at least one communication bus 33.Ability Field technique personnel, both can be with it should be appreciated that the structure of the computer installation shown in Fig. 3 does not constitute the restriction of the embodiment of the present invention Be bus topology, be also possible to star structure, the computer installation 3 can also include than illustrate it is more or fewer other Hardware perhaps software or different component layouts.
In some embodiments, the computer installation 3 includes that one kind can be according to the instruction for being previously set or storing, certainly The dynamic terminal for carrying out numerical value calculating and/or information processing, hardware include but is not limited to microprocessor, specific integrated circuit, can Program gate array, digital processing unit and embedded device etc..
It should be noted that the computer installation 3 is only for example, other electronics that are existing or being likely to occur from now on are produced Product are such as adaptable to the present invention, should also be included within protection scope of the present invention, and are incorporated herein by reference.
In some embodiments, the memory 31 is used to store program code and various data, such as is mounted on described Interface test device 30 in computer installation 3, and in the operational process of computer installation 3 realize high speed, be automatically completed The access of program or data.The memory 31 includes read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), programmable read only memory (Programmable Read-Only Memory, PROM), Erasable Programmable Read Only Memory EPROM (Erasable Programmable Read-Only Memory, EPROM), one Secondary programmable read only memory (One-time Programmable Read-Only Memory, OTPROM), electronics erasing type Can make carbon copies read-only memory (Electrically-Erasable Programmable Read-Only Memory, EEPROM), CD-ROM (Compact Disc Read-Only Memory, CD-ROM) or other disc memories, magnetic disk storage, magnetic Tape storage or any other the computer-readable storage medium that can be used in carrying or storing data.
In some embodiments, at least one described processor 32 can be made of integrated circuit, such as can be by single The integrated circuit of encapsulation is formed, and is also possible to be made of the integrated circuit that multiple identical functions or different function encapsulate, be wrapped Include one or more central processing unit (Central Processing unit, CPU), microprocessor, digital processing chip, The combination etc. of graphics processor and various control chips.At least one described processor 32 is the control of the computer installation 3 Core (Control Unit), using all parts of various interfaces and the entire computer installation 3 of connection, by operation or The program or module being stored in the memory 31 are executed, and calls the data being stored in the memory 31, with The various functions and processing data of computer installation 3 are executed, such as execute the function of interface testing.
In some embodiments, at least one communication bus 33 is arranged to realize the memory 31 and described Connection communication between at least one processor 32 etc..
Although being not shown, the computer installation 3 can also include the power supply (such as battery) powered to all parts, excellent Choosing, power supply can be logically contiguous by electric power controller and at least one described processor 32, to pass through power management Device realizes the functions such as management charging, electric discharge and power managed.Power supply can also include one or more direct current or AC power source, recharging device, power failure detection circuit, power adapter or inverter, power supply status indicator etc. are appointed Meaning component.The computer installation 3 can also include multiple sensors, bluetooth module, Wi-Fi module etc., and details are not described herein.
It should be appreciated that the embodiment is only purposes of discussion, do not limited by this structure in patent claim.
The above-mentioned integrated unit realized in the form of software function module, can store and computer-readable deposit at one In storage media.Above-mentioned software function module is stored in a storage medium, including some instructions are used so that a computer Device (can be server, PC etc.) or processor (processor) execute each embodiment the method for the present invention Part.
In a further embodiment, in conjunction with Fig. 2, the computer installation 3 is can be performed at least one described processor 32 Operating device and the types of applications program (interface test device 30 as mentioned) of installation, program code etc., for example, above-mentioned Modules.
Program code is stored in the memory 31, and at least one described processor 32 can call the memory 31 The program code of middle storage is to execute relevant function.For example, modules described in Fig. 2 are stored in the memory 31 In program code, and as performed by least one described processor 32, to realize the function of the modules to reach The purpose of interface testing.
In one embodiment of the invention, the memory 31 stores one or more instructions i.e. at least one instruction, The purpose of interface testing is realized at least one described instruction performed by least one described processor 32.
Specifically, with reference to the description of correlation step in Fig. 1 corresponding embodiment, at least one described processor 32 executes above-mentioned Instruction is to realize:
Compilation operations are executed to the file where request data, to generate corresponding demand file, the demand file packet Include the attribute information of service provider, wherein the service provider provides at least one testing service, the service provider Attribute information include the service provider host address and port numbers;The demand file is executed, according to the service The host address and port numbers of provider is issued to the service provider requests, and obtains the service from the service provider The test information of each testing service provided by provider;And according to the judgement of the test information of each testing service Whether service provider passes through interface testing, and issues prompt information prompt test result.
Preferably, the attribute information of the service provider further includes each test clothes provided by the service provider The parameter information of business, the parameter information of each testing service include the Service name of each testing service, call method and defeated Enter data, each testing service at least one of described testing service is distinguished by Service name as mark.
Preferably, described to be asked according to the host address and port numbers of the service provider to service provider sending It asks, the test information of each testing service provided by the service provider is obtained from the service provider: using The library telnetlib in Python is issued according to the host address and port numbers of the service provider to the service provider Request;And the test information of corresponding testing service is obtained from the service provider by tn.read_until ().
Preferably, when the service provider provides multiple testing services, interval preset time will by the request The parameter information of each testing service is sent to the service provider.
Preferably, when the service provider provides multiple testing services, one of them are tested by the request After the parameter information of service is sent to the service provider, and receive that the service provider returned described wherein one After the test information of testing service, then by described request the parameter information of the next item down testing service being sent to the service Provider.
Preferably, the test information of each testing service according to judges whether the service provider passes through and connects Mouthful test, and issuing prompt information prompt test result includes: to compare the test information of each testing service and corresponding reference Information;When the test information of each testing service is identical as corresponding reference information, determine that the service provider passes through Interface testing, and issue prompt information prompt and be successfully tested;And when at least one of testing service test information and corresponding ginseng Examine information it is not identical when, determine the service provider not over interface testing, and issue prompt information prompt test crash.
Preferably, the test information of each testing service according to judges whether the service provider passes through and connects Mouth test, and issuing prompt information prompt test result includes: to calculate time interval corresponding to each testing service, wherein According to calculating at the first time with the second time, the first time refers to each time interval corresponding to each testing service The parameter information of testing service is sent to the time of the service provider, and second time refers to that receiving the service mentions The time for the corresponding test information that supplier is returned;Judge time interval corresponding to each testing service whether default Within time range;Described in if time interval corresponding to each testing service within the preset time range, determines Service provider is issued prompt information prompt and is successfully tested by interface testing;And if corresponding at least one testing service Time interval not within the preset time range, determine that the service provider not over interface testing, and issues Prompt information prompts test crash.
In several embodiments provided by the present invention, it should be understood that disclosed device and method can pass through it Its mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the module, only Only a kind of logical function partition, there may be another division manner in actual implementation.
The module as illustrated by the separation member may or may not be physically separated, aobvious as module The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.Some or all of the modules therein can be selected to realize the mesh of this embodiment scheme according to the actual needs 's.
It, can also be in addition, each functional module in each embodiment of the present invention can integrate in one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of hardware adds software function module.
It is obvious to a person skilled in the art that invention is not limited to the details of the above exemplary embodiments, Er Qie In the case where without departing substantially from spirit or essential attributes of the invention, the present invention can be realized in other specific forms.Therefore, no matter From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the present invention is by appended power Benefit requires rather than above description limits, it is intended that all by what is fallen within the meaning and scope of the equivalent elements of the claims Variation is included in the present invention.Any reference signs in the claims should not be construed as limiting the involved claims.This Outside, it is clear that one word of " comprising " is not excluded for other units or, odd number is not excluded for plural number.The multiple units stated in device claim Or device can also be implemented through software or hardware by a unit or device.The first, the second equal words are used to indicate name Claim, and does not indicate any particular order.
Finally it should be noted that the above examples are only used to illustrate the technical scheme of the present invention and are not limiting, although reference Preferred embodiment describes the invention in detail, those skilled in the art should understand that, it can be to of the invention Technical solution is modified or equivalent replacement, without departing from the spirit and scope of the technical solution of the present invention.

Claims (10)

1. a kind of interface test method, which is characterized in that the described method includes:
Compilation operations are executed to the file where request data, to generate corresponding demand file, the demand file includes clothes The attribute information of business provider, wherein the service provider provides at least one testing service, the category of the service provider Property information includes the host address and port numbers of the service provider;
The demand file is executed, is issued according to the host address of the service provider and port numbers to the service provider Request, the test information of each testing service provided by the service provider is obtained from the service provider;
The test information of each testing service is formatted and each survey described in storing after format is converted Try the test information of service;And
Judge whether the service provider passes through interface testing according to the test information of each testing service, and issues and mention Show information alert test result.
2. interface test method as described in claim 1, which is characterized in that the attribute information of the service provider further includes The parameter information of each testing service provided by the service provider, the parameter information of each testing service include every Service name, call method and the input data of testing service, each testing service at least one of described testing service are logical Service name is crossed to be distinguished as mark.
3. interface test method as claimed in claim 2, which is characterized in that the host according to the service provider Location and port numbers are issued to the service provider requests, and obtains provided by the service provider from the service provider The test information of each testing service:
It is mentioned according to the host address and port numbers of the service provider to the service using the library telnetlib in Python Supplier issues request;And
The test information of corresponding testing service is obtained from the service provider by tn.read_until ().
4. interface test method as claimed in claim 3, which is characterized in that when the service provider provides multiple test clothes When business, the parameter information of each testing service is sent to the service provider by the request by interval preset time.
5. interface test method as claimed in claim 3, which is characterized in that when the service provider provides multiple test clothes When business, after the parameter information of one of them testing service is sent to the service provider by the request, and receive After the test information for the one of them testing service that the service provider is returned, then pass through the request for the next item down The parameter information of testing service is sent to the service provider.
6. interface test method as described in claim 1, which is characterized in that the test of each testing service according to Information judges whether the service provider passes through interface testing, and issues prompt information prompt test result and include:
Compare the test information of each testing service and corresponding reference information;
When the test information of each testing service is identical as corresponding reference information, determine the service provider by connecing Mouth test, and issue prompt information prompt and be successfully tested;And
When the test information of at least one testing service and not identical corresponding reference information, determine that the service provider does not have Have through interface testing, and issues prompt information prompt test crash.
7. interface test method as described in claim 1, which is characterized in that the test of each testing service according to Information judges whether the service provider passes through interface testing, and issues prompt information prompt test result and include:
Calculate time interval corresponding to each testing service, wherein time interval corresponding to each testing service is according to One time and the second time calculate, and the first time refers to that sending the service for the parameter information of each testing service mentions The time of supplier, second time refer to the time for receiving the corresponding test information that the service provider is returned;
Judge time interval corresponding to each testing service whether within preset time range;
If time interval corresponding to each testing service determines the service provider within the preset time range By interface testing, and issues prompt information prompt and be successfully tested;And
If time interval corresponding at least one testing service determines that the service mentions not within the preset time range Supplier issues prompt information prompt test crash not over interface testing.
8. a kind of computer installation, which is characterized in that the computer installation includes memory and processor, and the memory is used In storing at least one instruction, the processor when at least one described instruction for realizing as any one in claim 1 to 7 The item interface test method.
9. a kind of computer readable storage medium is stored thereon at least one instruction, which is characterized in that it is described at least one refer to The interface test method as described in any one of claim 1 to 7 is realized when order is executed by processor.
10. a kind of interface test device, which is characterized in that described device includes:
Execution module, it is described to ask to generate corresponding demand file for executing compilation operations to the file where request data Seeking file includes the attribute information of service provider, wherein the service provider provides at least one testing service, the clothes The attribute information of business provider includes the host address and port numbers of the service provider;
The execution module is also used to execute the demand file, according to the host address and port numbers of the service provider It issues and requests to the service provider, obtain each test clothes provided by the service provider from the service provider The test information of business;
The execution module is also used to format the test information of each testing service and store by format The test information of each testing service after conversion;And
Determining module, for judging whether the service provider passes through interface according to the test information of each testing service Test, and issue prompt information prompt test result.
CN201910190770.XA 2019-03-13 2019-03-13 Interface test method, device, computer installation and readable storage medium storing program for executing Pending CN110083523A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910190770.XA CN110083523A (en) 2019-03-13 2019-03-13 Interface test method, device, computer installation and readable storage medium storing program for executing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910190770.XA CN110083523A (en) 2019-03-13 2019-03-13 Interface test method, device, computer installation and readable storage medium storing program for executing

Publications (1)

Publication Number Publication Date
CN110083523A true CN110083523A (en) 2019-08-02

Family

ID=67412471

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910190770.XA Pending CN110083523A (en) 2019-03-13 2019-03-13 Interface test method, device, computer installation and readable storage medium storing program for executing

Country Status (1)

Country Link
CN (1) CN110083523A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078534A (en) * 2019-11-26 2020-04-28 深圳云天励飞技术有限公司 Test scheduling method and related equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484216A (en) * 2014-12-29 2015-04-01 广州唯品会网络技术有限公司 Method and device for generating service interface document and on-line test tool
CN106998277A (en) * 2017-05-25 2017-08-01 浙江数链科技有限公司 Web service method of testing and device
CN108268348A (en) * 2017-12-08 2018-07-10 广州视源电子科技股份有限公司 Interface test method, device, mobile terminal and storage medium
CN108334449A (en) * 2018-01-26 2018-07-27 北京京东金融科技控股有限公司 A kind of method and apparatus of interface automatic test
CN108650149A (en) * 2018-04-24 2018-10-12 平安科技(深圳)有限公司 Test method, device, equipment and the computer readable storage medium of server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484216A (en) * 2014-12-29 2015-04-01 广州唯品会网络技术有限公司 Method and device for generating service interface document and on-line test tool
CN106998277A (en) * 2017-05-25 2017-08-01 浙江数链科技有限公司 Web service method of testing and device
CN108268348A (en) * 2017-12-08 2018-07-10 广州视源电子科技股份有限公司 Interface test method, device, mobile terminal and storage medium
CN108334449A (en) * 2018-01-26 2018-07-27 北京京东金融科技控股有限公司 A kind of method and apparatus of interface automatic test
CN108650149A (en) * 2018-04-24 2018-10-12 平安科技(深圳)有限公司 Test method, device, equipment and the computer readable storage medium of server

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078534A (en) * 2019-11-26 2020-04-28 深圳云天励飞技术有限公司 Test scheduling method and related equipment

Similar Documents

Publication Publication Date Title
CN110443573A (en) Examination & approval management platform and its measures and procedures for the examination and approval, workflow generation method
CN109359031A (en) More appliance applications test methods, device, server and storage medium
CN108153670A (en) A kind of interface test method, device and electronic equipment
CN109302522A (en) Test method, device and computer system and medium
WO2022005401A1 (en) Method and apparatus for updating gateway resource, and iot control platform
CN109471789A (en) For the multi-apparatus management method of test, device, server and storage medium
CN110471834A (en) Credit card analog detection method and relevant device under more transaction channels
CN111917587B (en) Method for network service management by using service system and service system
CN110377520A (en) The test method and device, electronic equipment and readable storage medium storing program for executing for scene of trading
CN108595316A (en) Life cycle management method, manager, equipment and the medium of Distributed Application
CN111600760B (en) Quality detection system, method and equipment of power grid operation monitoring system
CN109977012A (en) Joint debugging test method, device, equipment and the computer readable storage medium of system
CN109213658A (en) A kind of method for inspecting and device
CN110083523A (en) Interface test method, device, computer installation and readable storage medium storing program for executing
CN109710447A (en) For the method, apparatus of data access, medium and calculate equipment
CN109240928A (en) A kind of test method, device, equipment and storage medium
CN116136801B (en) Cloud platform data processing method and device, electronic equipment and storage medium
US11868110B2 (en) Service operation method for energy management for each tenant in multi-tenant environment, and energy management service supply system
CN112069078A (en) ESA interface pressure testing method, device, testing equipment and storage medium
CN109598360A (en) Business handles on line method, apparatus and calculates readable storage medium storing program for executing
CN110348984A (en) Credit card information automation input method and relevant device under different transaction channels
CN110113181A (en) Node configuration method, device, computer installation and readable storage medium storing program for executing
CN107135191A (en) Check that distributed service handles the method and device of integrity degree
CN106130757B (en) Information acquisition method and device
CN110096416A (en) Abnormal alarm method, apparatus, computer installation and readable storage medium storing program for executing

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