CN106776324A - Interface test method and device - Google Patents

Interface test method and device Download PDF

Info

Publication number
CN106776324A
CN106776324A CN201611179931.8A CN201611179931A CN106776324A CN 106776324 A CN106776324 A CN 106776324A CN 201611179931 A CN201611179931 A CN 201611179931A CN 106776324 A CN106776324 A CN 106776324A
Authority
CN
China
Prior art keywords
target
value
keyword
return value
content
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
CN201611179931.8A
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.)
Guangzhou Kugou Computer Technology Co Ltd
Original Assignee
Guangzhou Kugou Computer Technology Co 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 Guangzhou Kugou Computer Technology Co Ltd filed Critical Guangzhou Kugou Computer Technology Co Ltd
Priority to CN201611179931.8A priority Critical patent/CN106776324A/en
Publication of CN106776324A publication Critical patent/CN106776324A/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/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • 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
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

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

The invention discloses a kind of interface test method and device, belong to field of computer technology.Methods described includes:By interface implementation of test cases to be measured, target return value is obtained;The content of the target return value and the content of default target desired value are compared, the target desired value is according to the requirement documents acquisition for performing initial return value and the test case that the test case is obtained;According to comparative result, judge whether the interface to be measured is normal.The present invention solves all the elements that cannot ensure in the prior art in return value and can be verified, and test leakage phenomenon easily occurs, and the poor problem of the reliability of interface testing improves the reliability of interface testing.The present invention is used for interface testing.

Description

Interface test method and device
Technical field
The present invention relates to field of computer technology, more particularly to a kind of interface test method and device.
Background technology
Interface testing is a kind of test carried out the interface between system.Interface testing is mainly for detection of system and system Between, and whether interactive interface between the subsystems of internal system normal.
In the prior art, generally serviced using automated test tools such as Postman, Soap UI and Selenium The interface testing at end.Specifically, tester is automating according to default desired value in the requirement documents of certain test case Check post is pre-set in testing tool, and (check post can include certain special key words (English:Key), specific value (English Text:Value), number of times that certain value occurs etc.), then request method, request reference address are input into automated test tool (also referred to as URL is (English:Uniform Resource Locator;Referred to as:URL)), required parameter etc. comes right Interface to be measured carries out interface testing, obtains return value.It is corresponding in checking return value finally according to the check post for pre-setting Content, when the corresponding contents in return value are consistent with the content in the check post for pre-setting, it is determined that the current interface is normal; When the content in the corresponding contents in return value with the check post for pre-setting is inconsistent, the interface exception is determined.
But only it is to demonstrate the content in the check post for pre-setting, due to testing when being verified to return value at present Card point is that tester pre-sets, when the data volume of return value is excessive, it is impossible to all data in ensureing as return value Check post is set, so as to cannot ensure that all the elements in return value can be verified, test leakage phenomenon easily occurs, so interface The reliability of test is poor.
The content of the invention
In order to solve cannot to ensure that all the elements in return value can be verified in the prior art, easily there is test leakage and show As the problem that the reliability of, interface testing is poor, a kind of interface test method and device are the embodiment of the invention provides.The skill Art scheme is as follows:
First aspect, there is provided a kind of interface test method, methods described includes:
By interface implementation of test cases to be measured, target return value is obtained;
The content of the target return value and the content of default target desired value are compared, the target desired value It is according to the requirement documents acquisition for performing initial return value and the test case that the test case is obtained;
According to comparative result, judge whether the interface to be measured is normal.
In embodiments of the present invention, the content and default target desired value of the target return value that will be returned from interface to be measured Content be compared, because the target desired value is initial return value according to implementation of test cases and the need of the test case Ask what document was obtained, compared with corresponding contents in the prior art according to the check post checking return value for pre-setting, the present invention Embodiment can verify all the elements of target return value, it is possible to prevente effectively from there is test leakage phenomenon, improve interface testing Reliability.
Optionally, it is described by interface implementation of test cases to be measured before, methods described also includes:
The test case is performed by the interface to be measured, the initial return value is obtained;
It is when the initial return value is identical with the default desired value in the requirement documents, the initial return value is true It is set to target desired value.
Interface test method provided in an embodiment of the present invention, determines that correct initial return value is set to mesh by tester Mark desired value, without setting check post by hand, reduces the maintenance cost of test case, improves testing efficiency.
Optionally, the content by the target return value is compared with the content of default target desired value, bag Include:
Judge whether the data form of the target return value is identical with the data form of the target desired value;
When the data form of the target return value is identical with the data form of the target desired value, according to the mesh The data type of return value is marked, content and the content of the target desired value to the target return value are compared.
In the embodiment of the present invention, judge at first the content of target return value and default target desired value content whether phase Together, when the content of target return value is differed with the content of default target desired value, comparison procedure is terminated, when target is returned When the content of value is identical with the content of default target desired value, then the content of comparison object return value is interior with target desired value Hold, the comparative sequence efficiency of this interface testing is higher.
Optionally, the data type according to the target return value, to the content of the target return value with it is described The content of target desired value is compared, including:
Determine the data type of the target return value, the data type is object or array;
When the data type is object, content and the content of the target desired value to the target return value are held Row object compares operation;
When the data type is array, content and the content of the target desired value to the target return value are held Line number group compares operation.
In the embodiment of the present invention, when data type is object, performs object and compare operation, when data type is array When, perform array and compare operation, comprehensively the content of target return value can be compared with the content of target desired value, point Class can also relatively improve the testing efficiency of interface testing.
Optionally, the target return value includes keyword and value corresponding with the keyword,
The content to the target return value performs object and compares operation with the content of the target desired value, wraps Include:
Judge the keyword of the target return value number and the keyword of the target desired value number whether phase Together;
When the number of the keyword of the target return value is identical with the number of the keyword of the target desired value, sentence Whether the form of the keyword of the target return value of breaking is identical with the form of the keyword of the target desired value;
When the form of the keyword of the target return value is identical with the form of the keyword of the target desired value, sentence Whether the title of the keyword of the target return value of breaking is identical with the title of the keyword of the target desired value;
When the title of the keyword of the target return value is identical with the title of the keyword of the target desired value, sentence Whether the corresponding value of the keyword value corresponding with the keyword of the target desired value of the target return value of breaking is identical;
It is described to judge whether interface to be measured is normal according to comparative result, including:
When the corresponding value of the keyword of target return value value corresponding with the keyword of the target desired value is identical When, determine that the interface to be measured is normal.
This content to target return value performs the method that object compares operation, Ke Yibao with the content of target desired value All the elements in card object are verified, and complete to compare the full traversal of target return value, and improve interface testing can By property.
Further, the content to the target return value performs object and compares with the content of the target desired value Operation, also includes:
Any one, terminates the object and compares operation, and send the prompt message that reports an error below satisfaction:
The number of the keyword of the target return value is differed with the number of the keyword of the target desired value;
The form of the keyword of the target return value is differed with the form of the keyword of the target desired value;
The title of the keyword of the target return value is differed with the title of the keyword of the target desired value;
The corresponding value of the keyword value corresponding with the keyword of the target desired value of the target return value is differed.
In the embodiment of the present invention, when above-mentioned any one situation is met, it will end object compares operation, it is possible to send out Go out the corresponding prompt message that reports an error, tester's interface to be measured is abnormal for pointing out for the prompt message that reports an error, and tester can Interface to be measured is repaired with according to the corresponding prompt message that reports an error.
Optionally, the content to the target return value compares behaviour with the content execution array of the target desired value Make, including:
Judge whether the length of the target return value is identical with the length of the target desired value;
When the length of the target return value is identical with the length of the target desired value, the target return value is judged Element content it is whether identical with the content of the element of the target desired value;
It is described to judge whether the interface to be measured is normal according to comparative result, including:
When the content of the element of the target return value is identical with the content of the element of the target desired value, institute is determined State interface to be measured normal.
This content to target return value performs the method that array compares operation, Ke Yibao with the content of target desired value All the elements in card array are verified, and complete to compare the full traversal of target return value, and improve interface testing can By property.
Optionally, the content to the target return value compares behaviour with the content execution array of the target desired value Make, also include:
When the length of the target return value is differed or the target return value with the length of the target desired value When the content of element is differed with the content of the element of the target desired value, terminate the array and compare operation, and send report Wrong prompt message.
In the embodiment of the present invention, when any one situation in meeting above-mentioned two situations, it will terminate array and compare operation, And the corresponding prompt message that reports an error can be sent, the prompt message that reports an error is surveyed for pointing out tester's interface to be measured abnormal Examination personnel can repair according to the corresponding prompt message that reports an error to interface to be measured.
Second aspect, there is provided a kind of interface test device, described device includes:
First performing module, for by interface implementation of test cases to be measured, obtaining target return value;
Comparison module, for the content of the target return value and the content of default target desired value to be compared, The target desired value is the requirement documents of the initial return value and test case obtained according to the execution test case Obtain;
Whether judge module is normal for according to comparative result, judging the interface to be measured.
Optionally, described device also includes:
Second performing module, for performing the test case by the interface to be measured, obtains the initial return value;
Determining module, for when the initial return value is identical with the default desired value in the requirement documents, by institute State initial return value and be defined as target desired value.
Optionally, the comparison module, including:
Judging submodule, for judging the data form of the target return value and the data form of the target desired value It is whether identical;
Comparison sub-module, for the data form phase of the data form when the target return value and the target desired value Meanwhile, according to the data type of the target return value, in the content of the target return value and the target desired value Appearance is compared.
Optionally, the comparison sub-module, including:
Determining unit, the data type for determining the target return value, the data type is object or array;
First execution unit, for when the data type is object, to the content of the target return value with it is described The content of target desired value performs object and compares operation;
Second execution unit, for when the data type is array, to the content of the target return value with it is described The content of target desired value performs array and compares operation.
Optionally, the target return value includes keyword and value corresponding with the keyword,
First execution unit, is used for:
Judge the keyword of the target return value number and the keyword of the target desired value number whether phase Together;
When the number of the keyword of the target return value is identical with the number of the keyword of the target desired value, sentence Whether the form of the keyword of the target return value of breaking is identical with the form of the keyword of the target desired value;
When the form of the keyword of the target return value is identical with the form of the keyword of the target desired value, sentence Whether the title of the keyword of the target return value of breaking is identical with the title of the keyword of the target desired value;
When the title of the keyword of the target return value is identical with the title of the keyword of the target desired value, sentence Whether the corresponding value of the keyword value corresponding with the keyword of the target desired value of the target return value of breaking is identical;
The judge module, is used for:
When the corresponding value of the keyword of target return value value corresponding with the keyword of the target desired value is identical When, determine that the interface to be measured is normal.
Optionally, first execution unit, is additionally operable to:
Any one, terminates the object and compares operation, and send the prompt message that reports an error below satisfaction:
The number of the keyword of the target return value is differed with the number of the keyword of the target desired value;
The form of the keyword of the target return value is differed with the form of the keyword of the target desired value;
The title of the keyword of the target return value is differed with the title of the keyword of the target desired value;
The corresponding value of the keyword value corresponding with the keyword of the target desired value of the target return value is differed.
Optionally, second execution unit, is used for:
Judge whether the length of the target return value is identical with the length of the target desired value;
When the length of the target return value is identical with the length of the target desired value, the target return value is judged Element content it is whether identical with the content of the element of the target desired value;
The judge module, is used for:
When the content of the element of the target return value is identical with the content of the element of the target desired value, institute is determined State interface to be measured normal.
Optionally, second execution unit, is additionally operable to:
When the length of the target return value is differed or the target return value with the length of the target desired value When the content of element is differed with the content of the element of the target desired value, terminate the array and compare operation, and send report Wrong prompt message.
The beneficial effect that technical scheme provided in an embodiment of the present invention is brought is:
Interface test method provided in an embodiment of the present invention and device, by from the target return value that interface to be measured is returned Appearance is compared with the content of default target desired value, because the target desired value is returned according to the initial of implementation of test cases Return what the requirement documents of value and the test case were obtained, and in the prior art according to the check post checking return value for pre-setting Corresponding contents are compared, and the embodiment of the present invention can verify all the elements of target return value, it is possible to prevente effectively from test leakage occurs showing As improve the reliability of interface testing.
Brief description of the drawings
Technical scheme in order to illustrate more clearly the embodiments of the present invention, below will be to that will make needed for embodiment description Accompanying drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present invention, for For those of ordinary skill in the art, on the premise of not paying creative work, other can also be obtained according to these accompanying drawings Accompanying drawing.
Fig. 1 is a kind of flow chart of interface test method provided in an embodiment of the present invention;
Fig. 2-1 is the flow chart of another interface test method provided in an embodiment of the present invention;
Fig. 2-2 is the method flow diagram of a kind of comparison object return value provided in an embodiment of the present invention and target desired value;
Fig. 2-3 is provided in an embodiment of the present invention a kind of according to data type comparison object return value and target desired value Method flow diagram;
Fig. 2-4 is the method flow diagram that a kind of execution object provided in an embodiment of the present invention compares operation;
Fig. 2-5 is the method flow diagram that a kind of execution array provided in an embodiment of the present invention compares operation;
Fig. 3 is a kind of structural representation of interface test device provided in an embodiment of the present invention;
Fig. 4-1 is the structural representation of another interface test device provided in an embodiment of the present invention;
Fig. 4-2 is a kind of structural representation of comparison module provided in an embodiment of the present invention;
Fig. 4-3 is a kind of structural representation of comparison sub-module provided in an embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to the application embodiment party Formula is described in further detail.
Fig. 1 is a kind of flow chart of interface test method provided in an embodiment of the present invention, as shown in figure 1, the method can be with Including:
Step 101, by interface implementation of test cases to be measured, obtain target return value.
Step 102, the content of the target return value is compared with the content of default target desired value, the target phase Prestige value is according to the requirement documents acquisition for performing initial return value and the test case that the test case is obtained.
Step 103, according to comparative result, judge whether interface to be measured normal.
In sum, interface test method provided in an embodiment of the present invention, the target return value that will be returned from interface to be measured Content be compared with the content of default target desired value, due to the target desired value be according to implementation of test cases just What the requirement documents of beginning return value and the test case were obtained, returned with being verified according to the check post for pre-setting in the prior art The corresponding contents of value are compared, and the embodiment of the present invention can verify all the elements of target return value, it is possible to prevente effectively from leaking Phenomenon is surveyed, the reliability of interface testing is improve.
Fig. 2-1 is the flow chart of another interface test method provided in an embodiment of the present invention, for service end, such as Fig. 2- Shown in 1, the method can include:
Step 201, by interface implementation of test cases to be measured, obtain initial return value.
It should be noted that before interface testing is carried out to interface to be measured, demand of the tester according to test case Content in document is input into request method, request URL and required parameter etc. in automated test tool, then by interface to be measured A test case is performed, initial return value is obtained, optionally, the initial return value can be held in normal test environment Test case of row is obtained.
Optionally, the present embodiments relate to interface to be measured can be service end system interface.
Step 202, when the default desired value in the requirement documents of the initial return value with test case is identical, will be initial Return value is defined as target desired value.
It should be noted that after a test case has been performed, tester can be according to the demand of the test case Default desired value in document carries out contrast verification to initial return value, when in the content and requirement documents of the initial return value When the content of default desired value is identical, the initial return value can be set to the target desired value in automated test tool. Interface test method provided in an embodiment of the present invention, without setting check post by hand, reduces the maintenance cost of test case, carries Testing efficiency high.
Optionally, when the return parameters of interface to be measured change or test case is changed, one is performed again in home Secondary test case, in the case of tester ensures that new return value is correct, can be set to new mesh by new return value Mark desired value, is easy to subsequently use.Save manpower and testing efficiency can be effectively improved.
Step 203, by interface implementation of test cases to be measured, obtain target return value.
Optionally, the content of service end document according to demand, periodically by interface implementation of test cases to be measured, example, A test case can be performed every half an hour, obtain corresponding target return value.
Step 204, the content of the target return value is compared with the content of default target desired value.
Optionally, service end can by every the content of the target return value obtained after half an hour implementation of test cases with it is pre- If the content of target desired value be compared.
Optionally, the process content of target return value being compared with the content of default target desired value, such as schemes Shown in 2-2, can include:
Whether the data form of step 2041, the data form for judging target return value and target desired value is identical;Work as mesh When the data form of mark return value is identical with the data form of target desired value, step 2042 is performed;When target return value When data form is different from the data form of target desired value, end step.
Optionally, the data form of the target desired value can be JSON (English:JavaScript Object Notiation) form, judges whether the data form of target return value is identical with the data form of target desired value, that is to say, Whether the data form for judging target return value is JSON forms.
It should be noted that JSON forms are based on JavaScript programming language ECMA-262 3rd Edition- A kind of data interchange format of lightweight of the standards of December 1999, including two kinds of data types of object and array.
Step 2042, the data type according to target return value, in the content and target desired value of target return value Appearance is compared.
Specifically, according to the data type of target return value, the content of content and target desired value to target return value The process being compared, as Figure 2-3, can include:
Step 2042a, the data type for determining target return value.
Optionally, the data type of target return value can be object or array.
Step 2042b, when data type is object, the content of target return value is performed with the content of target desired value Object compares operation.
Optionally, when data type is object, target return value can include keyword and value corresponding with keyword, The process that object compares operation is performed with the content of target desired value to the content of target return value, as in Figure 2-4, can be wrapped Include:
Step b1, judge target return value keyword number and the keyword of target desired value number whether phase Together;When the number of the keyword of target return value is identical with the number of the keyword of target desired value, step b2 is performed;Work as mesh When the number for marking the keyword of return value is differed with the number of the keyword of target desired value, step b5 is performed.
Assuming that target desired value is { " city ":" Beijing ", " area ":16800, " population ":1600 }, wherein, Keyword has three, respectively:" city ", " area " and " population ", then service end need to judge that target return value is It is no including three keywords.
It should be noted that the number not phase of number and the keyword of target desired value when the keyword of target return value Meanwhile, service end can compare operation with end object, and send the prompt message that reports an error, for the test for pointing out tester to return Result is wrong.Example, the prompt message that reports an error can be " interface exception, type of error is mismatched for keyword number ".
Step b2, judge target return value keyword form and the keyword of target desired value form whether phase Together;When the form of the keyword of target return value is identical with the form of the keyword of target desired value, step b3 is performed;Work as mesh When the form for marking the keyword of return value is differed with the form of the keyword of target desired value, step b5 is performed.
Optionally, the form of keyword can be integer or character string.
Example, with reference to the example in step b1, the form of keyword " city " and " area " is integer, The form of " population " is character string, then service end needs to judge whether the keyword in target return value is two integers The keyword of form and a keyword for string format.
It should be noted that the form not phase of form and the keyword of target desired value when the keyword of target return value Meanwhile, service end can compare operation with end object, and send the prompt message that reports an error.Assuming that the keyword bag in target return value Include in " city ", " area " and " population ", then the prompt message that reports an error can be for " interface exception, type of error is keyword " people The format mismatching of mouth " ".
Step b3, judge target return value keyword title and the keyword of target desired value title whether phase Together;When the title of the keyword of target return value is identical with the title of the keyword of target desired value, step b4 is performed;Work as mesh When the title for marking the keyword of return value is differed with the title of the keyword of target desired value, step b5 is performed.
Example, with reference to the example in step b1, then service end need to judge return desired value keyword name whether Respectively " city ", " area " and " population ".
It should be noted that the title not phase of title and the keyword of target desired value when the keyword of target return value Meanwhile, service end can compare operation with end object, and send the prompt message that reports an error.Assuming that the keyword bag in target return value Include in " city ", " area " and " number ", then the prompt message that reports an error can be for " interface exception, type of error is keyword The title of " number " is mismatched ".
Step b4, judge target return value the corresponding value of keyword value corresponding with the keyword of target desired value whether It is identical.
Example, with reference to the example in step b1, the corresponding value of keyword " city " is " Beijing ", and keyword " area " is right The value answered is " 16800 ", and the corresponding value of keyword " population " is " 1600 ", then need to judge the key of target return value Whether value corresponding with the keyword of target desired value is identical for the corresponding value of word.
It should be noted that when the corresponding value of the keyword of target return value value corresponding with the keyword of target desired value When different, service end can compare operation with end object, and send the prompt message that reports an error.Assuming that the corresponding value of keyword " city " Be " Beijing ", then this report an error prompt message can for " interface exception, type of error be the corresponding value of keyword " city " not Matching ".
Step b5, end object compare operation, and send the prompt message that reports an error.
The detailed process of step b5 can be corresponded to reference to the explanation in step b1 to step b4.
It should be noted that performing object with the content of target desired value in the content to target return value compares operation When, as long as ensureing that the number of keyword, the form of keyword, the title of keyword and the corresponding value of keyword are compared i.e. Can, the comparative sequence of above-mentioned steps b1 to step b4 is a kind of optional comparative sequence provided in an embodiment of the present invention, the present invention Embodiment is not limited comparative sequence.
Step 2042c, when data type is array, the content of target return value is performed with the content of target desired value Array compares operation.
Optionally, when data type is array, number is performed with the content of target desired value to the content of target return value Group compares the process of operation, as shown in Figure 2-5, can include:
Whether the length of step c1, the length for judging target return value and target desired value is identical;When target return value When length is identical with the length of target desired value, step c2 is performed;When the length and the length of target desired value of target return value When differing, step c3 is performed.
It should be noted that the length of the array of target desired value that is to say the number of element in array.Assuming that the target phase Prestige value is array [" Beijing ", 16800,1600], and the length of the array is 3, then during service end needs to judge target return value Whether the length of array is 3.
It should be noted that when the length of the array of target return value is differed with the length of the array of target desired value When, service end can terminate array and compare operation, and send the prompt message that reports an error.Example, the prompt message that reports an error can be " interface exception, type of error is mismatched for array length ".
Step c2, judge target return value element content and target desired value element content it is whether identical.
Example, with reference to the example in step c1, the content of element is respectively " Beijing ", " 16800 " in target desired value " 1600 ", then service end need to judge three contents of element in target return value whether with the element of target desired value Content is identical.
It should be noted that when the content of the element of target return value is differed with the content of the element of target desired value When, service end can terminate array and compare operation, and send the prompt message that reports an error.Assuming that the element of target return value include " on Sea ", " 16800 " and " 1600 ", this report an error prompt message can for " interface exception, type of error for element " Shanghai " content not Matching ".
Step c3, end array compare operation, and send the prompt message that reports an error.
The detailed process of step c3 can be corresponded to reference to the explanation in step c1 and step c2.
Step 205, according to comparative result, judge whether interface to be measured normal.
Optionally, when data type is object, above-mentioned steps b1 is to step b4 for correspondence, then exist:When target return value Keyword corresponding with the keyword of the target desired value value of corresponding value it is identical when, service end determines that interface to be measured is normal.
Optionally, when data type is array, correspondence above-mentioned steps c1 and step c2 is then present:When target return value Element content it is identical with the content of the element of target desired value when, service end determines that interface to be measured is normal.
It should be noted that the data of JSON forms can be nested, such as object can also may be used with nested array, array With nested object.For the data of this nested form, use the interface test method provided in an embodiment of the present invention equally can be with Realize the purpose being compared with the content of default target desired value to the content of target return value.
Optionally, when the data type of target return value is object, the data class of the corresponding value of keyword in object Type can be object, array or data.Wherein, data can include digital (integer or floating number), character string and logical value (true or false), when the data type of the corresponding value of keyword is data, can direct comparison object return value key Whether the corresponding value of word value corresponding with the keyword of target desired value is identical;When the data type of the corresponding value of keyword is right As when, object is performed to the corresponding value of keyword of target return value value corresponding with the keyword of target desired value and compares behaviour Make;When the data type of the corresponding value of keyword is array, the corresponding value of keyword to target return value is expected with target The corresponding value of keyword of value performs array and compares operation, so as to reach in the content and target return value to target return value Appearance carries out the effect that recurrence travels through contrast entirely, and test content more comprehensively, improves the reliability of interface testing.
Optionally, when the data type of target return value is array, the data type of the content of element can for object, Array or data.When the data type of the content of element is data, can the direct element of comparison object return value content Whether the content with the element of target desired value is identical;When the data type of the content of element is object, to target return value The content of content and the element of target desired value of element perform object and compare operation;When the data type of the content of element is During array, the content of element to target return value compares operation with the content execution array of the element of target desired value, so that Reaching carries out the effect that recurrence travels through contrast entirely to the content of target return value and the content of target return value, and test content is more complete Face, improves the reliability of interface testing.
In sum, interface test method provided in an embodiment of the present invention, the target return value that will be returned from interface to be measured Content and the content of default target desired value carry out recurrence traversal compare entirely, because the target desired value is according to performing survey What the initial return value of example on probation and the requirement documents of the test case were obtained, with the checking that basis pre-sets in the prior art The corresponding contents of point checking return value are compared, and the embodiment of the present invention can verify all the elements of target return value, test content More comprehensively, it is possible to prevente effectively from there is test leakage phenomenon, improve the reliability of interface testing.
Fig. 3 is a kind of structural representation of interface test device 30 provided in an embodiment of the present invention, as shown in figure 3, the dress Putting 30 includes:
First performing module 301, for by interface implementation of test cases to be measured, obtaining target return value.
Comparison module 302, for the content of target return value to be compared with the content of default target desired value, should Target desired value is according to the requirement documents acquisition for performing initial return value and the test case that the test case is obtained.
Judge module 303, for according to comparative result, judging whether interface to be measured is normal.
In sum, interface test device provided in an embodiment of the present invention, will be returned by comparison module from interface to be measured The content of target return value be compared with the content of default target desired value, because the target desired value is according to execution What the initial return value of test case and the requirement documents of the test case were obtained, tested with check post is set in the prior art The content for demonstrate,proving return value is compared, and the embodiment of the present invention can verify all the elements of target return value, it is possible to prevente effectively from occurring Test leakage phenomenon, improves the reliability of interface testing.
Optionally, as shown in Fig. 4-1, the device 30 can also include:
Second performing module 304, for performing the test case by interface to be measured, obtains initial return value.
Determining module 305, for when initial return value is identical with the default desired value in requirement documents, this initially being returned Return value and be defined as target desired value.
Other mark implications in Fig. 4-1 may be referred to Fig. 3.
Optionally, as shown in the Fig. 4-2, comparison module 302 can include:
Judging submodule 3021, for judge the data form of target return value and target desired value data form whether It is identical.
Comparison sub-module 3022, for when the data form of target return value and the data form of target desired value it is identical When, according to the data type of target return value, the content of target return value is compared with the content of target desired value.
Optionally, as shown in Fig. 4-3, comparison sub-module 3022 can include:
Determining unit 3022a, the data type for determining target return value, the data type is object or array.
First execution unit 3022b, for when data type is object, content and target to target return value to be expected The content of value performs object and compares operation.
Second execution unit 3022c, for when data type is array, content and target to target return value to be expected The content of value performs array and compares operation.
Optionally, on the one hand, when data type be object when, target return value can include keyword and with keyword pair The value answered, first execution unit 3022b can be used for:
Judge whether the number of the keyword of target return value is identical with the number of the keyword of target desired value;Work as target When the number of the keyword of return value is identical with the number of the keyword of target desired value, the keyword of target return value is judged Whether form is identical with the form of the keyword of target desired value;When the form and target desired value of the keyword of target return value Keyword form it is identical when, judge the title of the keyword of target return value is with the title of the keyword of target desired value It is no identical;When the title of the keyword of target return value is identical with the title of the keyword of target desired value, judge that target is returned Whether the corresponding value of the keyword value corresponding with the keyword for stating target desired value for returning value is identical.
Accordingly, judge module 303 can be used for:
When the corresponding value of the keyword of target return value value corresponding with the keyword of target desired value is identical, it is determined that treating Survey interface normal.
Optionally, first execution unit 3022b, can be also used for:
Any one, terminates the object and compares operation, and send the prompt message that reports an error below satisfaction:
The number of the keyword of target return value is differed with the number of the keyword of target desired value;Target return value The form of keyword is differed with the form of the keyword of target desired value;The title of the keyword of target return value and target phase The title of the keyword of prestige value is differed;The corresponding value of keyword of target return value is corresponding with the keyword of target desired value Value is differed.
On the other hand, when data type is array, target return value can include element, the second execution unit 3022c Can be used for:
Judge whether the length of target return value is identical with the length of target desired value;When the length and mesh of target return value Mark desired value length it is identical when, judge the element of target return value content and the element of target desired value content whether phase Together.
Accordingly, judge module 303 can be used for:
When the content of the element of target return value is identical with the content of the element of target desired value, interface to be measured is being determined just Often.
Optionally, the second execution unit 3022c, can be also used for:
When the length of target return value and the length of target desired value differ or target return value element content with When the content of the element of target desired value is differed, terminate array and compare operation, and send the prompt message that reports an error.
Optionally, above-mentioned data form can be JSON forms.
In sum, interface test device provided in an embodiment of the present invention, will be returned by comparison module from interface to be measured The content of target return value and the content of default target desired value carry out recurrence traversal compare entirely, due to the target desired value It is to be obtained according to the initial return value of implementation of test cases and the requirement documents of the test case, it is pre- with basis in the prior art The corresponding contents of the check post checking return value for first setting are compared, and the embodiment of the present invention can verify all interior of target return value Hold, test content more comprehensively, it is possible to prevente effectively from there is test leakage phenomenon, improves the reliability of interface testing.
It is apparent to those skilled in the art that, for convenience and simplicity of description, the device of foregoing description With the specific work process of module, the corresponding process in preceding method embodiment is may be referred to, will not be repeated here.
One of ordinary skill in the art will appreciate that realizing that all or part of step of above-described embodiment can be by hardware To complete, it is also possible to instruct the hardware of correlation to complete by program, described program can be stored in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only storage, disk or CD etc..
The foregoing is only alternative embodiment of the invention, be not intended to limit the invention, it is all it is of the invention spirit and Within principle, any modification, equivalent substitution and improvements made etc. should be included within the scope of the present invention.

Claims (16)

1. a kind of interface test method, it is characterised in that methods described includes:
By interface implementation of test cases to be measured, target return value is obtained;
The content of the target return value and the content of default target desired value are compared, the target desired value is root According to the requirement documents acquisition for performing initial return value and the test case that the test case is obtained;
According to comparative result, judge whether the interface to be measured is normal.
2. method according to claim 1, it is characterised in that it is described by interface implementation of test cases to be measured before, Methods described also includes:
The test case is performed by the interface to be measured, the initial return value is obtained;
When the initial return value is identical with the default desired value in the requirement documents, the initial return value is defined as Target desired value.
3. method according to claim 1, it is characterised in that the content by the target return value and default mesh The content for marking desired value is compared, including:
Judge whether the data form of the target return value is identical with the data form of the target desired value;
When the data form of the target return value is identical with the data form of the target desired value, returned according to the target The data type of value is returned, content and the content of the target desired value to the target return value are compared.
4. method according to claim 3, it is characterised in that
The data type according to the target return value, to content and the target desired value of the target return value Content is compared, including:
Determine the data type of the target return value, the data type is object or array;
When the data type is object, it is right that the content of the target return value and the content of the target desired value are performed As comparing operation;
When the data type is array, number is performed with the content of the target desired value to the content of the target return value Group compares operation.
5. method according to claim 4, it is characterised in that the target return value include keyword and with the key The corresponding value of word,
The content to the target return value performs object and compares operation with the content of the target desired value, including:
Judge whether the number of the keyword of the target return value is identical with the number of the keyword of the target desired value;
When the number of the keyword of the target return value is identical with the number of the keyword of the target desired value, institute is judged Whether the form for stating the keyword of target return value is identical with the form of the keyword of the target desired value;
When the form of the keyword of the target return value is identical with the form of the keyword of the target desired value, institute is judged Whether the title for stating the keyword of target return value is identical with the title of the keyword of the target desired value;
When the title of the keyword of the target return value is identical with the title of the keyword of the target desired value, institute is judged Whether the corresponding value of the keyword value corresponding with the keyword of the target desired value for stating target return value is identical;
It is described to judge whether interface to be measured is normal according to comparative result, including:
When the corresponding value of the keyword of target return value value corresponding with the keyword of the target desired value is identical, really The fixed interface to be measured is normal.
6. method according to claim 5, it is characterised in that the content to the target return value and the target The content of desired value performs object and compares operation, also includes:
Any one, terminates the object and compares operation, and send the prompt message that reports an error below satisfaction:
The number of the keyword of the target return value is differed with the number of the keyword of the target desired value;
The form of the keyword of the target return value is differed with the form of the keyword of the target desired value;
The title of the keyword of the target return value is differed with the title of the keyword of the target desired value;
The corresponding value of the keyword value corresponding with the keyword of the target desired value of the target return value is differed.
7. method according to claim 4, it is characterised in that the content to the target return value and the target The content of desired value performs array and compares operation, including:
Judge whether the length of the target return value is identical with the length of the target desired value;
When the length of the target return value is identical with the length of the target desired value, the unit of the target return value is judged Whether the content of element is identical with the content of the element of the target desired value;
It is described to judge whether the interface to be measured is normal according to comparative result, including:
When the content of the element of the target return value is identical with the content of the element of the target desired value, it is determined that described treat Survey interface normal.
8. method according to claim 7, it is characterised in that the content to the target return value and the target The content of desired value performs array and compares operation, also includes:
When the length of the target return value differed with the length of the target desired value or the target return value element Content when being differed with the content of the element of the target desired value, terminate the array and compare operation, and send to report an error and carry Show information.
9. a kind of interface test device, it is characterised in that described device includes:
First performing module, for by interface implementation of test cases to be measured, obtaining target return value;
Comparison module, it is described for the content of the target return value and the content of default target desired value to be compared Target desired value is according to the requirement documents acquisition for performing initial return value and the test case that the test case is obtained 's;
Whether judge module is normal for according to comparative result, judging the interface to be measured.
10. device according to claim 9, it is characterised in that described device also includes:
Second performing module, for performing the test case by the interface to be measured, obtains the initial return value;
Determining module, for when the initial return value is identical with the default desired value in the requirement documents, will it is described just Beginning return value is defined as target desired value.
11. devices according to claim 9, it is characterised in that the comparison module, including:
Judging submodule, for judge the data form of the target return value and the target desired value data form whether It is identical;
Comparison sub-module, for when the data form of the target return value it is identical with the data form of the target desired value When, according to the data type of the target return value, to the content of the content of the target return value and the target desired value It is compared.
12. devices according to claim 11, it is characterised in that
The comparison sub-module, including:
Determining unit, the data type for determining the target return value, the data type is object or array;
First execution unit, for when the data type is object, to content and the target of the target return value The content of desired value performs object and compares operation;
Second execution unit, for when the data type is array, to content and the target of the target return value The content of desired value performs array and compares operation.
13. devices according to claim 12, it is characterised in that the target return value include keyword and with the pass The corresponding value of key word,
First execution unit, is used for:
Judge whether the number of the keyword of the target return value is identical with the number of the keyword of the target desired value;
When the number of the keyword of the target return value is identical with the number of the keyword of the target desired value, institute is judged Whether the form for stating the keyword of target return value is identical with the form of the keyword of the target desired value;
When the form of the keyword of the target return value is identical with the form of the keyword of the target desired value, institute is judged Whether the title for stating the keyword of target return value is identical with the title of the keyword of the target desired value;
When the title of the keyword of the target return value is identical with the title of the keyword of the target desired value, institute is judged Whether the corresponding value of the keyword value corresponding with the keyword of the target desired value for stating target return value is identical;
The judge module, is used for:
When the corresponding value of the keyword of target return value value corresponding with the keyword of the target desired value is identical, really The fixed interface to be measured is normal.
14. devices according to claim 13, it is characterised in that first execution unit, are additionally operable to:
Any one, terminates the object and compares operation, and send the prompt message that reports an error below satisfaction:
The number of the keyword of the target return value is differed with the number of the keyword of the target desired value;
The form of the keyword of the target return value is differed with the form of the keyword of the target desired value;
The title of the keyword of the target return value is differed with the title of the keyword of the target desired value;
The corresponding value of the keyword value corresponding with the keyword of the target desired value of the target return value is differed.
15. devices according to claim 12, it is characterised in that second execution unit, are used for:
Judge whether the length of the target return value is identical with the length of the target desired value;
When the length of the target return value is identical with the length of the target desired value, the unit of the target return value is judged Whether the content of element is identical with the content of the element of the target desired value;
The judge module, is used for:
When the content of the element of the target return value is identical with the content of the element of the target desired value, it is determined that described treat Survey interface normal.
16. devices according to claim 15, it is characterised in that second execution unit, are additionally operable to:
When the length of the target return value differed with the length of the target desired value or the target return value element Content when being differed with the content of the element of the target desired value, terminate the array and compare operation, and send to report an error and carry Show information.
CN201611179931.8A 2016-12-19 2016-12-19 Interface test method and device Pending CN106776324A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611179931.8A CN106776324A (en) 2016-12-19 2016-12-19 Interface test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611179931.8A CN106776324A (en) 2016-12-19 2016-12-19 Interface test method and device

Publications (1)

Publication Number Publication Date
CN106776324A true CN106776324A (en) 2017-05-31

Family

ID=58890585

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611179931.8A Pending CN106776324A (en) 2016-12-19 2016-12-19 Interface test method and device

Country Status (1)

Country Link
CN (1) CN106776324A (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107357735A (en) * 2017-07-20 2017-11-17 万帮充电设备有限公司 Discount method of testing and device
CN107948744A (en) * 2017-12-13 2018-04-20 深圳市雷鸟信息科技有限公司 Interface detection method, interface detection device and computer-readable recording medium
CN108089985A (en) * 2017-12-14 2018-05-29 中国平安人寿保险股份有限公司 Method of calibration, device, equipment and the readable storage medium storing program for executing of interface return parameters
CN108089956A (en) * 2017-12-07 2018-05-29 畅捷通信息技术股份有限公司 Verify the method and system of the returned data of interface
CN108959065A (en) * 2018-05-17 2018-12-07 烽火通信科技股份有限公司 The verification method and system of software interface test parameter
CN109032956A (en) * 2018-09-11 2018-12-18 郑州云海信息技术有限公司 A kind of interface test method and device
CN109165127A (en) * 2018-08-29 2019-01-08 北京奇艺世纪科技有限公司 Localization method, device and the electronic equipment of problem interface
CN109714418A (en) * 2018-12-27 2019-05-03 北京潘达互娱科技有限公司 The comparison method of interface returned data calculates equipment
CN109857634A (en) * 2018-12-15 2019-06-07 中国平安人寿保险股份有限公司 Interface testing parameter verification method, apparatus, electronic equipment and storage medium
CN110046086A (en) * 2018-12-20 2019-07-23 阿里巴巴集团控股有限公司 Expected data generation method and device and electronic equipment for test
WO2020006930A1 (en) * 2018-07-05 2020-01-09 平安科技(深圳)有限公司 Data forgery method and apparatus, and computer storage medium
CN112214395A (en) * 2020-09-02 2021-01-12 浙江大搜车融资租赁有限公司 Interface testing method based on flow data, electronic device and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101814052A (en) * 2010-02-04 2010-08-25 浪潮集团山东通用软件有限公司 Automatic test method
CN102981958A (en) * 2012-12-19 2013-03-20 青岛海信传媒网络技术有限公司 Method and device for testing software
CN103488482A (en) * 2013-09-16 2014-01-01 深圳市龙视传媒有限公司 Method and device for generating test cases
CN104360920A (en) * 2014-12-02 2015-02-18 微梦创科网络科技(中国)有限公司 Automatic testing method and device for interface
CN104657268A (en) * 2015-02-13 2015-05-27 厦门美图之家科技有限公司 Two-factor authentication method and device for API (application program interface) compatibility
CN104899136A (en) * 2015-05-15 2015-09-09 百度在线网络技术(北京)有限公司 Method and device used for generating test case
CN105760292A (en) * 2014-12-18 2016-07-13 阿里巴巴集团控股有限公司 Assertion verification method and device for unit testing

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101814052A (en) * 2010-02-04 2010-08-25 浪潮集团山东通用软件有限公司 Automatic test method
CN102981958A (en) * 2012-12-19 2013-03-20 青岛海信传媒网络技术有限公司 Method and device for testing software
CN103488482A (en) * 2013-09-16 2014-01-01 深圳市龙视传媒有限公司 Method and device for generating test cases
CN104360920A (en) * 2014-12-02 2015-02-18 微梦创科网络科技(中国)有限公司 Automatic testing method and device for interface
CN105760292A (en) * 2014-12-18 2016-07-13 阿里巴巴集团控股有限公司 Assertion verification method and device for unit testing
CN104657268A (en) * 2015-02-13 2015-05-27 厦门美图之家科技有限公司 Two-factor authentication method and device for API (application program interface) compatibility
CN104899136A (en) * 2015-05-15 2015-09-09 百度在线网络技术(北京)有限公司 Method and device used for generating test case

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
何国民: "《现代大学计算机基础》", 30 September 2015 *

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107357735A (en) * 2017-07-20 2017-11-17 万帮充电设备有限公司 Discount method of testing and device
CN108089956A (en) * 2017-12-07 2018-05-29 畅捷通信息技术股份有限公司 Verify the method and system of the returned data of interface
CN108089956B (en) * 2017-12-07 2021-05-04 畅捷通信息技术股份有限公司 Method and system for verifying returned data of interface
CN107948744A (en) * 2017-12-13 2018-04-20 深圳市雷鸟信息科技有限公司 Interface detection method, interface detection device and computer-readable recording medium
CN107948744B (en) * 2017-12-13 2021-11-09 深圳市雷鸟网络传媒有限公司 Interface detection method, interface detection device, and computer-readable storage medium
CN108089985A (en) * 2017-12-14 2018-05-29 中国平安人寿保险股份有限公司 Method of calibration, device, equipment and the readable storage medium storing program for executing of interface return parameters
CN108089985B (en) * 2017-12-14 2020-09-29 中国平安人寿保险股份有限公司 Method, device and equipment for verifying interface return parameters and readable storage medium
CN108959065A (en) * 2018-05-17 2018-12-07 烽火通信科技股份有限公司 The verification method and system of software interface test parameter
WO2020006930A1 (en) * 2018-07-05 2020-01-09 平安科技(深圳)有限公司 Data forgery method and apparatus, and computer storage medium
CN109165127A (en) * 2018-08-29 2019-01-08 北京奇艺世纪科技有限公司 Localization method, device and the electronic equipment of problem interface
CN109165127B (en) * 2018-08-29 2022-09-02 北京奇艺世纪科技有限公司 Problem interface positioning method and device and electronic equipment
CN109032956B (en) * 2018-09-11 2022-03-22 郑州云海信息技术有限公司 Interface testing method and device
CN109032956A (en) * 2018-09-11 2018-12-18 郑州云海信息技术有限公司 A kind of interface test method and device
CN109857634A (en) * 2018-12-15 2019-06-07 中国平安人寿保险股份有限公司 Interface testing parameter verification method, apparatus, electronic equipment and storage medium
CN110046086A (en) * 2018-12-20 2019-07-23 阿里巴巴集团控股有限公司 Expected data generation method and device and electronic equipment for test
CN109714418A (en) * 2018-12-27 2019-05-03 北京潘达互娱科技有限公司 The comparison method of interface returned data calculates equipment
CN112214395A (en) * 2020-09-02 2021-01-12 浙江大搜车融资租赁有限公司 Interface testing method based on flow data, electronic device and storage medium

Similar Documents

Publication Publication Date Title
CN106776324A (en) Interface test method and device
US9165100B2 (en) Methods and apparatus to map schematic elements into a database
CN106502883B (en) The database synchronization method and system of client and server-side when automatic test
CN109726136A (en) Test method, device, equipment and the storage medium of database
CN108959067B (en) Method and device for testing search engine and computer readable storage medium
WO2015176431A1 (en) Method and device for generating test data
CN105138461A (en) Interface testing method and device for application program
CN103942138A (en) Testing method and device
CN107508727B (en) Automatic network card information checking method and device
CN104462983B (en) A kind of PHP source code processing method and system
CN106681783A (en) Detection method and system for SVN code
CN104133768A (en) Program code review method and program code review device
CN108804315B (en) Test method and device applied to dynamic development, electronic equipment and storage medium
CN105117340B (en) URL detection methods and device for iOS browser application quality evaluations
CN113486358A (en) Vulnerability detection method and device
CN112612706A (en) Automated testing method, computer device and storage medium
CN105703964A (en) Online application system test method and equipment
CN109086202B (en) FPGA/IP core code rule checking method based on association rule
CN113300912B (en) Equipment testing method and device and electronic equipment
CN103250136B (en) The method quoted during for verifying operation
CN105608006B (en) A kind of program error detection method and system based on probabilistic model
CN114116522A (en) Swagger-based method for automatically testing interface
CN105893241A (en) Updating method and device for test data
CN106707144B (en) Reverse analysis method applied to antifuse Field Programmable Gate Array (FPGA) test vector
CN106933888A (en) Database configuration management system

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
CB02 Change of applicant information

Address after: 510660 Guangzhou City, Guangzhou, Guangdong, Whampoa Avenue, No. 315, self - made 1-17

Applicant after: Guangzhou KuGou Networks Co., Ltd.

Address before: 510000 B1, building, No. 16, rhyme Road, Guangzhou, Guangdong, China 13F

Applicant before: Guangzhou KuGou Networks Co., Ltd.

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20170531

RJ01 Rejection of invention patent application after publication