Interface testing method, device, equipment and storage medium

By parsing and generating interface test requests, extracting and analyzing parameters, executing API tests and recording results, the problem of lack of interface documentation and testing tools in the microservice architecture is solved, improving the efficiency of interface testing and the simplicity of document maintenance.

CN115017037BActive Publication Date: 2024-08-27PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210576205.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-25
Publication Date
2024-08-27
Estimated Expiration
2042-05-25

AI Technical Summary

Technical Problem

The existing microservice architecture lacks its own interface document generation tools and interface testing tools, causing developers and testers to spend a lot of time on interface document maintenance and test execution, and cannot generate interface simulation parameters and save test records, which increases time costs. and analysis difficulty.

Method used

Provide an interface testing method by receiving front-end requests, parsing and generating target configurations, extracting request and return parameter classes, generating JSON objects and writing them to the database, generating simulation parameters, executing API tests, recording and analyzing test results, and generating execution reports , including the number of interface execution times and success rate.

Benefits of technology

It reduces the time cost of assembling parameters during interface testing, improves testing efficiency, reduces interface document maintenance costs, and provides a unified interface document management entrance to facilitate development and testers to analyze test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115017037B
    Figure CN115017037B
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence, and discloses an interface testing method, device, equipment and storage medium for improving the efficiency of interface testing. The interface testing method comprises: obtaining the configuration corresponding to the preset local configuration file according to the target task to obtain the target configuration; parsing the target configuration and extracting the attributes of the request parameter class and the return parameter class to obtain the target attribute; parsing and converting the target attribute to obtain a JSON object; generating a simulation parameter interface through an application program interface; testing and executing the API through an execution interface to obtain execution parameters and execution results; using the JSON object, simulation parameters, execution parameters and execution results as test records in a relational data table, and performing statistical analysis on the test records in the relational data table to generate an execution report. In addition, the present invention also relates to blockchain technology, and the execution report can be stored in a blockchain node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to an interface testing method, device, equipment and storage medium. Background Art

[0002] Currently, many large enterprise system development adopts a front-end and back-end separation development method, and the back-end development technology is popular with microservice architecture. However, many microservice frameworks fail to come with interface document generation tools and interface testing tools, causing developers and testers to spend a lot of time on interface document maintenance.

[0003] For a system like a bank that prioritizes stability and security, using this type of intrusive interface document generation tool is not a good option. In addition, although this type of tool provides an interface test execution entry, it fails to generate interface simulation parameters and fails to save interface execution records, increasing the time cost of assembling parameters during test execution, and testers are unable to review and analyze historical execution records. Summary of the invention

[0004] The present invention provides an interface testing method, device, equipment and storage medium for improving the efficiency of interface testing.

[0005] The first aspect of the present invention provides an interface testing method, which includes: receiving an interface testing request sent by a front end, and calling a preset application program interface to parse the interface testing request to obtain a target task corresponding to the interface testing request, and obtaining a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration; parsing the target configuration to obtain a request parameter class and a return parameter class corresponding to the target configuration, and extracting attributes from the request parameter class and the return parameter class to obtain target attributes corresponding to the request parameter class and the return parameter class; parsing and converting the target attributes to obtain a JSON object corresponding to the target attributes, and extracting the target attributes according to the application program interface. The interface writes the JSON object into a preset relational database; generates a simulation parameter interface through the application interface, and writes the simulation parameters into the relational database; obtains the execution interface corresponding to the application interface, and tests and executes the API through the execution interface to obtain execution parameters and execution results, and writes the execution parameters and the execution results into the relational database table; uses the JSON object, the simulation parameters, the execution parameters and the execution results as test records in the relational data table, and performs statistical analysis on the test records in the relational data table through the application interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate.

[0006] Optionally, in a first implementation method of the first aspect of the present invention, the interface test request sent by the receiving front end is received, and a preset application program interface is called to parse the interface test request to obtain a target task corresponding to the interface test request, and a configuration corresponding to a preset local configuration file is obtained according to the target task to obtain a target configuration, including: receiving an interface test request sent by the front end; calling a preset application program interface to perform address resolution on the interface test request to obtain a request address corresponding to the interface test request, and matching the API resolution task corresponding to the interface test request according to the request address to obtain a target task corresponding to the interface test request; obtaining a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration, wherein the target configuration includes a repository address of the Java source code and an address of the application program interface.

[0007] Optionally, in a second implementation method of the first aspect of the present invention, the target configuration is parsed to obtain a request parameter class and a return parameter class corresponding to the target configuration, and attributes of the request parameter class and the return parameter class are extracted to obtain target attributes corresponding to the request parameter class and the return parameter class, including: source file parsing the target configuration to obtain a parsing result, wherein the parsing result includes information of the source file containing annotations and information of the source file not containing annotations; if the parsing result is that the information of the source file contains annotations, the request parameter class and the return parameter class corresponding to the information of the source file are extracted, and the target attributes are generated according to the request parameter class and the return parameter class.

[0008] Optionally, in a third implementation method of the first aspect of the present invention, the source file of the target configuration is parsed to obtain a parsing result, wherein the parsing result includes the source file information containing annotations and the source file information not containing annotations, including: reading the warehouse address in the target configuration to obtain the warehouse address to be parsed; downloading the warehouse address with parsing to a local directory, and scanning the local directory to obtain a Java file in a preset suffix format; parsing the Java file to obtain a parsing result, wherein the parsing result includes the source file information containing annotations and the source file information not containing annotations.

[0009] Optionally, in a fourth implementation method of the first aspect of the present invention, if the parsing result is that the information of the source file contains annotations, then the request parameter class and the return parameter class corresponding to the information of the source file are extracted, and target attributes are generated based on the request parameter class and the return parameter class, including: if the parsing result is that the information of the source file contains annotations, then the request parameter class and the return parameter class are parsed on the information of the source file to obtain the request parameter class and the return parameter class; the attributes corresponding to the request parameter class and the return parameter class are extracted, and the attributes are stored to obtain the target attributes.

[0010] Optionally, in a fifth implementation manner of the first aspect of the present invention, obtaining an execution interface corresponding to the application program interface, and testing and executing the API through the execution interface to obtain execution parameters and execution results, and writing the execution parameters and the execution results into the relational database table, includes: matching the parameters corresponding to the execution interface based on the execution interface corresponding to the application program interface to obtain a matching result; if the matching result is that the parameters are contained in a preset data table, obtaining the parameters; testing and executing the API based on the parameters and through the execution interface corresponding to the application program interface to obtain execution parameters and execution results, and writing the execution parameters and the execution results into the relational database table.

[0011] Optionally, in a sixth implementation method of the first aspect of the present invention, the JSON object, the simulation parameters, the execution parameters and the execution results are taken as test records in a relational data table, and the test records in the relational data table are statistically analyzed through the application interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate, including: taking the JSON object, the simulation parameters, the execution parameters and the execution results as test records in a relational data table; calculating the number of executions of the test records through the application interface to obtain the number of executions; analyzing the execution success rate of the test records through the application interface to obtain the execution success rate; and generating an execution report based on the number of executions and the execution success rate.

[0012] The second aspect of the present invention provides an interface testing device, which includes: a receiving module, which is used to receive an interface testing request sent by a front end, and call a preset application program interface to parse the interface testing request to obtain a target task corresponding to the interface testing request, and obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration; a parsing module, which is used to parse and process the target configuration to obtain a request parameter class and a return parameter class corresponding to the target configuration, and extract attributes from the request parameter class and the return parameter class to obtain target attributes corresponding to the request parameter class and the return parameter class; a conversion module, which is used to parse and convert the target attributes to obtain a JSON object corresponding to the target attributes, and extract the target attributes according to the application program interface. The interface writes the JSON object into a preset relational database; a processing module is used to generate a simulation parameter interface through the application interface, and write the simulation parameters into the relational database; an execution module is used to obtain the execution interface corresponding to the application interface, and test the API through the execution interface to obtain execution parameters and execution results, and write the execution parameters and execution results into the relational database table; a generation module is used to use the JSON object, the simulation parameters, the execution parameters and the execution results as test records in the relational data table, and perform statistical analysis on the test records in the relational data table through the application interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate.

[0013] Optionally, in a first implementation method of the second aspect of the present invention, the receiving module is specifically used to: receive an interface test request sent by a front end; call a preset application program interface to perform address resolution on the interface test request to obtain a request address corresponding to the interface test request, and match the API resolution task corresponding to the interface test request according to the request address to obtain a target task corresponding to the interface test request; obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration, wherein the target configuration includes a repository address of the Java source code and an address of the application program interface.

[0014] Optionally, in a second implementation method of the second aspect of the present invention, the parsing module further includes: an analysis unit, used to perform source file parsing on the target configuration to obtain a parsing result, wherein the parsing result includes the source file information containing annotations and the source file information not containing annotations; an extraction unit, used to extract the request parameter class and return parameter class corresponding to the information of the source file if the parsing result is that the source file information contains annotations, and generate target properties based on the request parameter class and the return parameter class.

[0015] Optionally, in a third implementation method of the second aspect of the present invention, the analysis unit is specifically used to: read the warehouse address in the target configuration to obtain the warehouse address to be parsed; download the warehouse address with parsing to a local directory, and scan the local directory to obtain a Java file with a preset suffix format; parse the Java file to obtain a parsing result, wherein the parsing result includes the source file information containing annotations and the source file information not containing annotations.

[0016] Optionally, in a fourth implementation method of the second aspect of the present invention, the extraction unit is specifically used to: if the parsing result is that the information of the source file contains annotations, then parse the information of the source file into a request parameter class and a return parameter class to obtain a request parameter class and a return parameter class; extract attributes corresponding to the request parameter class and the return parameter class, and store the attributes to obtain target attributes.

[0017] Optionally, in a fifth implementation of the second aspect of the present invention, the execution module is specifically used to: match the parameters corresponding to the execution interface based on the execution interface corresponding to the application program interface to obtain a matching result; if the matching result is that the parameters are contained in a preset data table, then the parameters are obtained; based on the parameters and through the execution interface corresponding to the application program interface, the API is tested and executed to obtain execution parameters and execution results, and the execution parameters and the execution results are written into the relational database table.

[0018] Optionally, in a sixth implementation method of the second aspect of the present invention, the generation module is specifically used to: use the JSON object, the simulation parameters, the execution parameters and the execution results as test records in a relational data table; calculate the number of executions of the test records through the application interface to obtain the number of executions; analyze the execution success rate of the test records through the application interface to obtain the execution success rate; and generate an execution report based on the number of executions and the execution success rate.

[0019] The third aspect of the present invention provides an interface testing device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the interface testing device executes the above-mentioned interface testing method.

[0020] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned interface testing method.

[0021] In the technical solution provided by the present invention, the target configuration is parsed and processed to obtain the request parameter class and return parameter class corresponding to the target configuration, and the request parameter class and return parameter class are attributed extracted to obtain the target attribute corresponding to the request parameter class and return parameter class; the target attribute is parsed and converted to obtain the JSON object corresponding to the target attribute, and the JSON object is written into a preset relational database according to the application program interface; a simulation parameter interface is generated through the application program interface, and the simulation parameter is written into the relational database; the execution interface corresponding to the application program interface is obtained, and the API is tested and executed through the execution interface to obtain the execution parameters and the execution results, and the execution parameters and the execution results are written into the relational database table; the JSON object, the simulation parameter, the execution parameter and the execution result are used as the test record, and the test record in the relational data table is statistically analyzed through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate. The present invention reduces the time cost of assembling interface parameters when testing the interface by statistically analyzing the test records and generating interface simulation request parameters, thereby improving the efficiency of interface testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A schematic diagram of an embodiment of an interface testing method in an embodiment of the present invention;

[0023] Figure 2 A schematic diagram of another embodiment of the interface testing method in an embodiment of the present invention;

[0024] Figure 3 A schematic diagram of an embodiment of an interface testing device in an embodiment of the present invention;

[0025] Figure 4 A schematic diagram of another embodiment of the interface testing device in an embodiment of the present invention;

[0026] Figure 5 The figure is a schematic diagram of an embodiment of an interface testing device in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] Embodiments of the present invention provide an interface testing method, apparatus, equipment and storage medium for improving the efficiency of interface testing. The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , the first embodiment of the interface testing method in the embodiment of the present invention includes:

[0029] 101. Receive an interface test request sent by the front end, call a preset application program interface to parse the interface test request, obtain a target task corresponding to the interface test request, and obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration;

[0030] Specifically, the server application programming interface (API) parsing task reads the configuration of the local configuration file, and the target configuration content includes the warehouse address of the Java source code and the address of the application program interface. The server provides a visual, user-friendly, browser-based interface management and interface execution interface through the web front end; including interface list query, interface request response parameter detail view, interface test execution, interface execution record view and other operation functions, which are stored and retrieved through the API Server (application service) module.

[0031] It is understandable that the execution subject of the present invention can be an interface test device, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking the server as the execution subject as an example. The embodiment of the present invention can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning. The server can be an independent server, or it can be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0032] 102. Analyze the target configuration to obtain a request parameter class and a return parameter class corresponding to the target configuration, and extract attributes of the request parameter class and the return parameter class to obtain target attributes corresponding to the request parameter class and the return parameter class;

[0033] Specifically, the server reads the repository address of the configured Java source code and downloads the Java source code to be parsed to a local directory; after downloading, it scans the local Java source file directory to find all files with the suffix .java, and uses the JavaParser package to parse each Java file found to parse whether the class or method of the source file contains the specified annotation; if it includes this annotation, it finds the method containing the annotation, parses the corresponding request parameter class and return parameter class, obtains the attributes of the corresponding parameter class and return parameter class, and stores them in a key-value manner, where the key is the attribute name and the value is the attribute type.

[0034] 103. Parse and convert the target attribute to obtain a JSON object corresponding to the target attribute, and write the JSON object into a preset relational database according to an application program interface;

[0035] Specifically, after parsing all the request parameters and response parameter class attributes, the server converts them into JSON objects, calls the application service interface configured in the configuration file and writes them into the esa_api table of the relational database. It should be noted that the server parses and converts the target attributes, obtains the JSON object corresponding to the target attributes, and writes the JSON object into the preset relational database Mysql DB (MySql database) according to the application interface, using the mysql database for data storage.

[0036] 104. Generate a simulation parameter interface through an application program interface, and write the simulation parameters into a relational database;

[0037] Specifically, the server generates a simulation parameter interface by calling the application service, generates simulation parameters for each parsed one, and writes them into the esa_api_demo table of the relational database; and displays the page through the application service simulation parameter query interface, which is convenient for developers and testers to view parameter examples and conduct corresponding tests. The interface document can be generated without modifying the code, which greatly reduces the maintenance cost of the interface document. Developers do not need to maintain the interface document, and can directly generate interface simulation request parameters, which reduces the time cost of assembling interface parameters when testing the interface, and improves the work efficiency of the front-end, back-end, caller, and tester. The interface execution history is saved to facilitate developers and testers to analyze and summarize test results and conclusions; the unified interface document management portal makes the interface document more standardized and unified, and maintenance is simpler.

[0038] 105. Obtain an execution interface corresponding to the application program interface, and test and execute the API through the execution interface to obtain execution parameters and execution results, and write the execution parameters and execution results into a relational database table;

[0039] Specifically, the server obtains the execution parameters, method parameters and input parameters corresponding to the interface to be tested based on the JAVA reflection mechanism. The server generates a test class and a test method according to the class parameters and the method parameters respectively. The server selects the parameters to be tested from the corresponding value library based on the parameters and generates input data. The server performs the test according to the input data through the test class and the test method to obtain the execution result. The server encapsulates the test class, test method and input data to generate execution parameters.

[0040] 106. The JSON object, simulation parameters, execution parameters and execution results are used as test records in the relational data table, and the test records in the relational data table are statistically analyzed through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate.

[0041] Specifically, the server; randomly generates a simulated value of the parameter attribute according to the attribute type of the input entity class and the response entity class of the interface, thereby generating examples of interface request parameters and response parameters; derives and simulates valid JSON parameter values ​​for the interface request parameters according to the parameter type and execution history records. If the interface has no execution record, the request parameter example is used as a valid JSON parameter; if an execution record exists, the most recent execution priority algorithm is used to obtain the request parameters in the most recent execution record as valid JSON parameters; the interface test execution record is saved to facilitate testers to repeat execution and analyze test results.

[0042] Furthermore, the server stores the execution report in the blockchain database, which is not specifically limited here.

[0043] In the embodiment of the present invention, the target configuration is parsed and processed to obtain the request parameter class and return parameter class corresponding to the target configuration, and the request parameter class and return parameter class are attributed extracted to obtain the target attribute corresponding to the request parameter class and return parameter class; the target attribute is parsed and converted to obtain the JSON object corresponding to the target attribute, and the JSON object is written into a preset relational database according to the application program interface; a simulation parameter interface is generated through the application program interface, and the simulation parameter is written into the relational database; an execution interface corresponding to the application program interface is obtained, and the API is tested and executed through the execution interface to obtain execution parameters and execution results, and the execution parameters and execution results are written into a relational database table; the JSON object, simulation parameters, execution parameters and execution results are used as test records, and the test records in the relational data table are statistically analyzed through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate. The present invention reduces the time cost of assembling interface parameters when testing the interface by statistically analyzing the test records and generating interface simulation request parameters, thereby improving the efficiency of interface testing.

[0044] See also Figure 2 , a second embodiment of the interface testing method in the embodiment of the present invention includes:

[0045] 201. Receive an interface test request sent by the front end, call a preset application program interface to parse the interface test request, obtain a target task corresponding to the interface test request, and obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration;

[0046] Specifically, the server receives the interface test request sent by the front end; the server calls the preset application program interface to perform address resolution on the interface test request, obtains the request address corresponding to the interface test request, and matches the API resolution task corresponding to the interface test request according to the request address, and obtains the target task corresponding to the interface test request; the server obtains the configuration corresponding to the preset local configuration file according to the target task, and obtains the target configuration, wherein the target configuration includes the warehouse address of the java source code and the address of the application program interface. Specifically, the server API resolution task reads the configuration of the local configuration file, and the target configuration content includes the warehouse address of the java source code and the address of the application program interface; then reads through the warehouse address of the configuration Java source code, and downloads the Java source code to be resolved to the local directory. The application service (API application service) mainly provides interface services, provides access interfaces for front-end web page operations and API resolution tasks, and performs storage and retrieval operations on the operated data; the API Parser Job (API resolution task) is mainly used to download the source code, parse the source code, generate the data format required by the interface document, and then write it to the database by calling the interface provided by the application service.

[0047] 202. Parse the target configuration source file to obtain a parsing result, wherein the parsing result includes information of the source file including annotations and information of the source file not including annotations;

[0048] Specifically, the server parses the source file of the target configuration to obtain the parsing result, wherein the parsing result includes whether the source file information contains annotations and whether the source file information does not contain annotations; if the parsing result is that the source file information contains annotations, the request parameter class and return parameter class corresponding to the source file information are extracted, and the target attribute is generated according to the request parameter class and the return parameter class, and each Java file found is parsed using the JavaParser package to parse whether the class or method of the source file contains the specified annotation, such as (@ESA, @RestController, @Controller, etc.); if this annotation is included, the method containing the annotation is found. Specifically, the server reads the warehouse address in the target configuration to obtain the warehouse address to be parsed; the server downloads the warehouse address with parsing to the local directory, and scans the local directory to obtain a Java file with a preset suffix format; the server parses the Java file to obtain the parsing result, wherein the parsing result includes whether the source file information contains annotations and whether the source file information does not contain annotations. Specifically, the server obtains the warehouse address to be parsed by reading the warehouse address of the configured Java source code, and downloads the Java source code to be parsed to a local directory; after downloading, the local Java source file directory is scanned to find all files with the suffix .java, and each Java file found is parsed using the JavaParser package to parse whether the class or method of the source file contains the specified annotation. The parsing results include the source file information containing the annotation and the source file information not containing the annotation.

[0049] 203. If the parsing result is that the information of the source file contains annotations, extract the request parameter class and the return parameter class corresponding to the information of the source file, and generate the target attribute according to the request parameter class and the return parameter class;

[0050] Specifically, if the server parses the information of the source file as an annotation, the server parses the information of the source file into a request parameter class and a return parameter class to obtain the request parameter class and the return parameter class; the server extracts the attributes corresponding to the request parameter class and the return parameter class, and stores the attributes to obtain the target attribute. Specifically, if the server parses the information of the source file as an annotation, if the annotation is included, the method containing the annotation is found, the corresponding request parameter class and the return parameter class are parsed, the attributes of the corresponding parameter class and the return parameter class are obtained, and stored in a key-value manner, where the key is the attribute name and the value is the attribute type. If the server parses the information of the source file as an annotation, the server parses the information of the source file into a request parameter class and a return parameter class, and parses the parameter class according to the parameter identifier in the source file to obtain the request parameter class and the return parameter class; the server extracts the attributes corresponding to the request parameter class and the return parameter class, and stores the attributes to obtain the target attribute.

[0051] 204. Parse and convert the target attribute to obtain a JSON object corresponding to the target attribute, and write the JSON object into a preset relational database according to an application program interface;

[0052] Specifically, after parsing all the request parameters and response parameter class attributes, the server converts them into JSON objects, calls the application service interface configured in the configuration file and writes them into the esa_api table of the relational database. It should be noted that the server parses and converts the target attributes, obtains the JSON object corresponding to the target attributes, and writes the JSON object into the preset relational database Mysql DB (MySql database) according to the application interface, using the mysql database for data storage.

[0053] 205. Generate a simulation parameter interface through an application program interface, and write the simulation parameters into a relational database;

[0054] Specifically, the server generates a simulation parameter interface by calling the application service, generates simulation parameters for each parsed one, and writes them into the esa_api_demo table of the relational database; and displays the page through the application service simulation parameter query interface, which is convenient for developers and testers to view parameter examples and conduct corresponding tests. The interface document can be generated without modifying the code, which greatly reduces the maintenance cost of the interface document. Developers do not need to maintain the interface document, and can directly generate interface simulation request parameters, which reduces the time cost of assembling interface parameters when testing the interface, and improves the work efficiency of the front-end, back-end, caller, and tester. The interface execution history is saved to facilitate developers and testers to analyze and summarize test results and conclusions; the unified interface document management portal makes the interface document more standardized and unified, and maintenance is simpler.

[0055] 206. Obtain an execution interface corresponding to the application program interface, and test and execute the API through the execution interface to obtain execution parameters and execution results, and write the execution parameters and execution results into a relational database table;

[0056] Specifically, the server matches the execution interface corresponding to the application program interface with the parameters corresponding to the execution interface to obtain a matching result; if the matching result is that the preset data table contains the parameters, the server obtains the parameters; the server tests and executes the API based on the parameters and through the execution interface corresponding to the application program interface, obtains the execution parameters and execution results, and writes the execution parameters and execution results into the relational database table. Specifically, the server queries all API data written to the database esa_api table by the parsing task by calling the application program interface query list interface and displays it on the web page; in this way, developers and testers can view the interface document through this page. Specifically, the server tests and executes the API by calling the execution interface provided by the application program service. When the API is executed, the last record in the esa_api_run table is used as the parameter by default. If there is no execution record in the esa_api_run table, the record in the esa_api_demo table is used as the parameter for execution. After execution, the execution parameters and execution results are written into the relational database esa_api_run table.

[0057] 207. The JSON object, simulation parameters, execution parameters and execution results are used as test records in the relational data table, and statistical analysis is performed on the test records in the relational data table through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate.

[0058] Specifically, the server uses the JSON object, simulation parameters, execution parameters, and execution results as test records in a relational data table; the server calculates the number of executions of the test records through the application program interface to obtain the number of executions; the server analyzes the execution success rate of the test records through the application program interface to obtain the execution success rate; the server generates an execution report based on the number of executions and the execution success rate. Specifically, the server uses the API execution record analysis interface provided by the application program service to perform statistical analysis on the AIP test records and generate an execution report, including the number of interface executions, execution success rate, etc. In this way, the test can conveniently view the records, without code intrusion, zero annotations, zero learning cost, and reversely generate interface definitions based on the request parameter type and response parameter type of the interface source code.

[0059] Furthermore, the server stores the execution report in the blockchain database, which is not specifically limited here.

[0060] In the embodiment of the present invention, the target configuration is parsed and processed to obtain the request parameter class and return parameter class corresponding to the target configuration, and the request parameter class and return parameter class are attributed extracted to obtain the target attribute corresponding to the request parameter class and return parameter class; the target attribute is parsed and converted to obtain the JSON object corresponding to the target attribute, and the JSON object is written into a preset relational database according to the application program interface; a simulation parameter interface is generated through the application program interface, and the simulation parameter is written into the relational database; an execution interface corresponding to the application program interface is obtained, and the API is tested and executed through the execution interface to obtain execution parameters and execution results, and the execution parameters and execution results are written into a relational database table; the JSON object, simulation parameters, execution parameters and execution results are used as test records, and the test records in the relational data table are statistically analyzed through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate. The present invention reduces the time cost of assembling interface parameters when testing the interface by statistically analyzing the test records and generating interface simulation request parameters, thereby improving the efficiency of interface testing.

[0061] The interface testing method in the embodiment of the present invention is described above. The interface testing device in the embodiment of the present invention is described below. Figure 3 , the first embodiment of the interface testing device in the embodiment of the present invention includes:

[0062] The receiving module 301 is used to receive the interface test request sent by the front end, and call the preset application program interface to parse the interface test request to obtain the target task corresponding to the interface test request, and obtain the configuration corresponding to the preset local configuration file according to the target task to obtain the target configuration;

[0063] The parsing module 302 is used to parse the target configuration to obtain the request parameter class and the return parameter class corresponding to the target configuration, and extract attributes from the request parameter class and the return parameter class to obtain the target attributes corresponding to the request parameter class and the return parameter class;

[0064] The conversion module 303 is used to parse and convert the target attribute to obtain a JSON object corresponding to the target attribute, and write the JSON object into a preset relational database according to the application program interface;

[0065] A processing module 304 is used to generate a simulation parameter interface through the application program interface and write the simulation parameters into the relational database;

[0066] An execution module 305 is used to obtain an execution interface corresponding to the application program interface, and test and execute the API through the execution interface to obtain execution parameters and execution results, and write the execution parameters and the execution results into the relational database table;

[0067] The generation module 306 is used to use the JSON object, the simulation parameters, the execution parameters and the execution results as test records in the relational data table, and perform statistical analysis on the test records in the relational data table through the application interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate.

[0068] Furthermore, the server stores the execution report in the blockchain database, which is not specifically limited here.

[0069] In the embodiment of the present invention, the target configuration is parsed and processed to obtain the request parameter class and return parameter class corresponding to the target configuration, and the request parameter class and return parameter class are attributed extracted to obtain the target attribute corresponding to the request parameter class and return parameter class; the target attribute is parsed and converted to obtain the JSON object corresponding to the target attribute, and the JSON object is written into a preset relational database according to the application program interface; a simulation parameter interface is generated through the application program interface, and the simulation parameter is written into the relational database; an execution interface corresponding to the application program interface is obtained, and the API is tested and executed through the execution interface to obtain execution parameters and execution results, and the execution parameters and execution results are written into a relational database table; the JSON object, simulation parameters, execution parameters and execution results are used as test records, and the test records in the relational data table are statistically analyzed through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate. The present invention reduces the time cost of assembling interface parameters when testing the interface by statistically analyzing the test records and generating interface simulation request parameters, thereby improving the efficiency of interface testing.

[0070] See also Figure 4 The second embodiment of the interface testing device in the embodiment of the present invention includes:

[0071] The receiving module 301 is used to receive the interface test request sent by the front end, and call the preset application program interface to parse the interface test request to obtain the target task corresponding to the interface test request, and obtain the configuration corresponding to the preset local configuration file according to the target task to obtain the target configuration;

[0072] The parsing module 302 is used to parse the target configuration to obtain the request parameter class and the return parameter class corresponding to the target configuration, and extract attributes from the request parameter class and the return parameter class to obtain the target attributes corresponding to the request parameter class and the return parameter class;

[0073] The conversion module 303 is used to parse and convert the target attribute to obtain a JSON object corresponding to the target attribute, and write the JSON object into a preset relational database according to the application program interface;

[0074] A processing module 304 is used to generate a simulation parameter interface through the application program interface and write the simulation parameters into the relational database;

[0075] An execution module 305 is used to obtain an execution interface corresponding to the application program interface, and test and execute the API through the execution interface to obtain execution parameters and execution results, and write the execution parameters and the execution results into the relational database table;

[0076] The generation module 306 is used to use the JSON object, the simulation parameters, the execution parameters and the execution results as test records in the relational data table, and perform statistical analysis on the test records in the relational data table through the application interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate.

[0077] Optionally, the receiving module 301 is specifically used for:

[0078] Receive an interface test request sent by the front end; call a preset application program interface to perform address resolution on the interface test request to obtain a request address corresponding to the interface test request, and match the API resolution task corresponding to the interface test request according to the request address to obtain a target task corresponding to the interface test request; obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration, wherein the target configuration includes a repository address of a Java source code and an address of an application program interface.

[0079] Optionally, the parsing module 302 further includes:

[0080] The analyzing unit 3021 is used to parse the source file of the target configuration to obtain a parsing result, wherein the parsing result includes information of the source file including annotations and information of the source file not including annotations;

[0081] The extraction unit 3022 is used to extract the request parameter class and the return parameter class corresponding to the information of the source file if the parsing result is that the information of the source file contains annotations, and generate target attributes according to the request parameter class and the return parameter class.

[0082] Optionally, the analysis unit 3021 is specifically used for:

[0083] Read the warehouse address in the target configuration to obtain the warehouse address to be parsed; download the warehouse address with parsing to a local directory, and scan the local directory to obtain a Java file in a preset suffix format; parse the Java file to obtain a parsing result, wherein the parsing result includes the source file information containing annotations and the source file information not containing annotations.

[0084] Optionally, the extraction unit 3022 is specifically used for:

[0085] If the parsing result is that the information of the source file contains annotations, the information of the source file is parsed into a request parameter class and a return parameter class to obtain a request parameter class and a return parameter class; the attributes corresponding to the request parameter class and the return parameter class are extracted, and the attributes are stored to obtain target attributes.

[0086] Optionally, the execution module 305 is specifically used for:

[0087] Based on the execution interface corresponding to the application program interface, the parameters corresponding to the execution interface are matched to obtain a matching result; if the matching result is that the parameters are included in a preset data table, the parameters are obtained; based on the parameters and through the execution interface corresponding to the application program interface, the API is tested and executed to obtain execution parameters and execution results, and the execution parameters and the execution results are written into the relational database table.

[0088] Optionally, the generating module 306 is specifically used for:

[0089] The JSON object, the simulation parameters, the execution parameters and the execution results are used as test records in a relational data table; the number of executions of the test records is calculated through the application program interface to obtain the number of executions; the execution success rate of the test records is analyzed through the application program interface to obtain the execution success rate; and an execution report is generated based on the number of executions and the execution success rate.

[0090] Furthermore, the server stores the execution report in the blockchain database, which is not specifically limited here.

[0091] In the embodiment of the present invention, the target configuration is parsed and processed to obtain the request parameter class and return parameter class corresponding to the target configuration, and the request parameter class and return parameter class are attributed extracted to obtain the target attribute corresponding to the request parameter class and return parameter class; the target attribute is parsed and converted to obtain the JSON object corresponding to the target attribute, and the JSON object is written into a preset relational database according to the application program interface; a simulation parameter interface is generated through the application program interface, and the simulation parameter is written into the relational database; an execution interface corresponding to the application program interface is obtained, and the API is tested and executed through the execution interface to obtain execution parameters and execution results, and the execution parameters and execution results are written into a relational database table; the JSON object, simulation parameters, execution parameters and execution results are used as test records, and the test records in the relational data table are statistically analyzed through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate. The present invention reduces the time cost of assembling interface parameters when testing the interface by statistically analyzing the test records and generating interface simulation request parameters, thereby improving the efficiency of interface testing.

[0092] above Figure 3 and Figure 4 The interface testing device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The interface testing device in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0093] Figure 5 1 is a schematic diagram of the structure of an interface test device provided by an embodiment of the present invention. The interface test device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 can be short-term storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the interface test device 500. Furthermore, the processor 510 can be configured to communicate with the storage medium 530 to execute a series of instruction operations in the storage medium 530 on the interface test device 500.

[0094] The interface test device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 5 The interface test device structure shown does not constitute a limitation on the interface test device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0095] The present invention also provides an interface testing device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor executes the steps of the interface testing method in the above-mentioned embodiments.

[0096] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the interface testing method.

[0097] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0098] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0099] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0100] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0101] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An interface testing method, characterized in that: The interface testing method comprises: Receive an interface test request sent by the front end, call a preset application program interface to parse the interface test request, obtain a target task corresponding to the interface test request, and obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration; Parsing the target configuration to obtain a request parameter class and a return parameter class corresponding to the target configuration, and extracting attributes from the request parameter class and the return parameter class to obtain target attributes corresponding to the request parameter class and the return parameter class; Parsing and converting the target attribute to obtain a JSON object corresponding to the target attribute, and writing the JSON object into a preset relational database according to the application program interface; Generate a simulation parameter interface through the application program interface, and write the simulation parameters into the relational database; Obtaining an execution interface corresponding to the application program interface, and testing and executing the API through the execution interface to obtain execution parameters and execution results, and writing the execution parameters and the execution results into the relational database table; The JSON object, the simulation parameter, the execution parameter and the execution result are used as test records in a relational data table, and statistical analysis is performed on the test records in the relational data table through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate; The parsing process of the target configuration to obtain a request parameter class and a return parameter class corresponding to the target configuration, and extracting attributes of the request parameter class and the return parameter class to obtain target attributes corresponding to the request parameter class and the return parameter class include: Parsing the target configuration source file to obtain a parsing result, wherein the parsing result includes information of the source file including annotations and information of the source file not including annotations; If the parsing result is that the information of the source file contains annotations, extracting the request parameter class and the return parameter class corresponding to the information of the source file, and generating target attributes according to the request parameter class and the return parameter class; The source file of the target configuration is parsed to obtain a parsing result, wherein the parsing result includes information of the source file including annotations and information of the source file not including annotations, including: Read the warehouse address in the target configuration to obtain the warehouse address to be resolved; Download the warehouse address to be parsed to a local directory, and scan the local directory to obtain a Java file in a preset suffix format; Parsing the Java file to obtain a parsing result, wherein the parsing result includes information of the source file including annotations and information of the source file not including annotations; The obtaining of the execution interface corresponding to the application program interface, testing and executing the API through the execution interface, obtaining execution parameters and execution results, and writing the execution parameters and the execution results into the relational database table includes: Based on the execution interface corresponding to the application program interface, matching the parameters corresponding to the execution interface obtains a matching result; If the matching result is that the preset data table contains parameters, then obtaining the parameters; Based on the parameters and through the execution interface corresponding to the application program interface, the API is tested and executed to obtain execution parameters and execution results, and the execution parameters and the execution results are written into the relational database table.

2. The interface testing method according to claim 1, characterized in that: The receiving interface test request sent by the front end, calling a preset application program interface to parse the interface test request, obtaining a target task corresponding to the interface test request, and obtaining a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration, including: Receive the interface test request sent by the front end; Calling a preset application program interface to perform address resolution on the interface test request to obtain a request address corresponding to the interface test request, and matching an API resolution task corresponding to the interface test request according to the request address to obtain a target task corresponding to the interface test request; According to the target task, a configuration corresponding to a preset local configuration file is acquired to obtain a target configuration, wherein the target configuration includes a repository address of a Java source code and an address of an application program interface.

3. The interface testing method according to claim 1, characterized in that: If the parsing result is that the information of the source file contains annotations, extracting the request parameter class and the return parameter class corresponding to the information of the source file, and generating target attributes according to the request parameter class and the return parameter class, including: If the parsing result is that the information of the source file contains annotations, performing request parameter class and return parameter class parsing on the information of the source file to obtain a request parameter class and a return parameter class; Attributes corresponding to the request parameter class and the return parameter class are extracted, and the attributes are stored to obtain target attributes.

4. The interface testing method according to any one of claims 1 to 3, characterized in that: The JSON object, the simulation parameter, the execution parameter and the execution result are used as test records in a relational data table, and statistical analysis is performed on the test records in the relational data table through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate, including: The JSON object, the simulation parameters, the execution parameters and the execution results are used as test records in a relational data table; Calculate the execution times of the test record through the application program interface to obtain the execution times; Performing an execution success rate analysis on the test record through the application program interface to obtain the execution success rate; An execution report is generated based on the execution times and the execution success rate.

5. An interface testing device, characterized in that: The interface testing device comprises: A receiving module is used to receive an interface test request sent by the front end, and call a preset application program interface to parse the interface test request to obtain a target task corresponding to the interface test request, and obtain a configuration corresponding to a preset local configuration file according to the target task to obtain a target configuration; A parsing module is used to parse the target configuration to obtain a request parameter class and a return parameter class corresponding to the target configuration, and to extract attributes from the request parameter class and the return parameter class to obtain target attributes corresponding to the request parameter class and the return parameter class; A conversion module, used to parse and convert the target attribute to obtain a JSON object corresponding to the target attribute, and write the JSON object into a preset relational database according to the application program interface; A processing module, used for generating a simulation parameter interface through the application program interface, and writing the simulation parameters into the relational database; An execution module, used to obtain an execution interface corresponding to the application program interface, and test and execute the API through the execution interface to obtain execution parameters and execution results, and write the execution parameters and the execution results into the relational database table; A generation module, used to use the JSON object, the simulation parameter, the execution parameter and the execution result as test records in a relational data table, and to perform statistical analysis on the test records in the relational data table through the application program interface to generate an execution report, wherein the execution report includes the number of interface executions and the execution success rate; The parsing module further includes: an analysis unit, configured to parse the target configuration source file to obtain a parsing result, wherein the parsing result includes whether the source file information contains annotations or not; an extraction unit, configured to extract a request parameter class and a return parameter class corresponding to the source file information if the parsing result is that the source file information contains annotations, and generate a target attribute according to the request parameter class and the return parameter class; The analysis unit is specifically used to: read the warehouse address in the target configuration to obtain the warehouse address to be parsed; download the warehouse address to be parsed to a local directory, and scan the local directory to obtain a Java file in a preset suffix format; parse the Java file to obtain a parsing result, wherein the parsing result includes whether the information of the source file contains annotations and whether the information of the source file does not contain annotations; The execution module is specifically used for: matching the parameters corresponding to the execution interface based on the execution interface corresponding to the application program interface to obtain a matching result; if the matching result is that the parameters are contained in a preset data table, then obtaining the parameters; testing and executing the API based on the parameters and through the execution interface corresponding to the application program interface to obtain execution parameters and execution results, and writing the execution parameters and the execution results into the relational database table.

6. The interface testing device according to claim 5, characterized in that: The receiving module is specifically used for: Receive the interface test request sent by the front end; Calling a preset application program interface to perform address resolution on the interface test request to obtain a request address corresponding to the interface test request, and matching an API resolution task corresponding to the interface test request according to the request address to obtain a target task corresponding to the interface test request; According to the target task, a configuration corresponding to a preset local configuration file is acquired to obtain a target configuration, wherein the target configuration includes a repository address of a Java source code and an address of an application program interface.

7. The interface testing device according to claim 5, characterized in that: The extraction unit is specifically used for: If the parsing result is that the information of the source file contains annotations, performing request parameter class and return parameter class parsing on the information of the source file to obtain a request parameter class and a return parameter class; Attributes corresponding to the request parameter class and the return parameter class are extracted, and the attributes are stored to obtain target attributes.

8. The interface testing device according to any one of claims 5 to 7, characterized in that: The generation module is specifically used for: The JSON object, the simulation parameters, the execution parameters and the execution results are used as test records in a relational data table; Calculate the execution times of the test record through the application program interface to obtain the execution times; Performing an execution success rate analysis on the test record through the application program interface to obtain the execution success rate; An execution report is generated based on the execution times and the execution success rate.

9. An interface testing device, characterized in that: The interface testing device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the interface testing device to execute the interface testing method according to any one of claims 1 to 4.

10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the interface testing method according to any one of claims 1 to 4 is implemented.