CN108446190B - Interface test method and device - Google Patents

Interface test method and device Download PDF

Info

Publication number
CN108446190B
CN108446190B CN201710084564.1A CN201710084564A CN108446190B CN 108446190 B CN108446190 B CN 108446190B CN 201710084564 A CN201710084564 A CN 201710084564A CN 108446190 B CN108446190 B CN 108446190B
Authority
CN
China
Prior art keywords
interface
tested
test case
automatic test
parameter
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.)
Active
Application number
CN201710084564.1A
Other languages
Chinese (zh)
Other versions
CN108446190A (en
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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital 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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201710084564.1A priority Critical patent/CN108446190B/en
Publication of CN108446190A publication Critical patent/CN108446190A/en
Application granted granted Critical
Publication of CN108446190B publication Critical patent/CN108446190B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2205Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
    • G06F11/2221Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested to test input/output devices or peripheral units

Abstract

The embodiment of the invention discloses an interface testing method and device, and belongs to the technical field of computers. The method comprises the following steps: acquiring structured interface data of an interface to be tested, wherein the structured interface data of the interface to be tested refers to interface data of the interface to be tested expressed according to a preset specification; the interface data of the interface to be tested is used for describing basic information of the interface to be tested; generating an executable automatic test case according to the structured interface data of the interface to be tested; and testing the interface to be tested through the automatic test case to obtain a test result. The technical scheme provided by the embodiment of the invention improves the efficiency of compiling the test case and the efficiency of interface test.

Description

Interface test method and device
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to an interface testing method and device.
Background
At present, electronic devices usually implement various functions through interfaces. In order to ensure that the electronic device can perform its functions, it is usually necessary to verify the correctness and stability of the interface, i.e. interface test.
The interface test method provided by the prior art is as follows: the method comprises the steps that a tester writes a test case corresponding to an interface to be tested in advance, sends an interface request message corresponding to the test case to the interface to be tested, receives a response message fed back by the interface to be tested, and determines a test result according to the interface request message and the response message corresponding to the test case. In practical application, each interface corresponds to a parameter, each parameter may have a plurality of values, and each test case includes values of all the parameters. In order to ensure the comprehensiveness of the interface test, a tester needs to write a plurality of test cases so that the plurality of test cases can cover the combination of all parameter values.
In the prior art, a tester needs to manually compile test cases, and when the parameters of an interface are more, the tester needs to manually compile dozens of or even hundreds of test cases, so that the efficiency of compiling the test cases is low, and the efficiency of testing the interface is low.
Disclosure of Invention
In order to solve the problems that in the prior art, a tester needs to manually compile a test case, so that the efficiency of compiling the test case is low, and the efficiency of testing an interface is low, embodiments of the present invention provide an interface testing method and apparatus. The technical scheme is as follows:
in a first aspect, a method for testing an interface is provided, where the method includes:
acquiring structured interface data of an interface to be tested, wherein the structured interface data of the interface to be tested refers to the interface data of the interface to be tested expressed according to a preset specification; the interface data of the interface to be tested is used for describing basic information of the interface to be tested;
generating an executable automatic test case according to the structured interface data of the interface to be tested;
and testing the interface to be tested through the automatic test case to obtain a test result.
Optionally, the structured interface data of the interface to be tested includes: at least one parameter of the interface to be tested, a value example of each parameter, at least one value range of each parameter, and an expected result corresponding to each value range of each parameter;
the generating an executable automatic test case according to the structured interface data of the interface to be tested comprises the following steps:
reading value examples of all parameters of the interface to be tested from the structured interface data of the interface to be tested, and generating an executable automatic test case template according to the value examples of all the parameters;
reading the value range of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and generating n test objects according to the value range of each parameter; comparing the actual value of each parameter included in each test object with the value example of each parameter, wherein the value of one parameter is different, and n is an integer greater than 1;
and replacing the value examples of the parameters in the automatic test case template with the n test objects respectively to generate n automatic test cases, wherein each automatic test case corresponds to an expected result.
Optionally, the obtaining the structured interface data of the interface to be tested includes:
acquiring interface data of the interface to be tested;
and according to the preset specification, converting the interface data of the interface to be tested into the structured interface data of the interface to be tested.
Optionally, the testing the interface to be tested through the automated test case to obtain a test result, including:
executing the automatic test case by adopting an automatic test frame to obtain an execution result corresponding to the automatic test case;
and for each automatic test case, comparing the execution result and the expected result corresponding to the automatic test case to obtain the test result corresponding to the automatic test case.
Optionally, after the testing the interface to be tested by the automated test case to obtain a test result, the method further includes:
and respectively carrying out association matching on each automatic test case and the corresponding test result to generate the automatic test case with the test result.
In a second aspect, there is provided an interface testing apparatus, the apparatus comprising:
the data acquisition module is used for acquiring structured interface data of an interface to be tested, wherein the structured interface data of the interface to be tested refers to the interface data of the interface to be tested expressed according to a preset specification; the interface data of the interface to be tested is used for describing basic information of the interface to be tested;
the case generating module is used for generating an executable automatic test case according to the structured interface data of the interface to be tested;
and the interface testing module is used for testing the interface to be tested through the automatic testing case to obtain a testing result.
Optionally, the structured interface data of the interface to be tested includes: at least one parameter of the interface to be tested, a value example of each parameter, at least one value range of each parameter, and an expected result corresponding to each value range of each parameter;
the use case generation module comprises:
the template generating unit is used for reading value examples of all parameters of the interface to be tested from the structured interface data of the interface to be tested and generating an executable automatic test case template according to the value examples of all the parameters;
the object generating unit is used for reading the value range of each parameter of the interface to be tested from the structured interface data of the interface to be tested and generating n test objects according to the value range of each parameter; comparing the actual value of each parameter included in each test object with the value example of each parameter, wherein the value of one parameter is different, and n is an integer greater than 1;
and the case generating unit is used for adopting the n test objects to respectively replace the value examples of the parameters in the automatic test case template to generate n automatic test cases, and each automatic test case corresponds to an expected result.
Optionally, the data obtaining module includes:
the data acquisition unit is used for acquiring interface data of the interface to be tested;
and the data conversion unit is used for converting the interface data of the interface to be tested into the structured interface data of the interface to be tested according to the preset specification.
Optionally, the interface test module includes:
the case execution unit is used for executing the automatic test case by adopting an automatic test frame to obtain an execution result corresponding to the automatic test case;
and the result acquisition unit is used for comparing the execution result and the expected result corresponding to each automatic test case to obtain the test result corresponding to the automatic test case.
Optionally, the apparatus further comprises:
and the case updating module is used for respectively carrying out correlation matching on each automatic test case and the corresponding test result to generate the automatic test case with the test result.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
the method comprises the steps of generating an executable automatic test case according to structured interface data of an interface to be tested by acquiring the structured interface data of the interface to be tested, and then testing the interface to be tested through the automatic test case to obtain a test result; the problems that in the prior art, test cases need to be manually compiled by testers, so that the compiling efficiency of the test cases is low, and the interface testing efficiency is low are solved; on one hand, the test case can be automatically compiled, so that the efficiency of compiling the test case is improved; on the other hand, the test case is an executable automatic test case which is an executable file and can be automatically executed by the electronic equipment, so that the efficiency of interface testing is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow chart of a method for testing an interface according to an embodiment of the present invention;
FIG. 2 is a flow chart of step 102 involved in the embodiment shown in FIG. 1;
FIG. 3 is a block diagram of an interface test apparatus provided in one embodiment of the present invention;
FIG. 4 is a block diagram of an interface test apparatus according to another embodiment of the present invention;
fig. 5 is a block diagram of an electronic device provided by an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
In the embodiment of the invention, the method for automatically compiling the test case is provided, so that the efficiency of compiling the test case is improved. In addition, the test case related in the embodiment of the present invention is an executable automated test case, and the automated test case is an executable file that can be automatically executed by the electronic device, so that the efficiency of the interface test can also be improved. The embodiments of the present invention will be described in further detail below based on the common aspects related to the embodiments of the present invention described above.
In the method provided by the embodiment of the invention, the execution main body of each step can be electronic equipment. For example, the electronic device may be a PC (Personal Computer), a server, or the like. In addition, in the embodiment of the present invention, the type of the interface to be tested is not limited, and the interface to be tested is, for example, a Web Service interface (Web Service) interface, an HTTP (HyperText Transfer Protocol) interface, or the like.
Referring to fig. 1, a flowchart of an interface testing method according to an embodiment of the present invention is shown. The method may include several steps as follows.
Step 101, obtaining structured interface data of an interface to be tested.
The structured interface data of the interface to be tested refers to the interface data of the interface to be tested expressed according to the preset specification.
The preset specification refers to a specification set according to an identification rule of the electronic device. Optionally, the preset specification is set according to a data type that can be recognized by the electronic device, for example, the data type that can be recognized by the electronic device is in a JSON (JavaScript Object notification) format, and then the preset specification is to represent the interface data of the interface to be tested into the JSON format.
The interface data of the interface to be tested is used for describing basic information of the interface to be tested. Optionally, the interface data of the interface to be tested may be read from an original interface document of the interface to be tested, which includes a name of the interface to be tested, a service address, parameters of the interface to be tested, interpretation information of each parameter, value examples of each parameter, and the like.
The service address of the interface to be tested is a URL (Uniform Resource Locator) address corresponding to the interface to be tested, and is used to indicate an address for calling the interface to be tested on the internet. The interpretation information of the parameter comprises the name and the type of the parameter, at least one value range corresponding to the parameter, and an expected result and an error code corresponding to the value range. The value example of each parameter refers to a parameter value corresponding to each parameter when the interface to be tested can realize the function thereof, and the value example of each parameter may be a specific numerical value or a value range.
Optionally, the interface data of the interface to be tested may further include other information of the precondition and the operation step waiting for the test interface, and the embodiment of the present invention does not limit the specific content included in the interface data of the interface to be tested.
Optionally, step 101 comprises the following two substeps:
1. acquiring interface data of an interface to be tested;
2. and according to a preset standard, converting the interface data of the interface to be tested into the structured interface data of the interface to be tested.
The electronic equipment obtains interface data of the interface to be tested in advance, and then converts the interface data of the interface to be tested into structured interface data of the interface to be tested, which can be identified by the electronic equipment, according to a preset specification.
In one specific example, the interface data of the interface to be tested may refer to table 1:
TABLE 1
Figure BDA0001226976930000061
Figure BDA0001226976930000071
In table 1, the service address, the interface name, each parameter, and the name, data type, length, and parameter description corresponding to the parameter, which correspond to the interface to be tested, need to be expressed in JSON format. In a specific example, when the list of parameters included in the interface to be tested is expressed in JSON format, the result is as follows: para _ list [ "arejson", "pagesize", "start", "threshold" ]. It should be noted that the conversion of the structured data may be performed manually or automatically by an electronic device.
And 102, generating an executable automatic test case according to the structured interface data of the interface to be tested.
Test cases are a set of test inputs, execution conditions, and expected results that are formulated to verify the correctness and stability of an application in order to test a certain application path or verify that a certain requirement is met. In the prior art, a test case is written by a tester, and before an electronic device performs a test, the test case generally needs to be subjected to corresponding format conversion.
The automatic test case is a test case that can be automatically executed by the electronic device, that is, the electronic device does not need to perform corresponding processing on the automatic test case before testing.
In the embodiment of the invention, each automatic test case corresponds to a value of a parameter in the interface to be tested, and the electronic equipment automatically executes the automatic test cases so as to verify whether the parameter corresponding to the automatic test case can realize the expected function of the automatic test case, thereby realizing the test of the interface to be tested.
After the electronic equipment acquires the structured interface data of the interface to be tested, an automatic test case can be generated, and the automatic test case can be automatically executed by the electronic equipment, so that the problem that interface testing efficiency is low due to the fact that a large amount of manual intervention is needed in interface testing in the prior art is solved, the labor cost of the interface testing can be reduced, and the efficiency of the interface testing is improved.
The following explains the steps of generating an automated test case for an electronic device with reference to specific contents of structured data of an interface to be tested.
Optionally, the structured interface data of the interface to be tested includes: the method comprises the steps of obtaining at least one parameter of an interface to be tested, a value example of each parameter, at least one value range of each parameter and an expected result corresponding to each value range of each parameter.
The at least one parameter of the interface to be tested refers to all parameters of the interface to be tested, a parameter value of each parameter corresponds to a plurality of value ranges, each value range corresponds to an expected result, and the expected result can be directly obtained from parameter interpretation information in interface data of the interface to be tested. For example, the interface to be tested has a parameter with a parameter name Pagesize, the parameter type of the parameter is int, and the corresponding value range and the expected result thereof can refer to table 2:
TABLE 2
Figure BDA0001226976930000081
Optionally, step 102 comprises the following three substeps:
step 102a, reading value examples of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and generating an executable automatic test case template according to the value examples of each parameter.
The electronic equipment firstly obtains a value example of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and then generates an automatic test case template according to the value examples of each parameter. The automatic test case template can be automatically executed under an automatic test framework.
The automated testing framework is a tool set composed of one or more automated testing basic modules, automated testing management modules, automated testing statistical modules and the like. The automatic test case is used for organizing, managing and executing the automatic test case. Optionally, the automated test framework is a Robot frame.
And step 102b, reading the value range of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and generating n test objects according to the value range of each parameter, wherein n is an integer greater than 1.
Compared with the value examples of each parameter, the actual value of each parameter included in each test object has a different value of one parameter.
The test object comprises a group of parameter values of all parameters of the interface to be tested, the value examples of the test object and each parameter generated by the electronic equipment have different parameter values corresponding to one parameter, and the different parameter values in the value examples of the test object and each parameter are determined according to the value range of each parameter.
And 102c, replacing the value examples of each parameter in the automatic test case template with n test objects respectively to generate n automatic test cases.
Each automated test case corresponds to an expected result. The expected result is used for indicating the expected result obtained after the electronic equipment executes the automatic test case.
The method for generating the automatic test case by the electronic equipment is the same as the method for generating the automatic test case template by the electronic equipment, wherein the value examples of each parameter of the automatic case template are replaced by the parameter values of each parameter in the test object, and the executable automatic test case is obtained.
Optionally, the electronic device sequentially generates the automated test cases corresponding to the test objects according to the generation sequence of the test objects, and after generating an automated test case corresponding to one test object, the electronic device detects whether the test object is the last test object corresponding to the interface to be tested. If the test object is not the last test object corresponding to the interface to be tested, the electronic equipment continues to generate an automatic test case corresponding to the next test object; and if the test object is the last test object corresponding to the interface to be tested, the electronic equipment starts the execution process of the automatic test case.
And 103, testing the interface to be tested through the automatic test case to obtain a test result.
The electronic equipment executes the automated test case by adopting the command provided by the automated test framework so as to realize the test of the interface to be tested.
Optionally, step 103 comprises the following two substeps:
1. executing the automatic test case by adopting an automatic test frame to obtain an execution result corresponding to the automatic test case;
optionally, the automated testing framework presets at least one command, for example, the command may be a command to start testing or the like, and the electronic device executes the command provided by the automated testing framework to perform testing on the interface to be tested.
2. And for each automatic test case, comparing the execution result and the expected result corresponding to the automatic test case to obtain the test result corresponding to the automatic test case.
After the electronic device obtains the execution result of the automatic test case, the electronic device compares the execution result corresponding to the automatic test case with an expected result by using at least one assertion (assertion) to obtain a test result corresponding to the automatic test case. Wherein the assertion is expressed as a kind of boolean expression, and is generally applied to test a source program of an application program.
If the execution result is not consistent with the expected result, the test result corresponding to the automatic test case is failed, and if the execution result is consistent with the expected result, the test result corresponding to the automatic test case is passed.
Optionally, the electronic device may sequentially execute the automated test cases according to a generation sequence of the automated test cases, and after one automated test case is executed, the electronic device detects whether the automated test case is a last automated test case corresponding to the interface to be tested. If the automatic test case is not the last automatic test case corresponding to the interface to be tested, the electronic equipment continues to execute the next automatic test case; and if the automatic test case is the last automatic test case corresponding to the interface to be tested, the electronic equipment stops executing the automatic test case and generates a test result file corresponding to the interface to be tested. The test result file may be in an HTML (HyperText Markup Language) format or an XML (Extensible Markup Language) format, and is used to describe test results corresponding to all automated test cases of the interface to be tested.
Optionally, the test result file comprises two parts. The first part is used for displaying the test result of any one automatic test case, and the second part is used for displaying an automatic test case list which comprises the serial number of each automatic test case.
Optionally, the test result of the automatic test case includes a Name (Full Name), a resource path (Source), a test time (e.g., a Start time (Start), an End time (End), an execution duration (Elapsed)), a Status (Status), and the like of the automatic test case. The resource path is used for indicating a storage path of a test result of the automatic test case in the electronic equipment. The test time comprises the starting time, the ending time and the execution duration of the electronic equipment for executing the automatic test case. The status is used for indicating the test result of the automatic test case, and the test result comprises a pass status and a fail status. In one specific example, the test results of the automated test case are as follows:
the name is WIFIBIGDATA v2.0.02general Query Macs Tracks
Resource path: e \ Auto Test \ cases _ pool \ WIFIBIGDATA v2.0\02_ genetic Query Macs tracks
Start time/end time/execution duration: 2016070416:23:22.156/2016070416:23:44.633/00:00:22.477
The state is as follows: conclusive test 60, pass, 1 failure
60 test, 59 pass, 1 fail
Optionally, the content displayed in the first part of the test result file may be changed according to the trigger signal. For example, when the serial number of any one of the automated test cases obtains the trigger signal, the first part of the test result file skips to display the test result corresponding to the automated test case.
In summary, in the method provided in the embodiment of the present invention, the structured interface data of the interface to be tested is obtained, and the executable automated test case is generated according to the structured interface data of the interface to be tested, so that the interface to be tested is tested by the automated test case to obtain the test result; the problems that in the prior art, test cases need to be manually compiled by testers, so that the compiling efficiency of the test cases is low, and the interface testing efficiency is low are solved; on one hand, the test case can be automatically compiled, so that the efficiency of compiling the test case is improved; on the other hand, the test case is an executable automatic test case which is an executable file and can be automatically executed by the electronic equipment, so that the efficiency of interface testing is improved.
In addition, because the parameter types of various parameters and the corresponding test items are preset in the automatic test framework, a uniform specification is provided for testing different interfaces.
In an alternative embodiment provided based on the embodiment shown in fig. 1, after step 103, the following steps are further included: and respectively carrying out association matching on each automatic test case and the corresponding test result to generate the automatic test case with the test result.
The automatic test case with the test result comprises the automatic test case and the test result corresponding to the automatic test case. Optionally, the automatic test case with the test result includes a name of the automatic test case, a precondition, an execution step, an expected result, an execution result, and the like.
Optionally, after all the automated test cases are executed by the electronic device, performing association matching according to the feature information in the automated test cases and the feature information in the test results corresponding to the automated test cases in the test result file. The characteristic information is used for identifying an automated test case, and the characteristic information may be a number, a function, a precondition, an execution step, an expected result, and the like of the automated test case.
In a possible implementation manner, after the matching is completed, the electronic device writes each automatic test case and the test result corresponding to each automatic test case into a document in a test case template style, so that the automatic test case with the test result can be obtained. The test case template style is used to describe a canonical style of the document, for example, the test case template style specifies a background color, a border, a font, and the like of a document cell.
In another possible implementation, after the matching is completed, the electronic device writes each automatic test case and the test result corresponding to each automatic test case into a document in a CSV (Comma-Separated Values) format, so as to obtain the automatic test case with the test result.
In summary, the method provided by the embodiment of the present invention automatically generates the automatic test case with the test result by matching the automatic test case and the corresponding test result, thereby avoiding analyzing and sorting the test result by the tester and further saving the labor cost.
The following are embodiments of the apparatus of the present invention that may be used to perform embodiments of the method of the present invention. For details which are not disclosed in the embodiments of the apparatus of the present invention, reference is made to the embodiments of the method of the present invention.
Referring to fig. 3, a block diagram of an interface testing apparatus according to an embodiment of the invention is shown. The device has the functions of realizing the method examples, and the functions can be realized by hardware or by hardware executing corresponding software. The apparatus may include: a data acquisition module 301, a use case generation module 302 and an interface test module 303.
The data acquisition module 301 is configured to acquire structured interface data of an interface to be tested, where the structured interface data of the interface to be tested is interface data of the interface to be tested, which is represented according to a preset specification; the interface data of the interface to be tested is used for describing basic information of the interface to be tested.
The use case generating module 302 is configured to generate an executable automated test use case according to the structured interface data of the interface to be tested.
And the interface testing module 303 is configured to test the interface to be tested through the automatic test case to obtain a test result.
In summary, the apparatus provided in the embodiment of the present invention generates an executable automatic test case according to the structured interface data of the interface to be tested by obtaining the structured interface data of the interface to be tested, and then tests the interface to be tested by using the executable automatic test case to obtain a test result; the problems that in the prior art, test cases need to be manually compiled by testers, so that the compiling efficiency of the test cases is low, and the interface testing efficiency is low are solved; on one hand, the test case can be automatically compiled, so that the efficiency of compiling the test case is improved; on the other hand, the test case is an executable automatic test case which is an executable file and can be automatically executed by the electronic equipment, so that the efficiency of interface testing is improved.
In an alternative embodiment provided based on the embodiment shown in fig. 3, please refer to fig. 4, the structured interface data of the interface to be tested includes: the test system comprises at least one parameter of the interface to be tested, a value example of each parameter, at least one value range of each parameter, and an expected result corresponding to each value range of each parameter.
The use case generation module 302 includes: a template generating unit 302a, an object generating unit 302b, and a use case generating unit 302 c.
The template generating unit 302a is configured to read value examples of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and generate an executable automatic test case template according to the value examples of each parameter.
The object generating unit 302b is configured to read a value range of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and generate n test objects according to the value range of each parameter; compared with the actual value of each parameter included in each test object, the actual value of each parameter included in each test object has a different value of one parameter, and n is an integer greater than 1.
The case generating unit 302c is configured to replace the value examples of the parameters in the automatic test case template with the n test objects, respectively, to generate n automatic test cases, where each automatic test case corresponds to an expected result.
In another alternative embodiment provided based on the embodiment shown in fig. 3, referring to fig. 4, the data obtaining module 301 includes: a data acquisition unit 301a and a data conversion unit 301 b.
The data obtaining unit 301a is configured to obtain interface data of the interface to be tested.
The data conversion unit 301b is configured to convert the interface data of the interface to be tested into the structured interface data of the interface to be tested according to the preset specification.
In another alternative embodiment provided based on the embodiment shown in fig. 3, referring to fig. 4, the interface testing module 303 includes: a use case execution unit 303a and a result acquisition unit 303 b.
The case executing unit 303a is configured to execute the automated test case by using an automated test framework, and obtain an execution result corresponding to the automated test case.
The result obtaining unit 303b is configured to, for each automatic test case, compare an execution result and an expected result corresponding to the automatic test case to obtain a test result corresponding to the automatic test case.
In an alternative embodiment provided based on the embodiment shown in fig. 3, please refer to fig. 4, the apparatus further includes: a use case update module 304.
The case updating module 304 is configured to perform association matching on each automated test case and the corresponding test result, and generate an automated test case with a test result.
It should be noted that: in the above embodiment, when the device implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to implement all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Referring to fig. 5, a schematic structural diagram of an electronic device according to an embodiment of the invention is shown. The electronic device is used for implementing the interface testing method provided in the above embodiment. Specifically, the method comprises the following steps:
the electronic device 500 includes a Central Processing Unit (CPU)501, a system memory 504 including a Random Access Memory (RAM)502 and a Read Only Memory (ROM)503, and a system bus 505 connecting the system memory 504 and the central processing unit 501. The electronic device 500 also includes a basic input/output system (I/O system) 506, which facilitates the transfer of information between devices within the computer, and a mass storage device 507, which stores an operating system 513, application programs 514, and other program modules 515.
The basic input/output system 506 comprises a display 508 for displaying information and an input device 509, such as a mouse, keyboard, etc., for user input of information. Wherein the display 508 and the input device 509 are connected to the central processing unit 501 through an input output controller 510 connected to the system bus 505. The basic input/output system 506 may also include an input/output controller 510 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input-output controller 510 also provides output to a display screen, a printer, or other type of output device.
The mass storage device 507 is connected to the central processing unit 501 through a mass storage controller (not shown) connected to the system bus 505. The mass storage device 507 and its associated computer-readable media provide non-volatile storage for the electronic device 500. That is, the mass storage device 507 may include a computer-readable medium (not shown) such as a hard disk or CD-ROM drive.
Without loss of generality, the computer-readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, EPROM, EEPROM, flash memory or other solid state memory technology, CD-ROM, DVD, or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the foregoing. The system memory 504 and mass storage device 507 described above may be collectively referred to as memory.
The electronic device 500 may also operate as a remote computer connected to a network via a network, such as the internet, in accordance with various embodiments of the present invention. That is, the electronic device 500 may be connected to the network 512 through the network interface unit 511 connected to the system bus 505, or may be connected to another type of network or a remote computer system (not shown) using the network interface unit 511.
The memory also includes one or more programs stored in the memory and configured to be executed by one or more processors. The one or more programs include instructions for performing the interface test method described above.
It should be understood that reference to "a plurality" herein means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (6)

1. An interface testing method, the method comprising:
acquiring structured interface data of an interface to be tested, wherein the structured interface data of the interface to be tested refers to interface data of the interface to be tested, which is expressed according to a preset specification, and the structured interface data of the interface to be tested comprises at least one parameter of the interface to be tested, a value example of each parameter, at least one value range of each parameter, and an expected result corresponding to each value range of each parameter; the interface data of the interface to be tested is used for describing basic information of the interface to be tested;
generating an automatic test case which can be automatically executed by the electronic equipment according to the structured interface data of the interface to be tested;
executing the automatic test case by adopting an automatic test frame to obtain an execution result corresponding to the automatic test case;
for each automatic test case, comparing an execution result and an expected result corresponding to the automatic test case to obtain a test result corresponding to the automatic test case, wherein the test result comprises the name, the resource path, the test time and the state of the automatic test case;
respectively associating and matching each automatic test case with a corresponding test result according to characteristic information in the automatic test case and characteristic information in the test result corresponding to the automatic test case in a test result file, wherein the characteristic information is used for identifying the automatic test case, and the characteristic information comprises at least one of the serial number, the function, the precondition, the execution step and the expected result of the automatic test case;
and respectively writing each automatic test case and the test result corresponding to each automatic test case into a document to obtain the automatic test case of the result to be tested.
2. The method of claim 1, wherein generating an executable automated test case from the structured interface data of the interface under test comprises:
reading value examples of all parameters of the interface to be tested from the structured interface data of the interface to be tested, and generating an executable automatic test case template according to the value examples of all the parameters;
reading the value range of each parameter of the interface to be tested from the structured interface data of the interface to be tested, and generating n test objects according to the value range of each parameter; comparing the actual value of each parameter included in each test object with the value example of each parameter, wherein the value of one parameter is different, and n is an integer greater than 1;
and replacing the value examples of the parameters in the automatic test case template with the n test objects respectively to generate n automatic test cases, wherein each automatic test case corresponds to an expected result.
3. The method of claim 1, wherein obtaining structured interface data for an interface under test comprises:
acquiring interface data of the interface to be tested;
and according to the preset specification, converting the interface data of the interface to be tested into the structured interface data of the interface to be tested.
4. An interface testing apparatus, the apparatus comprising:
the data acquisition module is used for acquiring structured interface data of an interface to be tested, wherein the structured interface data of the interface to be tested refers to interface data of the interface to be tested, which is expressed according to a preset specification, and the structured interface data of the interface to be tested comprises at least one parameter of the interface to be tested, a value example of each parameter, at least one value range of each parameter, and an expected result corresponding to each value range of each parameter; the interface data of the interface to be tested is used for describing basic information of the interface to be tested;
the case generating module is used for generating an executable automatic test case according to the structured interface data of the interface to be tested;
the interface test module comprises a use case execution unit and a result acquisition unit;
the case execution unit is used for executing the automatic test case by adopting an automatic test frame to obtain an execution result corresponding to the automatic test case;
the result obtaining unit is used for comparing an execution result corresponding to each automatic test case with an expected result corresponding to each automatic test case to obtain a test result corresponding to each automatic test case;
and the case updating module is used for respectively carrying out correlation matching on each automatic test case and the corresponding test result to generate the automatic test case with the test result.
5. The apparatus of claim 4, wherein the use case generation module comprises:
the template generating unit is used for reading value examples of all parameters of the interface to be tested from the structured interface data of the interface to be tested and generating an executable automatic test case template according to the value examples of all the parameters;
the object generating unit is used for reading the value range of each parameter of the interface to be tested from the structured interface data of the interface to be tested and generating n test objects according to the value range of each parameter; comparing the actual value of each parameter included in each test object with the value example of each parameter, wherein the value of one parameter is different, and n is an integer greater than 1;
and the case generating unit is used for adopting the n test objects to respectively replace the value examples of the parameters in the automatic test case template to generate n automatic test cases, and each automatic test case corresponds to an expected result.
6. The apparatus of claim 4, wherein the data acquisition module comprises:
the data acquisition unit is used for acquiring interface data of the interface to be tested;
and the data conversion unit is used for converting the interface data of the interface to be tested into the structured interface data of the interface to be tested according to the preset specification.
CN201710084564.1A 2017-02-16 2017-02-16 Interface test method and device Active CN108446190B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710084564.1A CN108446190B (en) 2017-02-16 2017-02-16 Interface test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710084564.1A CN108446190B (en) 2017-02-16 2017-02-16 Interface test method and device

Publications (2)

Publication Number Publication Date
CN108446190A CN108446190A (en) 2018-08-24
CN108446190B true CN108446190B (en) 2021-08-17

Family

ID=63190735

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710084564.1A Active CN108446190B (en) 2017-02-16 2017-02-16 Interface test method and device

Country Status (1)

Country Link
CN (1) CN108446190B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254920A (en) * 2018-09-06 2019-01-22 上海精数信息科技有限公司 Interface testing case generation method, device, electronic equipment, storage medium
CN109446068B (en) * 2018-09-26 2024-04-05 平安健康保险股份有限公司 Interface test method, device, computer equipment and storage medium
CN109298882A (en) * 2018-09-26 2019-02-01 深圳壹账通智能科技有限公司 Management method, computer readable storage medium and the terminal device of interface
CN109522210A (en) * 2018-09-29 2019-03-26 中国平安人寿保险股份有限公司 Interface testing parameters analysis method, device, electronic device and storage medium
CN111198809A (en) * 2018-11-16 2020-05-26 北京奇虎科技有限公司 Interface automation test method and device
CN109739701A (en) * 2018-12-14 2019-05-10 北京奇安信科技有限公司 Interface test method and device
CN109766262B (en) * 2018-12-15 2022-05-06 深圳壹账通智能科技有限公司 Interface data processing method, automatic testing method, device, equipment and medium
CN111352825B (en) * 2018-12-21 2023-06-02 北京金山云网络技术有限公司 Data interface testing method and device and server
CN109766231A (en) * 2019-01-11 2019-05-17 未来电视有限公司 Interface test method and device
CN109992508A (en) * 2019-03-22 2019-07-09 恒生电子股份有限公司 Test exemple automation generation method, device and electronic equipment
CN110609791A (en) * 2019-09-03 2019-12-24 深圳证券交易所 Interface test method, interface test device and storage medium for bidding system
CN110647471B (en) * 2019-09-26 2023-05-23 招商局金融科技有限公司 Interface test case generation method, electronic device and storage medium
CN111078526A (en) * 2019-11-04 2020-04-28 泰康保险集团股份有限公司 Test case generation method and device and storage medium
CN111083007B (en) * 2019-11-21 2022-07-29 京信网络系统股份有限公司 Test method, test device, computer equipment and storage medium
CN111581083B (en) * 2020-04-26 2024-02-09 抖音视界有限公司 Interface testing method and device, electronic equipment and storage medium
CN112035363A (en) * 2020-09-01 2020-12-04 中国银行股份有限公司 Automatic interface testing method and device
CN112100078A (en) * 2020-09-27 2020-12-18 中国建设银行股份有限公司 Method, device and equipment for generating interface test case

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6880109B2 (en) * 2001-07-03 2005-04-12 The United States Of America As Represented By The Secretary Of The State Functional element test tool and method
CN103064788A (en) * 2012-12-24 2013-04-24 清华大学 Web service modeling and test method based on interface semantic contract model
CN106095673A (en) * 2016-06-07 2016-11-09 深圳市泰久信息系统股份有限公司 Automated testing method based on WEB interface and system
CN106354634A (en) * 2016-08-25 2017-01-25 青岛海信传媒网络技术有限公司 Interface testing method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080295076A1 (en) * 2007-05-23 2008-11-27 Microsoft Corporation Graphical user interface testing
CN102694701B (en) * 2012-06-13 2015-12-02 青岛海信传媒网络技术有限公司 Message based method of testing and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6880109B2 (en) * 2001-07-03 2005-04-12 The United States Of America As Represented By The Secretary Of The State Functional element test tool and method
CN103064788A (en) * 2012-12-24 2013-04-24 清华大学 Web service modeling and test method based on interface semantic contract model
CN106095673A (en) * 2016-06-07 2016-11-09 深圳市泰久信息系统股份有限公司 Automated testing method based on WEB interface and system
CN106354634A (en) * 2016-08-25 2017-01-25 青岛海信传媒网络技术有限公司 Interface testing method and device

Also Published As

Publication number Publication date
CN108446190A (en) 2018-08-24

Similar Documents

Publication Publication Date Title
CN108446190B (en) Interface test method and device
US11379348B2 (en) System and method for performing automated API tests
CN108845940B (en) Enterprise-level information system automatic function testing method and system
US8549483B1 (en) Engine for scalable software testing
CN110716870B (en) Automatic service testing method and device
CN101526919B (en) Method for generating script files to test Web application software and device thereof
WO2019029160A1 (en) Application construction method and system, computer device, and storage medium
WO2018120721A1 (en) Method and system for testing user interface, electronic device, and computer readable storage medium
CN107526676B (en) Cross-system test method and device
US20140165040A1 (en) Test script generation for application image validation
CN108763091B (en) Method, device and system for regression testing
CN102012857A (en) Device and method for automatically testing web page
CN112241360A (en) Test case generation method, device, equipment and storage medium
CN112035363A (en) Automatic interface testing method and device
CN115658529A (en) Automatic testing method for user page and related equipment
US20200293592A1 (en) Methods and systems for browser extension used to generate relative xpath, absolute xpath and/or css selectors
US11615016B2 (en) System and method for executing a test case
CN113268409B (en) Method, apparatus, device and medium for tracking logical nodes during automated testing
CN110928760A (en) Unit testing method and device in embedded system
CN112416333A (en) Software model training method, device, system, equipment and storage medium
CN114064503A (en) UI automation test method and device, electronic equipment and storage medium
CN113326193A (en) Applet testing method and device
CN111459833B (en) Method for realizing multi-terminal multi-platform automatic test and monitoring of mobile terminal of government and enterprise
WO2020261363A1 (en) Traceability management device
CN114647589A (en) Application software testing method, system, device, equipment and readable storage medium

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
GR01 Patent grant
GR01 Patent grant