CN112597020A - Interface testing method and device, computer equipment and storage medium - Google Patents
Interface testing method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN112597020A CN112597020A CN202011548553.2A CN202011548553A CN112597020A CN 112597020 A CN112597020 A CN 112597020A CN 202011548553 A CN202011548553 A CN 202011548553A CN 112597020 A CN112597020 A CN 112597020A
- Authority
- CN
- China
- Prior art keywords
- test
- interface
- data
- specified
- configuration file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3664—Environments for testing or debugging software
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application relates to the technical field of interface testing, and discloses an interface testing method, an interface testing device, computer equipment and a storage medium, wherein the method is used for acquiring a test request instruction from a user end to a testing interface; analyzing the request test instruction, and acquiring a specified test interface and a test scene identifier in the request test instruction; acquiring data of the specified test interface from the specified test interface; according to the test scene identification, obtaining a configuration file corresponding to the test scene identification from the specified test interface data; generating a test case corresponding to the test scene identification according to the configuration file; and uploading the test case to a specified test interface to perform interface test to obtain a test result. The application also relates to blockchain technology, and the test cases are stored in the blockchain. According to the method and the device, the specified test interface is obtained, and the corresponding test case is generated to carry out interface test, so that the efficiency of interface test is improved.
Description
Technical Field
The present application relates to the field of interface testing technologies, and in particular, to an interface testing method and apparatus, a computer device, and a storage medium.
Background
At present, in the process of testing an interface on a front-end page, different data are required to be returned by test page data along with the interface, and different page display or operation is carried out. As a tester, testing this type of scenario requires the interface to return the parameter values that make up the test scenario to test the current function.
In the prior art, a packet capturing tool, such as a finder or Charles, is used to intercept returned data of an interface making request, and then the modified data is returned to an interface caller. However, in this method, data needs to be returned from the interception interface, a place where the data is modified is found, and then the data is returned to the caller, a certain time needs to be consumed in this period, and when the time exceeds the interface response time, the call is directly returned to be overtime, so that the modified data cannot be used, and the test fails, and the interface test efficiency is low. There is a need for a method for improving the efficiency of interface testing.
Disclosure of Invention
An object of the embodiments of the present application is to provide an interface testing method, an interface testing apparatus, a computer device, and a storage medium, so as to improve efficiency of interface testing.
In order to solve the foregoing technical problem, an embodiment of the present application provides an interface testing method, including:
acquiring a test request instruction from a user end to a test interface;
analyzing the request test instruction, and acquiring a specified test interface and a test scene identifier in the request test instruction, wherein the test scene identifier is used for representing a test scene corresponding to the specified test interface;
acquiring data of the specified test interface from the specified test interface;
according to the test scene identification, obtaining a configuration file corresponding to the test scene identification from the specified test interface data;
generating a test case corresponding to the test scene identification according to the configuration file;
and uploading the test case to the specified test interface to perform interface test, so as to obtain a test result.
In order to solve the above technical problem, an embodiment of the present application provides an interface testing apparatus, including:
the test request instruction module is used for acquiring a test request instruction from a user terminal to the test interface;
the specified test interface module is used for analyzing the request test instruction and acquiring a specified test interface and a test scene identifier in the request test instruction, wherein the test scene identifier is used for representing a test scene corresponding to the specified test interface;
the test interface data module is used for acquiring the data of the specified test interface from the specified test interface;
the configuration file acquisition module is used for acquiring a configuration file corresponding to the test scene identifier from the specified test interface data according to the test scene identifier;
the test case generation module is used for generating a test case corresponding to the test scene identifier according to the configuration file;
and the test result generation module is used for uploading the test case to the specified test interface to carry out interface test so as to obtain a test result.
In order to solve the technical problems, the invention adopts a technical scheme that: a computer device is provided that includes, one or more processors; a memory for storing one or more programs for causing the one or more processors to implement the interface testing method of any one of the above.
In order to solve the technical problems, the invention adopts a technical scheme that: a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements an interface testing method as recited in any one of the above.
The embodiment of the invention provides an interface testing method and device, computer equipment and a storage medium. Wherein the method comprises the following steps: acquiring a test request instruction from a user end to a test interface; analyzing the request test instruction, and acquiring a specified test interface and a test scene identifier in the request test instruction; acquiring data of the specified test interface from the specified test interface; according to the test scene identification, obtaining a configuration file corresponding to the test scene identification from the specified test interface data; generating a test case corresponding to the test scene identification according to the configuration file; and uploading the test case to a specified test interface to perform interface test to obtain a test result. According to the embodiment of the invention, the specified test interface and the corresponding test scene identification are obtained, the corresponding test case is generated, and the test task is completed through the test case, so that the specified test interface is favorably obtained when a specific test scene is carried out, the test case is correspondingly generated to carry out interface test, and the efficiency of interface test is improved.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a schematic application environment diagram of an interface testing method provided in an embodiment of the present application;
FIG. 2 is a flow chart of an implementation of a method for testing an interface according to an embodiment of the present disclosure;
FIG. 3 is a flow chart of an implementation of a sub-process in the interface testing method according to the embodiment of the present application;
FIG. 4 is a flowchart of another implementation of a sub-process in the interface testing method according to the embodiment of the present application;
FIG. 5 is a flowchart of another implementation of a sub-process in the interface testing method according to the embodiment of the present application;
FIG. 6 is a flowchart of another implementation of a sub-process in the interface testing method according to the embodiment of the present application;
FIG. 7 is a flowchart of another implementation of a sub-process in the interface testing method according to the embodiment of the present application;
FIG. 8 is a schematic diagram of an interface testing apparatus according to an embodiment of the present application;
fig. 9 is a schematic diagram of a computer device provided in an embodiment of the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
The present invention will be described in detail below with reference to the accompanying drawings and embodiments.
Referring to fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as a web browser application, a search-type application, an instant messaging tool, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that, the interface testing method provided in the embodiments of the present application is generally executed by a server, and accordingly, the interface testing apparatus is generally configured in the server.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring to fig. 2, fig. 2 shows an embodiment of an interface testing method.
It should be noted that, if the result is substantially the same, the method of the present invention is not limited to the flow sequence shown in fig. 2, and the method includes the following steps:
s1: and acquiring a test request instruction from the user end to the test interface.
Specifically, when the user needs to test a certain test scenario, the user sends a test request instruction for the test interface to the server, and after the server receives the test request instruction from the user for the test interface, the server starts to execute an interface test task. Wherein, the request test instruction includes an appointed test interface identifier.
In the test tasks of the interface, the user terminal can initiate test requests for different test tasks, so that the server can acquire the test tasks requested by the user terminal to test. Specifically, the server provides a request initiation entry for the client, and if the client desires to perform a test on a certain test task, the client may initiate a test request by triggering a related operation through the request initiation entry, and at this time, the client may send a test request instruction of the test interface to the server.
For example, if a test task list is displayed on a server, and the test task list lists a series of test tasks available for the user to select, the user can select any one of the test tasks listed in the test task list. The test task list is a request initiating entry provided by the server, and the click operation is an operation of the user side for triggering an interface test at the request initiating entry.
S2: analyzing the request test instruction, and acquiring a specified test interface and a test scene identifier in the request test instruction, wherein the test scene identifier is used for representing a test scene corresponding to the specified test interface.
Specifically, in the process of testing interfaces in different test scenarios, a certain test interface needs to be specified for testing, so that interface test tasks need to be determined. The server obtains the appointed test interface identification in the request test instruction by analyzing the request test instruction, matches the test interface in the interface set according to the test interface identification, and inquires whether a test interface matched with the test interface identification exists. If the test interface matched with the test interface identification exists, the test interface is used as an appointed test interface, namely the appointed test interface exists in the judgment result, the appointed test interface is obtained, and in the subsequent interface test of the test scene, the test is carried out through the appointed test interface.
Specifically, after a test scene is specified by the user side, the request test instruction is sent to carry a test scene identifier, and a test task of the test scene can be performed on the specified test interface through the test scene identifier. Therefore, after the test request instruction is analyzed, the test scene identification can be obtained, so that a test task of scene test can be performed through the specified test interface in the following process. The test scenes comprise types such as performance tests, load tests, pressure tests, stability tests and the like.
S3: and acquiring the data of the specified test interface from the specified test interface.
Specifically, after the specified test interface is obtained, the corresponding test interface data is obtained from the specified test interface. The specified interface data comprises configuration files, HTTP protocols and other data corresponding to different test scenes.
S4: and acquiring a configuration file corresponding to the test scene identification from the specified test interface data according to the test scene identification.
Specifically, the configuration file is pre-deployed in the server for interface testing, and is used for the server to automatically test the interface to be tested. And each interface to be tested stores corresponding testing parameters in the configuration file. It should be understood that the test scenarios are different, and the test parameters of the interface to be tested in the test scenarios may be different. That is, in the embodiment of the present application, the test parameters of the configuration file of each test interface are different, so that the configuration file corresponding to the test scenario needs to be obtained from the data of the specified test interface according to the test scenario identifier, so as to generate a corresponding test case in the following, thereby completing the test task. Furthermore, since the specified test interface data includes configuration files under different test scenes, as long as the test scene identification corresponding to the test scene is obtained, the test scene identification is used for traversing the test interface data, matching is performed to obtain the configuration files corresponding to the test scene identification, and then the configuration files are obtained.
S5: and generating a test case corresponding to the test scene identification according to the configuration file.
Specifically, the server acquires modification data obtained by modifying parameters of the configuration file by the user side according to the test scenario according to the configuration file, and generates a test case corresponding to the test scenario through the modification data.
The Test Case (Test Case) is a description of a Test task performed on a specific software product, and embodies a Test scheme, a method, a technology and a strategy. The contents of the test object, the test environment, the input data, the test steps, the expected results, the test scripts and the like are included, and finally, a document is formed. Simply considered, a test case is a set of test inputs, execution conditions, and expected results tailored for a particular purpose to verify whether a particular software requirement is met. It should be understood that the test scenarios are different, and the test cases are also different.
S6: and uploading the test case to a specified test interface to perform interface test to obtain a test result.
Specifically, the test result includes response result data, an expected assertion result, and a matching result of the expected assertion result and the response result data in the test scenario.
In the embodiment, a test request instruction from a user terminal to a test interface is obtained; analyzing the request test instruction, and acquiring a specified test interface and a test scene identifier in the request test instruction; acquiring data of the specified test interface from the specified test interface; according to the test scene identification, obtaining a configuration file corresponding to the test scene identification from the specified test interface data; generating a test case corresponding to the test scene identification according to the configuration file; and uploading the test case to a specified test interface to perform interface test to obtain a test result. The method and the device are beneficial to acquiring the specified test interface and correspondingly generating the test case to carry out interface test when a specific test scene is carried out, so that the efficiency of the interface test is improved.
Referring to fig. 3, fig. 3 shows a specific implementation manner of step S5, and a specific implementation process of generating a test case corresponding to a test scenario identifier according to a configuration file in step S5 is described as follows:
s51: and sending the configuration file to the user side to obtain modified data returned by the user side to the configuration file, wherein the modified data is modified configuration file data and comprises modified configuration file data and unmodified configuration file data.
Specifically, the server sends the configuration file to the user side, the user can modify the returned configuration file at the user side according to the test scenario, for example, data information such as key and value in the configuration file is modified, and then the user returns the modified data to the server through the user side, so that a test case is generated according to the modified data in the following process.
S52, the modified data is formatted into a preset format to obtain the target modified data.
The modified format is uniformly modified into the same format, so that when key fields are searched subsequently, the searching failure caused by inconsistent formats is prevented. The target modification data is data which can generate a test case corresponding to a test scene after the configuration file is modified.
Further, the preset format may be set according to actual conditions, and is not limited herein. In one embodiment, the predetermined format is a json format.
S53: and generating a test case corresponding to the test scene identification according to the target modification data.
Specifically, the server receives the target modification data and generates a test case corresponding to the test scene so as to perform subsequent tests to obtain a test result.
In the implementation, the configuration file is sent to the user side to obtain the modification data returned by the user side to the configuration file, then the modification data is formatted into the preset format to obtain the target modification data, and then the test case corresponding to the test scene identifier is generated according to the target modification data, so that the subsequent interface test is conveniently performed according to the data modified by the user, and the interface test efficiency is favorably improved.
Referring to fig. 4, fig. 4 shows an embodiment of step S6, where in step S6, the test case is uploaded to the designated test interface for interface test, and a specific implementation process of obtaining a test result is described as follows:
s61: and extracting the test parameters of the specified test interface data in the test scene from the test case.
Specifically, since the interface test of the corresponding test scenario is performed, data extraction is performed on the test case to obtain the test parameters corresponding to the test scenario.
S62: and in the test scene, calling the specified test interface according to the test parameters to obtain response data returned by the specified test interface in the scene test process.
Specifically, the above steps already determine the specified test interface, and on the specified test interface, an interface test is performed according to the test data to obtain the response data returned in the test process. The response data reflects the interface test result, and the test result can be generated through the response data.
S63: and generating a test result of the specified test interface according to the response data.
Specifically, the response data is subjected to assertion result calculation, so that a test interface of the specified test interface is generated. The calculation of the assertion result refers to comparing the result data in the response data with the expected assertion result, so as to obtain the test interface.
In this embodiment, the test parameters of the specified test interface data in the test scenario are extracted from the test case, the specified test interface is called according to the test parameters in the test scenario, the response data returned by the specified test interface in the scenario test process is obtained, and the test result of the specified test interface is generated according to the response data, so that the interface test of the test scenario is realized, and the interface test efficiency is improved.
Referring to fig. 5, fig. 5 shows an embodiment of step S63, and a detailed implementation process of generating a test result of a specified test interface according to response data in step S63 is as follows:
s631: and analyzing the target modification data to obtain an expected assertion rule list in the target modification data.
Specifically, the target modification data includes an expected result of the test on the test scenario by the user, so that the target modification data is analyzed to obtain an expected assertion rule list in the target modification data.
The assertion rule list contains content extraction symbols, matching symbols, and matched content, such as the rule $ { code } $ { equals } 200. Wherein, $ { code } is a content extraction symbol, which represents that an extraction interface returns a status code; $ equals is a match symbol, representing that the result assertion engine will use equal matching; 200 represents the matched content as 200. The logical meaning of this assertion rule is to assert the interface return status code to 200.
S632: and extracting corresponding content of the expected assertion rule list through the content extractor to obtain an assertion expected result corresponding to the test scene.
Specifically, by obtaining the assertion expected result, comparison with subsequently generated test return response result data is facilitated, and the completion effect of the test task is further judged.
And the assertion expected result is an expected result in the interface test assertion design and is used for comparing with the interface finally obtained by the interface test so as to obtain a test result.
The content extraction symbol comprises 3 types of $ { code }, $ { text }, $ { header. Wherein, $ { code } can extract the state code of the interface in the assertion engine to participate in assertion operation; the response body of the http interface can be extracted from the assertion engine to participate in assertion operation; item specific items (item) in an interface response head (head) can be extracted to participate in assertion operation in the assertion engine, for example, $ { head. In the application embodiment, the expected result of the assertion is extracted through the content extractor.
S633: and extracting response result data of the specified test interface in the response data.
Specifically, the response result data refers to the result data finally generated after the interface test under the test scene is completed.
S634: and performing character string matching on the response result data and the assertion expected result to obtain a character string matching result.
Specifically, the test result is obtained by performing string matching on the response result data and the assertion expected result, and judging whether the response result data is consistent with the assertion expected result. The character string matching means that response result data and an assertion expected result are converted into the same character format, and then the response result data and the assertion expected result are compared one by one to obtain a comparison result.
S635: and generating a test result according to the character string matching result.
Specifically, if the string matching result is that the strings of the response result data and the assertion expected result cannot be matched one by one, it is indicated that the response result data is different from the assertion expected result; if the character string matching result is that the response result data and the character strings of the assertion expected result can be matched one by one, the response result data and the assertion expected result are the same.
In the embodiment, the target modification data is analyzed to obtain the expected assertion rule list in the target modification data, the corresponding content of the expected assertion rule list is extracted through the content extractor to obtain the expected assertion result corresponding to the test scenario, the response result data of the specified test interface in the response data is extracted, the response result data and the expected assertion result are subjected to character string matching to obtain the character string matching result, the expected assertion result and the response result data are compared to obtain the interface test result, and the interface test efficiency is improved.
Referring to fig. 6, fig. 6 shows a specific implementation of step S2, where the specific implementation process of parsing the request test command and obtaining the specified test interface and the test scenario identifier in the request test command in step S2 is described as follows:
s21: and analyzing the request test instruction, and acquiring the specified test interface identifier and the test scene identifier in the request test instruction.
Specifically, the request test instruction includes an assigned test interface identifier, and the assigned test interface can be identified by the assigned test interface identifier, so that whether the assigned test interface exists in the interface data set is judged.
S22: and traversing the test interfaces in the interface set, and judging whether a test interface matched with the specified test interface identifier exists in the test interfaces in the interface set.
Specifically, multiple test interfaces are preset in the server, and the test interfaces are stored in the interface set. And judging whether the specified test interface exists or not by identifying and matching the specified test interface identifier with the test interfaces in the interface set.
S23: and if the matched test interface exists, judging that the specified test interface exists in the test request instruction and using the matched test interface as the specified test interface.
Specifically, when the specified test interface identifier can be matched with the corresponding test interface, the test interface is used as the specified test interface for subsequent interface test on the test scene.
Further, if no matched test interface exists, the judgment result is that no specified test interface exists in the test request instruction. If the judgment result is that the specified test interface in the request instruction does not exist, analyzing the interface test instruction to obtain a test scene, selecting an interface matched with the test scene from the interface set according to the test scene, and taking the interface as the specified test interface. And selecting an interface matched with the test scene from the interface set, wherein the interface executes the test task performed on the test scene in the previous test tasks.
In this embodiment, the request test instruction is analyzed to obtain the specified test interface identifier and the test scene identifier in the request test instruction, traverse the test interfaces in the interface set to obtain the specified test interface, and provide a basis for subsequent interface tests of the specified test interface.
Referring to fig. 7, fig. 7 shows a specific implementation manner after step S6, which includes:
s71: and acquiring a first timestamp of the test case uploaded to the specified test interface.
Specifically, the first timestamp uploaded to the specified test interface by the test case is the time point when the interface test response starts, and the first timestamp is acquired and recorded, so that the response time of the interface is conveniently acquired and recorded.
The time stamp is data generated by using a digital signature technology, and the signed object comprises original file information, signature parameters, signature time and other information. The time stamp system is used for generating and managing time stamps, and the time stamps are generated by digitally signing signature objects so as to prove that original files exist before the signature time.
S72: and acquiring a second timestamp of the returned data after the test scene test is completed.
Specifically, the second timestamp of the returned data after the test scenario test is completed is the time point of receiving the interface test response.
S73: and calculating the time difference between the second time stamp and the first time stamp, and taking the time difference as the response time of the interface.
Specifically, the time difference between the second timestamp and the first timestamp is the interface response time, and the test task completion effect is judged by recording the interface response time. Furthermore, a response time chart can be drawn according to the recorded response time of the interface, so that the test task completion degree can be conveniently analyzed.
In this embodiment, through the first time stamp that obtains test case upload to appointed test interface, obtain the second time stamp that returns data after the test scene test is accomplished, calculate the time difference of second time stamp and first time stamp to regard the time difference as the response time of interface, realize taking notes the response time of interface test, be convenient for observe the interface test, in order to provide the efficiency of interface test.
It is emphasized that, to further ensure the privacy and security of the test cases, the test cases may also be stored in a node of a block chain.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the computer program is executed. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
Referring to fig. 8, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an interface testing apparatus, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be applied to various electronic devices.
As shown in fig. 8, the interface test apparatus of the present embodiment includes: a test request instruction module 81, an appointed test interface module 82, a test interface data module 83, a configuration file acquisition module 84, a test case generation module 85, and a test result generation module 86, wherein:
a test request instruction module 81, configured to obtain a test request instruction from a user end to a test interface;
the specified test interface module 82 is configured to parse the request test instruction, and obtain a specified test interface and a test scenario identifier in the request test instruction, where the test scenario identifier is used to represent a test scenario corresponding to the specified test interface;
a test interface data module 83, configured to obtain data of a specified test interface from the specified test interface;
a configuration file obtaining module 84, configured to obtain, according to the test scenario identifier, a configuration file corresponding to the test scenario identifier from the specified test interface data;
the test case generation module 85 is configured to generate a test case corresponding to the test scene identifier according to the configuration file;
and the test result generation module 86 is configured to upload the test case to the specified test interface to perform an interface test, so as to obtain a test result.
Further, the test case generation module 85 includes:
the modified data acquisition unit is used for sending the configuration file to the user side so as to acquire modified data returned by the user side to the configuration file, wherein the modified data is modified configuration file data and comprises modified configuration file data and unmodified configuration file data;
the modified data conversion unit is used for converting the format of the modified data into a preset format to obtain target modified data;
and the test case acquisition unit is used for generating a test case corresponding to the test scene identifier according to the target modification data.
Further, the test result generation module 86 includes:
the test parameter extraction unit is used for extracting the test parameters of the specified test interface data in the test scene from the test cases;
the response data acquisition unit is used for calling the specified test interface according to the test parameters in the test scene to acquire response data returned by the specified test interface in the scene test process;
and the test result generating unit is used for generating a test result of the specified test interface according to the response data.
Further, the response data acquiring unit includes:
the configuration file analysis subunit is used for analyzing the target modification data and acquiring an expected assertion rule list in the target modification data;
and the assertion expected result obtaining subunit is used for extracting the corresponding content of the expected assertion rule list through the content extractor to obtain the assertion expected result corresponding to the test scene.
The response result data extraction subunit is used for extracting response result data of a specified test interface in the response data;
the character string matching result subunit is used for carrying out character string matching on the response result data and the assertion expected result to obtain a character string matching result;
and the test result acquisition subunit is used for generating a test result according to the character string matching result.
Further, the specified test interface module 82 includes:
the test interface identification acquisition submodule is used for analyzing the request test instruction and acquiring the specified test interface identification and the test scene identification in the request test instruction;
the test interface identification matching submodule is used for traversing the test interfaces in the interface set and judging whether a test interface matched with the specified test interface identification exists in the test interfaces in the interface set;
and the first judgment result sub-module is used for judging that the specified test interface exists in the test request instruction and using the matched test interface as the specified test interface if the matched test interface exists. Further, after the test result generating module 86, the interface testing apparatus further includes:
the first time stamp obtaining module is used for obtaining a first time stamp uploaded to a specified test interface by a test case;
the second timestamp acquisition module is used for acquiring a second timestamp of the returned data after the test scene test is finished;
and the response time calculation module is used for calculating the time difference between the second time stamp and the first time stamp and taking the time difference as the response time of the interface.
It is emphasized that, to further ensure the privacy and security of the test cases, the test cases may also be stored in a node of a block chain.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 9, fig. 9 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 9 includes a memory 91, a processor 92, and a network interface 93 communicatively connected to each other via a system bus. It is noted that only the computer device 9 having three components memory 91, processor 92, network interface 93 is shown, but it is understood that not all of the shown components are required to be implemented, and more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 91 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 91 may be an internal storage unit of the computer device 9, such as a hard disk or a memory of the computer device 9. In other embodiments, the memory 91 may also be an external storage device of the computer device 9, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the computer device 9. Of course, the memory 91 may also comprise both an internal storage unit of the computer device 9 and an external storage device thereof. In this embodiment, the memory 91 is generally used for storing an operating system installed in the computer device 9 and various types of application software, such as program codes of the interface test method. Further, the memory 91 can also be used to temporarily store various types of data that have been output or are to be output.
The network interface 93 may include a wireless network interface or a wired network interface, and the network interface 93 is generally used to establish a communication connection between the computer device 9 and other electronic devices.
The present application further provides another embodiment, which is to provide a computer-readable storage medium storing a server maintenance program, which is executable by at least one processor to cause the at least one processor to perform the steps of an interface testing method as described above.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method of the embodiments of the present application.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.
Claims (10)
1. An interface testing method, comprising:
acquiring a test request instruction from a user end to a test interface;
analyzing the request test instruction, and acquiring a specified test interface and a test scene identifier in the request test instruction, wherein the test scene identifier is used for representing a test scene corresponding to the specified test interface;
acquiring data of the specified test interface from the specified test interface;
according to the test scene identification, obtaining a configuration file corresponding to the test scene identification from the specified test interface data;
generating a test case corresponding to the test scene identification according to the configuration file;
and uploading the test case to the specified test interface to perform interface test, so as to obtain a test result.
2. The interface testing method according to claim 1, wherein the generating a test case corresponding to the test scenario identifier according to the configuration file includes:
sending the configuration file to the user side to obtain modified data returned by the user side to the configuration file, wherein the modified data is modified configuration file data and comprises modified configuration file data and unmodified configuration file data;
converting the format of the modified data into a preset format to obtain target modified data;
and generating a test case corresponding to the test scene identification according to the target modification data.
3. The interface testing method according to claim 2, wherein the uploading the test case to the specified testing interface for interface testing to obtain a testing result comprises:
extracting test parameters of the specified test interface data in the test scene from the test case;
in the test scene, calling the specified test interface according to the test parameters to obtain response data returned by the specified test interface in the scene test process;
and generating a test result of the specified test interface according to the response data.
4. The interface testing method of claim 3, wherein generating a test result for a specified test interface according to the response data comprises:
analyzing the target modification data to obtain an expected assertion rule list in the target modification data;
extracting corresponding contents of the expected assertion rule list through a content extractor to obtain an assertion expected result corresponding to the test scene;
extracting response result data of a specified test interface in the response data;
performing character string matching on the response result data and the assertion expected result to obtain a character string matching result;
and generating the test result according to the character string matching result.
5. The interface testing method according to claim 1, wherein the analyzing the request testing instruction to obtain the specified testing interface and the testing scenario identifier in the request testing instruction comprises:
analyzing the request test instruction, and acquiring a specified test interface identifier and a test scene identifier in the request test instruction;
traversing the test interfaces in the interface set, and judging whether a test interface matched with the specified test interface identifier exists in the test interfaces in the interface set;
if the matched test interface exists, judging that the specified test interface exists in the request test instruction, and taking the matched test interface as the specified test interface.
6. The interface testing method according to any one of claims 1 to 5, wherein after the test case is uploaded to the specified testing interface to perform interface testing, and a test result is obtained, the method further comprises:
acquiring a first timestamp of the test case uploaded to the specified test interface;
acquiring a second timestamp of returned data after the test scene test is finished;
and calculating the time difference between the second time stamp and the first time stamp, and taking the time difference as the response time of the interface.
7. An interface testing apparatus, comprising:
the test request instruction module is used for acquiring a test request instruction from a user terminal to the test interface;
the specified test interface module is used for analyzing the request test instruction and acquiring a specified test interface and a test scene identifier in the request test instruction, wherein the test scene identifier is used for representing a test scene corresponding to the specified test interface;
the test interface data module is used for acquiring the data of the specified test interface from the specified test interface;
the configuration file acquisition module is used for acquiring a configuration file corresponding to the test scene identifier from the specified test interface data according to the test scene identifier;
the test case generation module is used for generating a test case corresponding to the test scene identifier according to the configuration file;
and the test result generation module is used for uploading the test case to the specified test interface to carry out interface test so as to obtain a test result.
8. The interface test apparatus of claim 7, wherein the test case generation module comprises:
a modified data obtaining unit, configured to send the configuration file to the user side, so as to obtain modified data returned by the user side to the configuration file, where the modified data is modified configuration file data and includes modified configuration file data and unmodified configuration file data;
the modified data conversion unit is used for converting the format of the modified data into a preset format to obtain target modified data;
and the test case acquisition unit is used for generating the test case corresponding to the test scene identifier according to the target modification data.
9. A computer device comprising a memory in which a computer program is stored and a processor which, when executing the computer program, implements an interface testing method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that a computer program is stored thereon, which computer program, when being executed by a processor, carries out the interface testing method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011548553.2A CN112597020A (en) | 2020-12-24 | 2020-12-24 | Interface testing method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011548553.2A CN112597020A (en) | 2020-12-24 | 2020-12-24 | Interface testing method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112597020A true CN112597020A (en) | 2021-04-02 |
Family
ID=75200849
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011548553.2A Pending CN112597020A (en) | 2020-12-24 | 2020-12-24 | Interface testing method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112597020A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113051171A (en) * | 2021-04-08 | 2021-06-29 | 平安国际智慧城市科技股份有限公司 | Interface test method, device, equipment and storage medium |
CN113220579A (en) * | 2021-05-18 | 2021-08-06 | 京东科技控股股份有限公司 | Method, device, equipment and storage medium for processing stock test data |
CN113342677A (en) * | 2021-06-29 | 2021-09-03 | 平安普惠企业管理有限公司 | Interface testing method and device, computer equipment and storage medium |
CN113377667A (en) * | 2021-06-29 | 2021-09-10 | 平安国际融资租赁有限公司 | Scene-based testing method and device, computer equipment and storage medium |
CN113590483A (en) * | 2021-07-30 | 2021-11-02 | 北京京东振世信息技术有限公司 | Case operation method and device |
CN113778878A (en) * | 2021-09-10 | 2021-12-10 | 未鲲(上海)科技服务有限公司 | Interface testing method and device, electronic equipment and storage medium |
CN114218110A (en) * | 2021-12-17 | 2022-03-22 | 平安养老保险股份有限公司 | Account checking test method and device for financial data, computer equipment and storage medium |
CN114579473A (en) * | 2022-05-09 | 2022-06-03 | 太平金融科技服务(上海)有限公司深圳分公司 | Application testing method, device, equipment and storage medium |
-
2020
- 2020-12-24 CN CN202011548553.2A patent/CN112597020A/en active Pending
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113051171A (en) * | 2021-04-08 | 2021-06-29 | 平安国际智慧城市科技股份有限公司 | Interface test method, device, equipment and storage medium |
CN113051171B (en) * | 2021-04-08 | 2024-04-02 | 深圳赛安特技术服务有限公司 | Interface testing method, device, equipment and storage medium |
CN113220579A (en) * | 2021-05-18 | 2021-08-06 | 京东科技控股股份有限公司 | Method, device, equipment and storage medium for processing stock test data |
CN113342677A (en) * | 2021-06-29 | 2021-09-03 | 平安普惠企业管理有限公司 | Interface testing method and device, computer equipment and storage medium |
CN113377667A (en) * | 2021-06-29 | 2021-09-10 | 平安国际融资租赁有限公司 | Scene-based testing method and device, computer equipment and storage medium |
CN113377667B (en) * | 2021-06-29 | 2024-05-10 | 平安国际融资租赁有限公司 | Scene-based testing method and device, computer equipment and storage medium |
CN113590483A (en) * | 2021-07-30 | 2021-11-02 | 北京京东振世信息技术有限公司 | Case operation method and device |
CN113590483B (en) * | 2021-07-30 | 2024-09-20 | 北京京东振世信息技术有限公司 | Use case operation method and device |
CN113778878A (en) * | 2021-09-10 | 2021-12-10 | 未鲲(上海)科技服务有限公司 | Interface testing method and device, electronic equipment and storage medium |
CN114218110A (en) * | 2021-12-17 | 2022-03-22 | 平安养老保险股份有限公司 | Account checking test method and device for financial data, computer equipment and storage medium |
CN114579473A (en) * | 2022-05-09 | 2022-06-03 | 太平金融科技服务(上海)有限公司深圳分公司 | Application testing method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112597020A (en) | Interface testing method and device, computer equipment and storage medium | |
CN111813701B (en) | HTTP-based interface testing method and device, computer equipment and storage medium | |
CN111552633A (en) | Interface abnormal call testing method and device, computer equipment and storage medium | |
CN109936621B (en) | Information security multi-page message pushing method, device, equipment and storage medium | |
CN110798445B (en) | Public gateway interface testing method and device, computer equipment and storage medium | |
CN109787974B (en) | Message data stream generation method and device, computer equipment and storage medium | |
CN112181835B (en) | Automatic test method, device, computer equipment and storage medium | |
CN112631924A (en) | Automatic testing method and device, computer equipment and storage medium | |
CN112328486A (en) | Interface automation test method and device, computer equipment and storage medium | |
CN112631911A (en) | Automatic testing method and device, computer equipment and storage medium | |
CN113434400A (en) | Test case execution method and device, computer equipment and storage medium | |
CN111026669B (en) | Test log management method, test log management device and storage medium | |
CN112966304A (en) | Method and device for preventing process document from being tampered, computer equipment and medium | |
CN114461833A (en) | Picture evidence obtaining method and device, computer equipment and storage medium | |
CN111813418A (en) | Distributed link tracking method, device, computer equipment and storage medium | |
CN113360300B (en) | Interface call link generation method, device, equipment and readable storage medium | |
CN111045934A (en) | Page analysis method, device, client, storage medium and electronic equipment | |
CN114489603A (en) | Code generation method, apparatus, electronic device, medium, and product | |
CN112817816B (en) | Embedded point processing method and device, computer equipment and storage medium | |
CN110727576A (en) | Web page testing method, device, equipment and storage medium | |
CN114968822A (en) | Interface testing method and device, computer equipment and storage medium | |
CN114637672A (en) | Automatic data testing method and device, computer equipment and storage medium | |
CN114371866A (en) | Version reconfiguration test method, device and equipment of service system | |
CN112817782A (en) | Data acquisition reporting method and device, electronic equipment and storage medium | |
CN112671615A (en) | Method, system and storage medium for collecting operation behavior data of front-end user |
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 |