CN108664385A - A kind of test method and device of application programming interface - Google Patents
A kind of test method and device of application programming interface Download PDFInfo
- Publication number
- CN108664385A CN108664385A CN201710198569.7A CN201710198569A CN108664385A CN 108664385 A CN108664385 A CN 108664385A CN 201710198569 A CN201710198569 A CN 201710198569A CN 108664385 A CN108664385 A CN 108664385A
- Authority
- CN
- China
- Prior art keywords
- api
- test
- test case
- interface
- metadata
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
This application discloses the test method of API a kind of and devices, to solve the problems, such as that interface docking test accuracy existing in the prior art is relatively low.Method includes:According to the metadata of the first API, generate the test case between the first API and the 2nd API and simulation test stake, first API and the 2nd API is the API that any two is different in multiple API that production environment includes, and the metadata of the first API is used to characterize the interface message of the first API;Call simulation test stake implementation of test cases in production environment;If test case execution passes through, it is determined that the first API is docked with the interface between the 2nd API and is successfully tested.
Description
Technical field
This application involves field of computer technology more particularly to a kind of application programming interface (Application
Programming Interface, API) test method and device.
Background technology
In field of communication technology, especially in the complicated information technology/communication technology (Information
Techonology/Communication Techonology, IT/CT) in system, often refer to integrated between multiple API
Docking.When docking test into line interface to the API in system, the following method of generally use:Research Analyst is to the API in system
It is investigated, forms the investigation document of API;Then determine that the technology of investigation document is thin repeatedly with Research Analyst through research staff
Section;After investigation document transfers to tester, test environment is built according to investigation document by tester, then in the test built
Each two API is docked into line interface in environment and is tested.
There are following defects for the interface docking test method of above-mentioned API:The interface docking test of API is to be based on tester
What the test environment built carried out, when realization, is difficult to ensure the consistency of test environment and true production environment, to influence
The accuracy of interface docking test.
To sum up, in the scheme provided in the prior art, there is a problem of that the accuracy of interface docking test is relatively low.
Invention content
The application provides a kind of test method and device of API, is surveyed to solve interface docking existing in the prior art
Try the relatively low problem of accuracy.
In a first aspect, the embodiment of the present application provides a kind of test method of API.This method comprises the following steps:According to
The metadata of one API generates the test case between the first API and the 2nd API and simulation test stake;Call simulation test stake in life
Produce implementation of test cases in environment;If test case execution passes through, it is determined that the first API docks survey with the interface between the 2nd API
It tries successfully.Wherein, the different API of any two in multiple API that the first API and the 2nd API includes for production environment, first
The metadata of API is used to characterize the interface message of the first API.
In the test method for the API that first aspect provides, according to the metadata of the first API, the first API and second is generated
Test case between API and simulation test stake, then by calling simulation test stake implementation of test cases in production environment,
Test case execution determines that the first API is docked with the interface between the 2nd API when passing through and is successfully tested.It is provided due to first aspect
Method is in production environment, to be carried by calling simulation test stake to be realized come implementation of test cases, therefore using first aspect
The method of confession, which docks API into line interface, tests, the accuracy higher of test.
Based in a first aspect, in one possible implementation, being executed in production environment calling simulation test stake
After test case, further include:Pass through if test case is not carried out, corrects the metadata of the first API;Then, according to amendment
The metadata of the first API afterwards updates the test case between the first API and the 2nd API and simulation test stake;It calls updated
Simulation test stake executes updated test case in production environment, until the execution of updated test case passes through.
Since the metadata of the first API is there may be mistake, when the test case of the first API and the 2nd API is not held
When row passes through, you can think that there are mistakes in the metadata of the first API, the metadata to the first API is needed to be modified at this time.
It is modified by the metadata to the first API, the accuracy of the metadata of the first API can be improved so that the member of the first API
Data can more realistically characterize the interface message of the first API, to improve the accuracy of interface docking test.
First aspect provide method in, test case be not carried out by the reason of there are many.It is right for different reasons
The mode that the metadata of first API is modified is also different.Wherein three kinds of situations are only enumerated below:
The first situation
If it is determined that test case be not carried out by the reason of for the first API metadata lack Optional Field, then first
Increase Optional Field in the metadata of API.
The second situation
If it is determined that test case be not carried out by the reason of not carried defined in the metadata of the first API in the first API
Mandatory field, then the mandatory field defined in the metadata of the first API is modified to Optional Field.
The third situation
If it is determined that test case be not carried out by the reason of in the data type of transmission data and the metadata of the first API
The data type of definition is inconsistent, then by test case be not carried out by information be recorded into the corresponding interface daily records of the first API
In, and according to the metadata of the first API of the interface daily record of typing above- mentioned information amendment.If for example, in the metadata of the first API
The data type of definition is numeric type, and the data type of transmission data is character string type, then test case can then be held
Unworkable mistake.Test case can be not carried out at this time by information be recorded in the corresponding interface daily records of the first API, it is follow-up i.e.
The metadata of the first API can be corrected according to the corresponding interface daily records of the first API.
Based in a first aspect, in one possible implementation, the interface pair between determining the first API and the 2nd API
It connects after being successfully tested, further includes:Record the commissioning environmental information between the first API and the 2nd API, commissioning environmental information includes the
The corresponding interface daily record of interface contract, the first API between one API and the 2nd API and test case, commissioning environmental information are used for
The joint debugging environment of simulated production environment is generated in development environment.It is different that any two in multiple API is imported in development environment
Multiple commissioning environmental informations that API is generated, you can generate the joint debugging environment of simulated production environment.
After the joint debugging environment for generating simulated production environment, you can connect to multiple interfaces in system in joint debugging environment
Mouth docking test, is tested without being docked in production environment into line interface again.To avoid the API in system in development phase
When constantly being changed, need frequently to dock the problem of testing into line interface in production environment.
Based in a first aspect, in one possible implementation, after the joint debugging environment for generating simulated production environment,
Actual test stake implementation of test cases in joint debugging environment of the first API compiled in advance can be also called, if test case executes
Pass through, it is determined that the actual test stake is errorless;Pass through if test case is not carried out, calls the modified actual test stake
The test case is executed in joint debugging environment, until test case execution passes through.
It should be noted that in joint debugging environment call actual test stake implementation of test cases process, with production ring
The process of simulation test stake implementation of test cases is called to be slightly different in border:In production environment when implementation of test cases, first
The request message or response message of API is that simulation test stake is sent, the response message or request message of the 2nd API be this second
What API entities were sent;And in joint debugging environment when implementation of test cases, the request message or response message of the first API are to pass through
The program code that research staff writes is called to realize, the response message or request message of the 2nd API are joint debugging environmental simulation hairs
It send.Therefore, actual test stake is called when implementation of test cases, to pass through if test case is not carried out, explanation in joint debugging environment
There are mistakes in the program code that research staff writes instructs development process to help research staff to improve program code.
Based in a first aspect, in one possible implementation, if the first API is in client, the 2nd API is in
In server-side, then the interface contract between preset first API and the 2nd API includes the interface message of the first API, the 2nd API
Interface message, the first API to the solicited message of the 2nd API, the 2nd API to the response message of the first API and the first API with
Interaction context information between 2nd API;If the first API is in server-side, the 2nd API is in client, then preset
Interface contract between first API and the 2nd API include the first API interface message, the interface message of the 2nd API, the first API to
The response message of 2nd API, the 2nd API are to above and below the interaction between the solicited message and the first API and the 2nd API of the first API
Literary information.
Second aspect, the application provide a kind of test device of API, which includes the first generation module, calling module
With the first determining module.
First generation module is used for the metadata according to the first API, generates the test case between the first API and the 2nd API
With simulation test stake;Calling module is for calling simulation test stake implementation of test cases in production environment;First determining module
For when test case execution passes through, determining that the first API is docked with the interface between the 2nd API and being successfully tested.
Wherein, the different API of any two in multiple API that the first API and the 2nd API includes for production environment, first
The metadata of API is used to characterize the interface message of the first API.
In the test device for the API that second aspect provides, the first generation module is generated according to the metadata of the first API
Test case between first API and the 2nd API and simulation test stake, then calling module is by calling simulation test stake producing
Implementation of test cases in environment, the first determining module execute the when of passing through in test case and determine connecing between the first API and the 2nd API
Mouth docking is successfully tested.When docking test into line interface due to the test device of the API provided using second aspect, calling module
By calling simulation test stake in production environment come implementation of test cases, therefore the first API is docked into line interface and is tested, surveyed
The accuracy higher of examination.
Based on second aspect, in one possible implementation, the test device of API further includes correcting module, is corrected
Module be used for test case be not carried out by when, correct the first API metadata;First generation module is additionally operable to according to amendment
The metadata of revised first API of module updates the test case between the first API and the 2nd API and simulation test stake;It calls
Module is additionally operable to that updated simulation test stake is called to execute updated test case in production environment, until updated
Test case execution passes through.
Since the metadata of the first API is there may be mistake, when the test case of the first API and the 2nd API is not held
When row passes through, you can think that there are mistakes in the metadata of the first API, the metadata to the first API is needed to be modified at this time.
It is modified by the metadata of the first API of correcting module pair, the accuracy of the metadata of the first API can be improved so that the
The metadata of one API can more realistically characterize the interface message of the first API, to improve the accuracy of interface docking test.
Second aspect provide API test device in, test case be not carried out by the reason of there are many.For not
Same reason, for correcting module when correcting the metadata of the first API, correcting mode includes but not limited to three kinds following:
The first situation
If it is determined that test case be not carried out by the reason of for the first API metadata lack Optional Field, then correct mould
Block increases Optional Field in the metadata of the first API.
The second situation
If it is determined that test case be not carried out by the reason of not carried defined in the metadata of the first API in the first API
Mandatory field, then correcting module the mandatory field defined in the metadata of the first API is modified to Optional Field.
The third situation
If it is determined that test case be not carried out by the reason of in the data type of transmission data and the metadata of the first API
The data type of definition is inconsistent, then correcting module by test case be not carried out by information to be recorded into the first API corresponding
In interface daily record, and according to the metadata of the first API of the interface daily record of typing information amendment.
Based on second aspect, in one possible implementation, the test device of API further includes:Module is recorded, is recorded
Module is used for after the first determining module determines that the first API dock with the interface between the 2nd API and to be successfully tested, recording first
Commissioning environmental information between API and the 2nd API, commissioning environmental information include interface contract between the first API and the 2nd API, the
The corresponding interface daily records of one API and test case, commissioning environmental information in development environment for generating simulated production environment
Joint debugging environment.
In addition, the test device of API may also include the second generation module, the second generation module in development environment for leading
Enter multiple commissioning environmental informations that the API that any two is different in multiple API is generated, generates the joint debugging ring of simulated production environment
Border.
After second generation module generates the joint debugging environment of simulated production environment, you can to more in system in joint debugging environment
A interface is docked into line interface to be tested, and is tested without being docked in production environment into line interface again.To avoid in system
API needs frequently to dock the problem of testing into line interface in production environment when development phase is constantly changed.
Based on second aspect, in one possible implementation, calling module is additionally operable to generate in the second generation module
After the joint debugging environment of simulated production environment, the actual test stake of the first API compiled in advance is called to be executed in joint debugging environment
Test case;The device may also include the second determining module, and the second determining module is used to, when test case execution passes through, determine
Actual test stake is errorless;Calling module be additionally operable to test case be not carried out by when, call modified actual test stake to exist
Implementation of test cases in joint debugging environment, until test case execution passes through.
It should be noted that in joint debugging environment call actual test stake implementation of test cases process, with production ring
The process of simulation test stake implementation of test cases is called to be slightly different in border:In production environment when implementation of test cases, first
The request message or response message of API is that simulation test stake is sent, the response message or request message of the 2nd API be this second
What API entities were sent;And in joint debugging environment when implementation of test cases, the request message or response message of the first API are to pass through
The program code that research staff writes is called to realize, the response message or request message of the 2nd API are joint debugging environmental simulation hairs
It send.Therefore, calling module calls actual test stake in joint debugging environment when implementation of test cases, if test case be not carried out it is logical
It crosses, illustrates that there are mistakes in the program code that research staff writes, to help research staff to improve program code, guidance exploitation
Process.
Based on second aspect, in one possible implementation, if the first API is in client, the 2nd API is in
In server-side, then the interface contract between preset first API and the 2nd API includes the interface message of the first API, the 2nd API
Interface message, the first API to the solicited message of the 2nd API, the 2nd API to the response message of the first API and the first API with
Interaction context information between 2nd API;If the first API is in server-side, the 2nd API is in client, then preset
Interface contract between first API and the 2nd API include the first API interface message, the interface message of the 2nd API, the first API to
The response message of 2nd API, the 2nd API are to above and below the interaction between the solicited message and the first API and the 2nd API of the first API
Literary information.
The third aspect, the embodiment of the present application provide a kind of test method of API, and the test device of the API includes transceiver,
Processor and memory.Transceiver, processor and memory are connected by bus.The transceiver is used to support the test of the API
It receives and sends messages between device and other equipment.Processor is realized pair by calling in memory the program code that stores and data
First API is docked into line interface to be tested.
Fourth aspect, the embodiment of the present application provide a kind of computer readable storage medium, in computer readable storage medium
Computer executed instructions are stored with, when at least one processor of calculate node executes the computer executed instructions, calculate section
The method that point executes the various possible realization methods offers of above-mentioned first aspect or first aspect.
5th aspect, the embodiment of the present application provide a kind of computer program product, which includes calculating
Machine executes instruction, which stores in a computer-readable storage medium.At least one processing of calculate node
Device can read the computer executed instructions from computer readable storage medium, and at least one processor executes computer execution
Instruction is so that calculate node implements the method for the various possible realization methods offers of above-mentioned first aspect or first aspect.
Description of the drawings
Fig. 1 is a kind of structural schematic diagram of API provided by the embodiments of the present application;
Fig. 2 is a kind of flow diagram of the test method of API provided by the embodiments of the present application;
Fig. 3 is a kind of flow diagram of the implementation of test cases in joint debugging environment provided by the embodiments of the present application;
Fig. 4 is the flow diagram of the test method of another kind API provided by the embodiments of the present application;
Fig. 5 is a kind of structural schematic diagram of the test device of API provided by the embodiments of the present application;
Fig. 6 is the structural schematic diagram of the test device of another kind API provided by the embodiments of the present application.
Specific implementation mode
In order to keep the purpose, technical scheme and advantage of the application clearer, below in conjunction with attached drawing to the application make into
One step it is described in detail.
The application provides a kind of test method and device of API, is surveyed to solve interface docking existing in the prior art
Try the relatively low problem of accuracy.Wherein, method and apparatus are based on same inventive concept, since method and device solves the problems, such as
Principle it is similar, therefore the implementation of apparatus and method can be with cross-reference, and overlaps will not be repeated.
In IT/CT systems, especially complicated IT/CT systems, the integrated docking between multiple API is often referred to.Wherein,
Multiple API may be from different producers, using different agreements, therefore how be into line interface docking test to multiple API
One urgent problem to be solved.By taking some base station sub-system (Base Sation Subsystem, BSS) as an example, collect in the system
At API related data it is as follows:The producer for being related to integrated docking is more than 100, and the API for being related to integrated docking is more than 1000
A, the agreement for being related to integrated docking is more than 4 kinds.If right in production environment again after the completion of whole API exploitations in system
Multiple API in system are docked into line interface to be tested, and be frequently can lead to mistake and is just found to a last link, and then causes
The rehabilitation cost of mistake is got higher.
In the prior art, in order to by the docking of API test it is preposition, find mistake as early as possible, usually in development phase i.e. to API
It docks and tests into line interface, method is as follows:In the requirement investigation link of API, Research Analyst obtains the API that API suppliers provide
Investigate document;After research staff obtains the investigation document, with regard to Simple Object Access Protocol (Simple Object Access
Protocol, SOAP) whether agreement do safety certification, have packet capturing with reference to the technical details such as code stream and Research Analyst's progress ditch
It is logical, then give the investigation document finally confirmed to tester.Tester builds test environment according to investigation document, and
API is docked into line interface in the test environment built and is tested.
In this method to API into line interface docking test, since the interface docking test of API is to be based on tester
The test environment built of member carries out, and when realization is difficult to ensure the consistency of test environment and true production environment, thus shadow
Ring the accuracy of interface docking test.Therefore, it in the scheme tested into line interface docking API provided in the prior art, deposits
In the relatively low problem of the accuracy of interface docking test.
The application provides a kind of test method and device of API, is surveyed to solve interface docking existing in the prior art
Try the relatively low problem of accuracy.
It should be noted that it is multiple involved by the application, refer to two or more.In addition, it is necessary to understand
It is that in the description of the present application, the vocabulary such as " first ", " second " are only used for distinguishing the purpose of description, and should not be understood as indicating
Or imply relative importance, instruction or hint sequence can not be interpreted as.
In the following, in order to allow the application to be more easily understood, the basic conception involved in the application is explained.
One, the metadata of API
The metadata of API is used to characterize the interface message of API, and the metadata of API usually makes with specific API and API
Agreement etc. is unrelated.
In the application, API metadata is mainly made of following four part:
1, API is described:That is the type fields and metadata fields of API, type fields are used for illustrating the agreement that API is used
Type, the protocol specification that metadata fields are used for importing the specific descriptions API (is typically that W3C standard criterions or industry are wide
The general quasi- specification used) file.For example, when the type of API is SOAP, the protocol specification file of API is * .wsdl files, should
Protocol specification file can be come protocol parameter, the data structure etc. that define API.Wherein, the data structure of API includes request message
The data structure etc. of data structure, the data structure of response message and unexpected message.
2, API resources:Realized by services to describe the corresponding services of API.Wherein, complicated API can be associated with
Multiple service enablers, therefore an API can correspond to multiple services and realize supplier.
3, API strategies:The strategy of API includes routing policy, stream interface driver, overtime control, service-level agreement
The strategy of (Service-Level Agreement, SLA) strategy etc., API can be by policies elements to configuring.
4, API metadata extends point:Protocol type type, policies element etc. all supports extension.By with
Handlers is applied in combination, and can support the extension of API metadata.
Based on unified API metadata, can to different manufacturers or using different agreement API be standardized, specification
The description of change.
Two, test case, simulation test stake and actual test stake
In the application, test case is to test whether api interface disclosure satisfy that the application under some application scenarios
And the test input write and expected results etc., it can meet the use demand of the application scenarios to test the API.Than
Such as, when some API is API (API consumer) in client, then the API of the opposite ends API is i.e. in server-side
API (API suppliers).Under credit balance this application scenarios of inquiry user, API consumer sends to API suppliers and looks into
Request is ask, API suppliers send response message to API consumer, the telephone expenses balance amount information of user is included in the response message.
In this example, inquiry request is to test input, and response message is expected results.
In the application, simulation test stake is to be automatically generated in production environment according to the metadata of API.In production environment
In by call simulation test stake test case can be tested.
Usually, API includes following components, as shown in Figure 1:Basic agreement layer is used for transmission procotol and disappears
Breath;Message coding and decoding layer, for Internet Protocol Message to be converted into true data result;API realizes layer, for carrying out
Business logic processing.When docking test into line interface to some API, it is generally difficult to know the business logic processing of opposite end API,
That is the API of opposite end API realizes that layer is a black box for the API of local terminal.
When docking test into line interface to local terminal API, API consumer is needed to send request, API suppliers, which make, to be answered
It answers.Assuming that the API that test is docked into line interface is API consumer, then when docking test into line interface to API consumer,
If API consumer sends out request message, API suppliers can send corresponding response message to API consumer.In production environment
In, simulation test stake can simulate API consumer and send out request message, although the request message cannot true simulation API consumption
The request message of person, but the information such as the interface contract between API consumer and API suppliers can be embodied, the API in production environment is carried
Donor entity can send response message after receiving the request message to API consumer's (simulation test stake).By calling mould
Quasi- test pile implementation of test cases can judge that the interface docking of API tests whether success by the implementing result of test case.
In the application, for an API, tested being docked into line interface to the API (local terminal API) and opposite end API
When, API, metadata, test case and simulation test stake have following correspondence:Local terminal API one metadata of correspondence, one
Metadata corresponds to multiple test cases, and a metadata corresponds to a simulation test stake;Multiple test cases represent local terminal API and
Multiple application scenarios between the API of opposite end, simulation test stake are used to simulate the request message or response message of local terminal API, pass through tune
Multiple test cases can be executed respectively with the simulation test stake, that is, can test local terminal API and opposite end API meet multiple applications
The use demand of scene.
Though that is, simulation test stake cannot true simulation local terminal API business processing logic, connect
When mouthful docking test, if being API suppliers into line interface docking test, simulation test stake can be initiated in client to server-side
The response message at analog service end when request is tested to be docked into line interface to API suppliers;If alternatively, into line interface pair
It is API consumer to connect test, simulation test stake can analog service end receive, request message from client, to right
API consumer is docked into line interface to be tested.
In the application, test case and simulation test stake can be generated according to the metadata of API.
Generating the mode of test case can be:The metadata fields in API metadata are parsed, it is fixed to obtain protocol parameter
Justice, the data structure definition of the data structure definition of request message, the data structure definition of response message and unexpected message.Root
It is defined according to protocol parameter, generates parameter configuration template;Field type, enumerated value, exception class defined in metadata according to API
Type etc. generates tactful, multiple tests use of the generation covering main execution routes of API such as boundary condition is tested and equivalent partition is tested
, the test case under normal scene and the test case under abnormal scene are included in multiple test cases of generation.
Generating the mode of simulation test stake can be:The type fields in the metadata of API are parsed, the agreement of API is obtained
Type;The metadata fields in API metadata are parsed, the data structure definition of request message, the data of response message are obtained
Structure defines and the data structure definition of unexpected message.According to protocol type and message (comprising request message, response message and
Unexpected message) data structure, calling interface simulation test frame, you can generate the simulation test stake of api interface.Wherein, it connects
The technical implementation way that mouth mold intends test frame is as follows:The service end interface of related protocol is called according to the protocol type of the API
And client-side interface, server-side example and client instance are created, and the data structure of request message and response message is bound
Onto server-side and client instance, the message for receiving or sending the agreement.
Actual test stake is the program code that research staff writes.Obviously, when the API into line interface docking test is in visitor
When in the end of family, by the request message of the exportable client of actual test stake, or when the API into line interface docking test is in
When in server-side, pass through the response message of the exportable server-side of actual test stake.
It should be noted that actual test stake is alternatively referred to as test pile, in order to by itself and simulation test stake area in the application
It separates, is referred to as " actual test stake ".Three, commissioning environmental information
In the application, the commissioning environmental information of API includes interface contract, interface daily record and the test case of API.
The interface contract of API includes interface message, solicited message, response message and Interaction context information.Wherein, it asks
Information includes URL (Uniform Resoure Locator, uniform resource locator) address of request, HTTP (HyperText
Transfer Protocol, hypertext transfer protocol) it acts, the message body of request;URL address of the response message comprising request,
The message body of HTTP actions, request;When the protocol type of API is HTTP, Interaction context information can be http protocol race
Interaction context information.Obtaining the mode of the Interaction context information of http protocol race can be:The HTTP message head of extension
Using Key:String-Value:The mode of String key-value pairs carries extended field, can be obtained by parsing the extended field
Take Interaction context information.
The interface daily record of API is recorded and is generated by simulation test stake.When calling actual test stake is in joint debugging environment
When implementation of test cases, pass through if test case is not carried out, the interface daily record of API can judge result and positioning problems play it is auxiliary
Help effect.
Four, production environment, development environment and joint debugging environment
In the application, production environment refers to delivering to customer formally as the environment of offering customers service;Development environment refer to for
The one group of software for supporting the engineering development of system software and application software and safeguarding and using.
In the application, joint debugging environment refers to environment generated in development environment, for simulated production environment.The application
In joint debugging environment can truly simulated production environment.After generating joint debugging environment, can in joint debugging environment to API into line interface
Docking test.
API testing schemes provided by the present application are specifically described below in conjunction with the accompanying drawings.
It is a kind of flow chart of the test method of API provided by the present application referring to Fig. 2.This method comprises the following steps:
S201:According to the metadata of the first API, the test case and simulation test between the first API and the 2nd API are generated
Stake.
Wherein, the different API of any two in multiple API that the first API and the 2nd API includes for production environment, first
The metadata of API is used to characterize the interface message of the first API.First API described herein and the 2nd API is not to refer in particular to
Certain two interface, only represents the API that any two is different in multiple API that production environment includes.
In the application, API can be SOAP interfaces, RESTful interfaces or other privately owned interfaces, such as Oracle data
The tuxedo interfaces in library.The metadata of first API can investigate tool according to API automation demandings to generate in production environment
's.
S202:Call simulation test stake implementation of test cases in production environment.
Wherein, calling simulation test stake, implementation of test cases can be between the first API and the 2nd API not in production environment
It is tested with being docked into line interface to the first API and the 2nd API under application scenarios.
It should be noted that when docking test into line interface to the first API and the 2nd API, to the quantity of test case
It is not limited.The quantity of application scenarios between the quantity of test case and the first API and the 2nd API is identical.If for example, first
API is in client, and the 2nd API is in server-side, and client can inquire credit balance and be supplemented with money to server-side, then,
Produce two test cases according to the metadata of the first API, test case for client by the first API request to
Server-side inquires credit balance, another test case is supplemented with money by the first API request to server-side for client.
S203:If test case execution passes through, it is determined that the first API is docked with the interface between the 2nd API and is successfully tested.
If passing through in addition, test case is not carried out, the metadata of the first API is corrected;According to revised first API's
Metadata updates the test case between the first API and the 2nd API and simulation test stake;Then updated simulation test is called
Stake executes updated test case in production environment, until the execution of updated test case passes through.
Since the metadata of the first API is there may be mistake, when the test case of the first API and the 2nd API is not held
When row passes through, you can think that there are mistakes in the metadata of the first API, the metadata to the first API is needed to be modified at this time.
It is modified by the metadata to the first API, the accuracy of the metadata of the first API can be improved so that the member of the first API
Data can more realistically characterize the interface message of the first API, to improve the accuracy of interface docking test.
In the application, the format of readable text file, such as YAML formats may be used in the metadata of the first API, then,
When test case be not carried out by when, can directly be changed using the text edit tool.
In method shown in Fig. 2, test case be not carried out by the reason of there are many.For different reasons, to first
The mode that the metadata of API is modified is also different.Wherein three kinds of situations are only enumerated below:
The first situation
If it is determined that test case be not carried out by the reason of for the first API metadata lack Optional Field, then first
Increase Optional Field in the metadata of API.
The second situation
If it is determined that test case be not carried out by the reason of not carried defined in the metadata of the first API in the first API
Mandatory field, then the mandatory field defined in the metadata of the first API is modified to Optional Field.
The third situation
If it is determined that test case be not carried out by the reason of in the data type of transmission data and the metadata of the first API
The data type of definition is inconsistent, then by test case be not carried out by information be recorded into the corresponding interface daily records of the first API
In, and according to the metadata of the first API of the interface daily record of typing above- mentioned information amendment.If for example, in the metadata of the first API
The data type of definition is numeric type, and the data type of transmission data is character string type, then test case can then be held
Unworkable mistake.Test case can be not carried out at this time by information be recorded in the corresponding interface daily records of the first API, it is follow-up i.e.
The metadata of the first API can be corrected according to the corresponding interface daily records of the first API.
It should be noted that the test method of the API described in Fig. 2 is the test method for the first API.By executing figure
Method shown in 2 can dock the first API into line interface and test.Assuming that include this five API of A, B, C, D and E in system, if
A docked into line interface and be tested, then using A as the first API, then execute four using B, C, D and E as the 2nd API successively
Secondary method shown in Fig. 2, you can completion A docks test with other API's in system.
By executing method shown in Fig. 2, the first API can be docked into line interface and be tested.If test case in S203
Execution passes through, then the first API is docked with the interface between the 2nd API and is successfully tested;Pass through if test case is not carried out in S203,
Test case that can be after the metadata for correcting the first API between update the first API and the 2nd API and simulation test stake, are then adjusted
Updated test case is executed in production environment with updated simulation test stake, until updated test case executes
Pass through.By above-mentioned implementation procedure, it may make the first API is docked with the interface between any API in system to be successfully tested.But
In systems development process, since API can be changed constantly, make the first API by executing method shown in Fig. 2 and be
In system between any API interface docking be successfully tested after, if some API is modified, also need to production environment include it is more
A API is docked into line interface to be tested.It is tested if frequently being docked in production environment into line interface, implementation procedure is relatively cumbersome, and
Expend a large amount of man power and material.
It is tested in order to avoid frequently being docked in production environment into line interface, in the application, is determining the first API and second
After interface docking between API is successfully tested, the commissioning environmental information between the first API and the 2nd API can be also recorded, the commissioning ring
Joint debugging environment of the border information for generating simulated production environment in development environment.Generate the joint debugging environment of simulated production environment
Afterwards, you can in joint debugging environment to multiple interfaces in system into line interface dock test, without again in production environment into
Line interface docking test.
Wherein, commissioning environmental information includes the first API interface days corresponding with the interface contract between the 2nd API, the first API
Will and test case.If the first API is in client, the 2nd API is in server-side, then preset first API and second
Interface contract between API includes the request of the interface message, the interface message, the first API of the 2nd API of the first API to the 2nd API
Information, the 2nd API are to the Interaction context information between the response message and the first API and the 2nd API of the first API;If first
API is in server-side, and the 2nd API is in client, then the interface contract between preset first API and the 2nd API includes
The interface message of first API, the interface message of the 2nd API, the first API are to the response message of the 2nd API, the 2nd API to first
Interaction context information between the solicited message of API and the first API and the 2nd API.
In the interface contract in recording commissioning environmental information, the simulation test between the first API and the 2nd API can be passed through
Stake obtains request code stream and response code stream by the way of packet capturing;It can be parsed according to the message header of request code stream and response code stream
Interaction context information between the first API and the 2nd API.According to the protocol type of the first API, the parsing of related protocol is called
Plug-in unit obtains the protocol-dependent field, the data structure of the data structure of request message and response message.With the first API
Protocol type be HTTP for, by call http protocol parse plug-in unit (such as Servlet etc. of Java) can obtain
HttpRequest objects, the data structure that request message can be obtained by HttpRequest objects (including the addresses URL, are asked
Parameter, method and HTTP Header for asking etc.) and the data structure of response message (include the response of HTTP response messages
Code, response Body and HTTP message head etc.).
Method shown in Fig. 2 is executed by any two API in multiple API for including to production environment, and for surveying
Example on probation be not carried out by the case where, by correct the first API metadata and repeat implementation of test cases until execute pass through,
So that the test case between any two API is performed both by passes through in production environment, you can it is different that recording obtains any two
Multiple commissioning environmental informations between API.So, import what the API that any two is different in multiple API was generated in development environment
Multiple commissioning environmental informations, you can generate the joint debugging environment of simulated production environment.
It may include test case between multiple API in production environment and simulation test stake, multiple API in joint debugging environment
Request message and response message between interface contract, the interface daily record of multiple API, API etc..
By executing said program, the joint debugging environment of simulated production environment is produced.Since joint debugging environment is to production
Under the premise of the interface docking of any two API in multiple API that environment includes is successfully tested, by recording any two
What the commissioning environmental information between API generated, therefore joint debugging environment can truly characterize production environment.In systems development process,
It is higher to the result reliability of API into line interface docking test in joint debugging environment.
Further, in joint debugging environment, the actual test stake of the first API compiled in advance can be called to execute test and used
Example;If test case execution passes through, it is determined that the actual test stake is errorless;Pass through if test case is not carried out, calls modification
The implementation of test cases in the joint debugging environment of actual test stake afterwards, until test case execution passes through.
It should be noted that in joint debugging environment call actual test stake implementation of test cases process, with production ring
The process of simulation test stake implementation of test cases is called to be slightly different in border:In production environment when implementation of test cases, first
The request message or response message of API is that simulation test stake is sent, the response message or request message of the 2nd API be this second
What API entities were sent;And in joint debugging environment when implementation of test cases, the request message or response message of the first API are to pass through
The program code that research staff writes is called to realize, the response message or request message of the 2nd API are joint debugging environmental simulation hairs
It send.Therefore, actual test stake is called when implementation of test cases, to pass through if test case is not carried out, explanation in joint debugging environment
There are mistakes in the program code that research staff writes.If it is determined that in the program code that research staff writes, there are mistakes, then,
It can also call modified actual test stake (modified program code) in joint debugging environment using method provided by the present application
Implementation of test cases, until test case execution passes through.To help research staff to improve program code, development process is instructed.
Assuming that the first API is API suppliers, the 2nd API is API consumer, calls actual test stake in simulated production ring
The process of implementation of test cases can be as shown in Figure 3 in the joint debugging environment in border.As seen from Figure 3, production environment and simulated production
The joint debugging environment of environment is isolated by network firewall.Actual test stake is called in the joint debugging environment of simulated production environment
The process of implementation of test cases can be:1, by the request message in the commissioning environmental information of API consumer in the joint debugging environment
(API consumer is called to simulate stake implementation of test cases, it should be noted that API here as input implementation of test cases
It is different from simulation test stake described herein that consumer simulates stake);2, API consumer simulates stake and is sent to API suppliers
Request message;3, actual test stake (the API suppliers in Fig. 3) exports response message;4, the survey will be executed in production environment
The response message and the response message that the test case obtains is executed in the joint debugging environment of simulated production environment that example on probation obtains
It compares.If two response messages are consistent, illustrate that the program code that research staff writes is errorless;If two response messages differ
It causes, illustrates that the program code that research staff writes is wrong.
The interface docking test result of multiple test cases of multiple API is integrated, you can form integration testing report
It accuses.The test case of the execution ratio that may include test case in integration test report, the rate that runs succeeded and execution failure
Api interface daily record etc..Integration test report can be used for assisting research staff and tester to test not by test case
Carry out positioning problems.
In the test method of API shown in Fig. 2, according to the metadata of the first API, generate between the first API and the 2nd API
Test case and simulation test stake, then by call simulation test stake implementation of test cases in production environment, testing
Use-case execution determines that the first API is docked with the interface between the 2nd API when passing through and is successfully tested.Since method shown in Fig. 2 is in life
Produce in environment, by calling simulation test stake to realize come implementation of test cases, therefore use this method to API into line interface pair
Connect test, the accuracy higher of test.If passing through in addition, test case is not carried out, the metadata of the first API can be repaiied
Just, according to the metadata of revised first API, the test case between the first API and the 2nd API and simulation test stake are updated;
Then updated simulation test stake is called to execute updated test case, until the execution of updated test case passes through.
Therefore, using the test method of API provided by the embodiments of the present application, the metadata of the first API can be modified, to make
The interface message of the first API can more realistically be characterized by obtaining the metadata of the first API, improve the accuracy of interface docking test.
The description of test method and its various possible realization methods based on above-mentioned API can be known:The application provides
The test method of API three functions mainly may be implemented:One, API is docked in production environment into line interface and is tested;Two, it records
The commissioning environmental information of API in production environment processed;Three, joint debugging environment is generated by the commissioning environmental information of recording, in joint debugging
API is docked again into line interface in environment and is tested.Therefore, in specific implementation, above-mentioned three can be realized by three frames
A function, i.e. api interface dock test frame, API commissioning environment records frame and frame is reset in API ring border.These three are surveyed
Examination frame can interact, to realize the test method of API shown in Fig. 2.
As shown in figure 4, being a kind of test method of API provided by the embodiments of the present application, this method can be considered side shown in Fig. 2
One specific example of method.As shown in figure 4, this method comprises the following steps:
1.API interfaces dock the metadata that test frame imports API.
API in method shown in Fig. 4 can be considered the first API in method shown in Fig. 2.
2.API interfaces dock metadata of the test frame according to API, generate API test cases.
3.API interfaces dock metadata of the test frame according to API, generate API simulation test stakes.
4.API interfaces dock the test assignment that test frame generates API according to the test case of API and simulation test stake.
Wherein, a test assignment corresponds to a test case.Multiple tests can be supported in method provided herein
Task concurrently executes.
Needs are executed to a test assignment when being tested due to being docked into line interface to API.Therefore, can also pass through in the application
Interface docking test assignment management module is managed multiple test assignments.Interface docking test assignment management module externally carries
For Restful interfaces, and support following function:
A, it supports to control the state of test assignment, it includes 0 that interface, which docks test assignment state,:Halted state;1:
Halted state;2:Starting state, wherein the task only in stopping and halted state can start.
The implementation strategy for a variety of test assignments such as b, support timing executes, periodicity is executed, is immediately performed.Periodically to execute
For strategy, the timed task frame (such as quartz) increased income technically may be used in timing implementation strategy, can also be direct
Timed task Timer classes based on JDK, or based on thread pool service (the Scheduled Executor for supporting timed task
Service, SES).
C, the perform track inquiry for supporting test assignment, can check test record, the implementing result of some api interface
Deng.
5.API interfaces dock test frame and call API simulation test stakes, dock test into line interface in production environment.
6.API commissioning environment records the commissioning environmental information that frame records each API.
Wherein, commissioning environmental information includes interface contract, interface daily record and the test case of API.
For example, the commissioning environmental information of API for querying the balance a kind of can be as shown in Figure 3.
Wherein, API commissionings environment records frame and the commissioning environmental information of each API of recording can be classified and be beaten
Packet resets frame to support integrally to export the API commissionings environment after packing to API ring border.
7.API environment resets frame and imports the commissioning environmental information that API commissioning environment records frame recording.
8.API environment resets frame and generates joint debugging environment according to the commissioning environmental information of each API.
The commissioning environment that each API that frame includes by import in step 7, production system is reset in API ring border is believed
Breath produces joint debugging environment.
9.API environment resets the actual test stake that frame calls the API compiled in advance, and API is executed in joint debugging environment
Commissioning environment records the test case that frame is recorded.
10.API environment resets frame according to the test result for calling actual test stake, generates integration test report.
It resets frame and carries out the test result in the test result and production environment in joint debugging environment pair in API ring border
Than integration test report can be generated.Wherein, the execution ratio that test case is may include in integration test report, runs succeeded
Rate, the api interface daily record of test case etc. for executing failure.
The application provides a kind of test device of API, which can be used for executing method shown in Fig. 2.As shown in figure 5,
The test device 500 (hereinafter referred to as device 500) of the API includes the first generation module 501, the determination of calling module 502 and first
Module 503.
First generation module 501 generates the test between the first API and the 2nd API for the metadata according to the first API
Use-case and simulation test stake, the first API and the 2nd API are the API that any two is different in multiple API that production environment includes,
The metadata of first API is used to characterize the interface message of the first API;
Calling module 502, for calling simulation test stake implementation of test cases in production environment;
First determining module 503, for when test case execution passes through, determining the interface between the first API and the 2nd API
Docking is successfully tested.
Optionally, device 500 further includes:Correcting module, for test case be not carried out by when, correct the first API
Metadata;First generation module 501 is additionally operable to the metadata according to revised first API of correcting module, updates the first API
Test case between the 2nd API and simulation test stake;Calling module 502 is additionally operable to call updated simulation test stake in life
Updated test case is executed in production environment, until the execution of updated test case passes through.
Optionally, correcting module is specifically used for when correcting the metadata of the first API:If it is determined that test case is not carried out
By the reason of for the first API metadata lack Optional Field, then correcting module increase in the metadata of the first API optional
Field;If it is determined that test case be not carried out by the reason of for do not carried in the first API defined in the metadata of the first API must
Word selection section, then correcting module the mandatory field defined in the metadata of the first API is modified to Optional Field;If it is determined that test is used
Example be not carried out by the reason of metadata of the data type with the first API for transmission data defined in data type differ
Cause, then correcting module by test case be not carried out by information be recorded into the corresponding interface daily records of the first API, and according to record
The metadata of the first API is corrected in the interface daily record for having entered information.
Optionally, device 500 further includes:Module is recorded, for determining the first API and second in the first determining module 503
After interface docking between API is successfully tested, the commissioning environmental information between the first API and the 2nd API, commissioning environmental information are recorded
Including the first API interface daily records corresponding with the interface contract between the 2nd API, the first API and test case, commissioning environmental information
Joint debugging environment for generating simulated production environment in development environment.
Optionally, device 500 further includes:Second generation module, for being imported in development environment arbitrary two in multiple API
Multiple commissioning environmental informations that a different API is generated, generate the joint debugging environment of simulated production environment.
Optionally, calling module 502 is additionally operable to after the joint debugging environment that the second generation module generates simulated production environment,
Call actual test stake implementation of test cases in joint debugging environment of the first API compiled in advance;The device further includes second true
Cover half block, the second determining module are used to, when test case execution passes through, determine that actual test stake is errorless;Calling module is additionally operable to
Test case be not carried out by when, call modified actual test stake implementation of test cases in joint debugging environment, until survey
Example execution on probation passes through.
Optionally, if the first API is in client, the 2nd API is in server-side, then preset first API and
Interface contract between two API includes the interface message, the interface message of the 2nd API, the first API asking to the 2nd API of the first API
Ask information, the 2nd API to the Interaction context information between the response message and the first API and the 2nd API of the first API;If the
One API is in server-side, and the 2nd API is in client, then the interface contract packet between preset first API and the 2nd API
The interface message of interface message, the 2nd API containing the first API, the first API are to the response message of the 2nd API, the 2nd API to
Interaction context information between the solicited message of one API and the first API and the 2nd API.
It should be noted that being schematical, only a kind of logic function to the division of module in the embodiment of the present application
It divides, formula that in actual implementation, there may be another division manner.Each function module in the embodiment of the present application can be integrated in one
Can also be that modules physically exist alone in processing module, can also two or more modules be integrated in a mould
In block.The form that hardware had both may be used in above-mentioned integrated module is realized, can also be realized in the form of software function module.
It should be noted that device 500 can be used for executing the test method of API shown in Fig. 2.It is not detailed in device 500
The realization method of description can be found in the associated description in the test method of API shown in Fig. 2.
In device 500, the first generation module 501 generates between the first API and the 2nd API according to the metadata of the first API
Test case and simulation test stake, then calling module 502 by call simulation test stake execute test in production environment
Use-case, the first determining module 503 determine that the first API docks test with the interface between the 2nd API when test case execution passes through
Success.When being tested due to being docked into line interface using device 500, calling module 502 is by calling simulation test stake in production ring
Carry out implementation of test cases in border, therefore the first API is docked into line interface and is tested, the accuracy higher of test.If in addition, test
Use-case, which is not carried out, to be passed through, then correcting module can be modified the metadata of the first API, and the first generation module is according to revised
The metadata of first API updates the test case between the first API and the 2nd API and simulation test stake;Then calling module 502
Updated simulation test stake is called to execute updated test case, until the execution of updated test case passes through.Therefore,
Using the test device 500 of API provided by the embodiments of the present application, the metadata of the first API can be modified, so that
The metadata of first API can more realistically characterize the interface message of the first API, improve the accuracy of interface docking test.
Fig. 6 shows the alternatively possible structural schematic diagram of the test device of API involved in above-described embodiment.
The test device 600 of API includes transceiver 601, processor 602 and memory 603.Transceiver 601, processor
602 are connected with memory 603 by bus.The transceiver 601 is for supporting between the test device 600 of API and other equipment
It receives and sends messages.Processor 602 executes API's shown in Fig. 2 by calling the program code stored in memory 603 and data
Test method.
The test device 600 of API can be device identical with the test device of API 500, and the test device 600 of API can
Test method for executing API shown in Fig. 2.The realization method of not detailed description can be found in figure in the test device 600 of API
Associated description in the test method of API shown in 2 and the test device 500 of API.
To sum up, using the test method and device of API provided by the present application, the accurate of interface docking test can be improved
Property.
It should be understood by those skilled in the art that, embodiments herein can be provided as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application
Apply the form of example.Moreover, the application can be used in one or more wherein include computer usable program code computer
The computer program production implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of product.
The application be with reference to according to the present processes, equipment (system) and computer program product flow chart and/or
Block diagram describes.It should be understood that each flow that can be realized by computer program instructions in flowchart and/or the block diagram and/or
The combination of flow and/or box in box and flowchart and/or the block diagram.These computer program instructions can be provided to arrive
All-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices processor to generate one
Machine so that the instruction executed by computer or the processor of other programmable data processing devices generates flowing
The device for the function of being specified in one flow of journey figure or multiple flows and/or one box of block diagram or multiple boxes.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that instruction generation stored in the computer readable memory includes referring to
Enable the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one box of block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device so that count
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, in computer or
The instruction executed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Obviously, those skilled in the art can carry out the application essence of the various modification and variations without departing from the application
God and range.In this way, if these modifications and variations of the application belong to the range of the application claim and its equivalent technologies
Within, then the application is also intended to include these modifications and variations.
Claims (14)
1. a kind of test method of application programming interface API, which is characterized in that including:
According to the metadata of the first API, the test case between the first API and the 2nd API and simulation test stake are generated, it is described
First API and the 2nd API is the API that any two is different in multiple API that production environment includes, the first API's
Metadata is used to characterize the interface message of the first API;
The simulation test stake is called to execute the test case in the production environment;
If test case execution passes through, it is determined that the first API dock with the interface between the 2nd API test at
Work(.
2. the method as described in claim 1, which is characterized in that held in the production environment calling the simulation test stake
After the row test case, further include:
Pass through if the test case is not carried out, corrects the metadata of the first API;
According to the metadata of revised first API, the test case and simulation that update between the first API and the 2nd API are surveyed
Test pile;
The updated simulation test stake is called to execute the updated test case in the production environment, until more
Test case execution after new passes through.
3. method as claimed in claim 2, which is characterized in that the metadata of the first API is corrected, including:
If it is determined that the test case be not carried out by the reason of for the first API metadata lack Optional Field, then exist
Increase the Optional Field in the metadata of first API;
If it is determined that the test case be not carried out by the reason of for first number of the first API is not carried in the first API
The mandatory field defined in the metadata of first API is then modified to Optional Field by the mandatory field defined in;
If it is determined that the test case be not carried out by the reason of for transmission data data type and the first API first number
Data type defined in is inconsistent, then by the test case be not carried out by information be recorded into the described first API pairs
In the interface daily record answered, and correct according to the interface daily record of typing described information the metadata of the first API.
4. such as claims 1 to 3 any one of them method, which is characterized in that determining the first API and described second
After interface docking between API is successfully tested, further include:
The commissioning environmental information between the first API and the 2nd API is recorded, the commissioning environmental information includes described first
Interface contract, the corresponding interface daily records of the first API between API and the 2nd API and the test case, the commissioning
Environmental information simulates the joint debugging environment of the production environment for being generated in development environment.
5. method as claimed in claim 4, which is characterized in that further include:
Multiple commissioning environmental informations that the API that any two is different in multiple API is generated are imported in the development environment, are generated
Simulate the joint debugging environment of the production environment.
6. method as claimed in claim 5, which is characterized in that after generating the joint debugging environment for simulating the production environment,
Further include:
The actual test stake of the first API compiled in advance is called to execute the test case in the joint debugging environment;
If the test case execution passes through, it is determined that the actual test stake is errorless;Pass through if the test case is not carried out,
The modified actual test stake is then called to execute the test case in the joint debugging environment, until the test case
Execution passes through.
7. such as claim 4~6 any one of them method, which is characterized in that if the first API is in client, institute
It states the 2nd API to be in server-side, then the interface contract between preset first API and the 2nd API includes described the
The interface message of one API, the interface message of the 2nd API, solicited message, described from the first API to the 2nd API
2nd API believes to the Interaction context between the response message and the first API and the 2nd API of the first API
Breath;
If the first API is in server-side, the 2nd API is in client, then preset first API and institute
State the interface message that the interface contract between the 2nd API includes the first API, the interface message of the 2nd API, described first
Response message, solicited messages from twoth API to first API and first API of the API to the 2nd API
With the Interaction context information between the 2nd API.
8. a kind of test device of application programming interface API, which is characterized in that including:
First generation module generates the test case between the first API and the 2nd API for the metadata according to the first API
With simulation test stake, the first API and the 2nd API is that any two is different in multiple API that production environment includes
The metadata of API, the first API are used to characterize the interface message of the first API;
Calling module, for calling the simulation test stake to execute the test case in the production environment;
First determining module, for when test case execution passes through, determining between the first API and the 2nd API
Interface docking be successfully tested.
9. device as claimed in claim 8, which is characterized in that further include:
Correcting module, for the test case be not carried out by when, correct the metadata of the first API;
First generation module, is additionally operable to the metadata according to revised first API of the correcting module, update described the
Test case between one API and the 2nd API and simulation test stake;
The calling module is additionally operable to the updated simulation test stake is called to execute in the production environment updated
The test case, until the updated test case execution passes through.
10. device as claimed in claim 9, which is characterized in that the correcting module is in the metadata for correcting the first API
When, it is specifically used for:
If it is determined that the test case be not carried out by the reason of for the metadata of the first API lack Optional Field, then institute
It states correcting module and increases the Optional Field in the metadata of the first API;
If it is determined that the test case be not carried out by the reason of for first number of the first API is not carried in the first API
Mandatory field defined in, then the correcting module mandatory field defined in the metadata of the first API is repaiied
Just it is being Optional Field;
If it is determined that the test case be not carried out by the reason of for transmission data data type and the first API first number
Data type defined in is inconsistent, then the correcting module by the test case be not carried out by information be recorded into institute
It states in the corresponding interface daily records of the first API, and corrects first number of the first API according to the interface daily record of typing described information
According to.
11. such as claim 8~10 any one of them device, which is characterized in that further include:
Module is recorded, for determining that the first API docks survey with the interface between the 2nd API in first determining module
After trying successfully, the commissioning environmental information between the first API and the 2nd API is recorded, the commissioning environmental information includes
First API and interface contract, the corresponding interface daily records of the first API and the test case between the 2nd API,
The commissioning environmental information simulates the joint debugging environment of the production environment for being generated in development environment.
12. device as claimed in claim 11, which is characterized in that further include:
Second generation module, for imported in the development environment any two is different in multiple API API generate it is multiple
Commissioning environmental information generates the joint debugging environment for simulating the production environment.
13. device as claimed in claim 12, which is characterized in that the calling module is additionally operable to generate mould described second
After block generates the joint debugging environment for simulating the production environment, the actual test stake of the first API compiled in advance is called to exist
The test case is executed in the joint debugging environment;
Described device further includes:Second determining module, for when test case execution passes through, determining the actual test
Stake is errorless;
The calling module, be additionally operable to the test case be not carried out by when, call the modified actual test stake
The test case is executed in the joint debugging environment, until test case execution passes through.
14. such as claim 11~13 any one of them device, which is characterized in that if the first API is in client,
2nd API is in server-side, then the interface contract between preset first API and the 2nd API includes described
Solicited message to the 2nd API of the interface message of first API, the interface message, the first API of the 2nd API, institute
The 2nd API is stated to the Interaction context letter between the response message and the first API and the 2nd API of the first API
Breath;
If the first API is in server-side, the 2nd API is in client, then preset first API and institute
State the interface message that the interface contract between the 2nd API includes the first API, the interface message of the 2nd API, described first
Response message, solicited messages from twoth API to first API and first API of the API to the 2nd API
With the Interaction context information between the 2nd API.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710198569.7A CN108664385A (en) | 2017-03-29 | 2017-03-29 | A kind of test method and device of application programming interface |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710198569.7A CN108664385A (en) | 2017-03-29 | 2017-03-29 | A kind of test method and device of application programming interface |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108664385A true CN108664385A (en) | 2018-10-16 |
Family
ID=63786793
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710198569.7A Pending CN108664385A (en) | 2017-03-29 | 2017-03-29 | A kind of test method and device of application programming interface |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108664385A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109408398A (en) * | 2018-11-13 | 2019-03-01 | 郑州云海信息技术有限公司 | A kind of interface automatic test device and method |
CN109688202A (en) * | 2018-12-04 | 2019-04-26 | 北京腾云天下科技有限公司 | A kind of processing method of interface data, calculates equipment and storage medium at device |
CN109726116A (en) * | 2018-11-08 | 2019-05-07 | 深圳壹账通智能科技有限公司 | Joint debugging test method, device, computer installation and storage medium |
CN110162455A (en) * | 2019-04-09 | 2019-08-23 | 口碑(上海)信息技术有限公司 | Joint debugging method and device, storage medium, the electronic device of software |
CN110162979A (en) * | 2019-05-27 | 2019-08-23 | 北京百度网讯科技有限公司 | A kind of safety detecting method, device, electronic equipment and the storage medium of Web API |
CN110618922A (en) * | 2019-08-15 | 2019-12-27 | 平安普惠企业管理有限公司 | Performance test method and related equipment |
CN111444094A (en) * | 2020-03-25 | 2020-07-24 | 中国邮政储蓄银行股份有限公司 | Test data generation method and system |
CN112256710A (en) * | 2020-09-30 | 2021-01-22 | 中孚安全技术有限公司 | Metadata-based data statistical analysis chart generation system, method and equipment |
-
2017
- 2017-03-29 CN CN201710198569.7A patent/CN108664385A/en active Pending
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109726116A (en) * | 2018-11-08 | 2019-05-07 | 深圳壹账通智能科技有限公司 | Joint debugging test method, device, computer installation and storage medium |
CN109408398A (en) * | 2018-11-13 | 2019-03-01 | 郑州云海信息技术有限公司 | A kind of interface automatic test device and method |
CN109688202A (en) * | 2018-12-04 | 2019-04-26 | 北京腾云天下科技有限公司 | A kind of processing method of interface data, calculates equipment and storage medium at device |
CN109688202B (en) * | 2018-12-04 | 2021-07-02 | 北京腾云天下科技有限公司 | Interface data processing method and device, computing equipment and storage medium |
CN110162455A (en) * | 2019-04-09 | 2019-08-23 | 口碑(上海)信息技术有限公司 | Joint debugging method and device, storage medium, the electronic device of software |
CN110162979A (en) * | 2019-05-27 | 2019-08-23 | 北京百度网讯科技有限公司 | A kind of safety detecting method, device, electronic equipment and the storage medium of Web API |
CN110618922A (en) * | 2019-08-15 | 2019-12-27 | 平安普惠企业管理有限公司 | Performance test method and related equipment |
CN110618922B (en) * | 2019-08-15 | 2022-10-04 | 平安普惠企业管理有限公司 | Performance test method and related equipment |
CN111444094A (en) * | 2020-03-25 | 2020-07-24 | 中国邮政储蓄银行股份有限公司 | Test data generation method and system |
CN111444094B (en) * | 2020-03-25 | 2023-08-04 | 中国邮政储蓄银行股份有限公司 | Test data generation method and system |
CN112256710A (en) * | 2020-09-30 | 2021-01-22 | 中孚安全技术有限公司 | Metadata-based data statistical analysis chart generation system, method and equipment |
CN112256710B (en) * | 2020-09-30 | 2022-12-06 | 中孚安全技术有限公司 | Metadata-based data statistical analysis chart generation system, method and equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108664385A (en) | A kind of test method and device of application programming interface | |
US8504989B2 (en) | Service definition document for providing blended services utilizing multiple service endpoints | |
US7437275B2 (en) | System for and method of multi-location test execution | |
WO2019072110A1 (en) | Method for generating application program, apparatus, system, device, and medium | |
Zdun et al. | Sustainable architectural design decisions | |
US20200133829A1 (en) | Methods and systems for performance testing | |
CN109726016A (en) | A kind of link tracing methods, devices and systems for distributed system | |
US20130339931A1 (en) | Application trace replay and simulation systems and methods | |
Belli et al. | A holistic approach to model‐based testing of Web service compositions | |
CN107729228A (en) | Interface test method, device, storage medium and processor | |
US8918762B2 (en) | Generating test plans and test cases from service-oriented architecture and process models | |
US11449414B2 (en) | Mapping test parameter data elements during heterogeneous component-based testing in a portable automation framework in both API mode and UI mode | |
CN109460223A (en) | A kind of API gateway management system and its method | |
CN103744680A (en) | Method and device for business process processing | |
US20170220457A1 (en) | Constructing test-centric model of application | |
CN105871911A (en) | Service calling engine, method and system | |
CN110209584A (en) | A kind of automatic generation of test data and relevant apparatus | |
US12013777B2 (en) | Controlling heterogeneous component-based testing in a portable automation framework with test scripts in both API mode and UI mode | |
US11269712B1 (en) | Customized categorial error handling framework for heterogeneous component-based testing in a portable automation framework | |
KR20150133902A (en) | System and method for developing of service based on software product line | |
US11734134B2 (en) | Automatically locating resources using alternative locator expressions during heterogeneous component-based testing in a portable automation framework | |
US11310680B2 (en) | Reusing provisioned resources during heterogeneous component-based testing in a portable automation framework | |
Pavlov et al. | Framework for testing service compositions | |
CN110275731B (en) | Information processing method, information processing apparatus, storage medium, and electronic device | |
Anderson | Performance modelling of reactive web applications using trace data from automated testing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20181016 |