SDK interface testing method, system, and computer-readable storage medium

By automatically pulling and parsing the SDK source code from the code base, generating and deploying the SDK interface service project, the problems of high manual participation and low efficiency in existing SDK testing are solved, and efficient SDK interface testing is achieved.

CN113961178BActive Publication Date: 2025-10-03CHINA MERCHANTS BANK
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111174286.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-08
Publication Date
2025-10-03
Estimated Expiration
2041-10-08

AI Technical Summary

Technical Problem

Existing SDK testing technology requires a lot of manual participation and has a low degree of automation, resulting in low testing efficiency. Testers also need to spend time learning SDK unit test coding standards in different programming languages, increasing the risk of testing defects.

Method used

By receiving the SDK source code address request from the front end, it automatically pulls the SDK source code from the code library, parses and generates the SDK interface service project, and uses the template engine to automatically generate the SDK interface service project for automated deployment and testing, reducing manual workload.

Benefits of technology

It reduces the learning cost and defect risk of testers, improves SDK packaging efficiency and quality, and enhances testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113961178B_ABST
    Figure CN113961178B_ABST
Patent Text Reader

Abstract

This invention discloses an SDK interface testing method, system, and computer-readable storage medium. The method comprises: receiving an SDK source code address request from a front-end; pulling the specified SDK source code from a code repository based on the SDK source code address request; converting the SDK source code to generate a corresponding SDK interface service project; uploading the SDK interface service project to the code repository, and automatically deploying and testing the SDK interface service project. This invention significantly reduces the learning cost for testers and the risk of test defects; improves SDK packaging efficiency and quality; and enhances SDK testing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of interface testing, and in particular to an SDK interface testing method, system and computer-readable storage medium. Background Art

[0002] In recent years, with the in-depth development of cloud computing and the internet, cloud service applications have rapidly become popular, and cloud migration has become the norm for enterprises. However, as cloud projects evolve, more and more SDKs (Software Development Kits) are shared across development teams. Therefore, efficient SDK testing has become a pressing issue for enterprises.

[0003] Currently, conventional SDK testing methods mostly rely on unit testing. Furthermore, developers' cloud development frameworks and testers' automated testing frameworks often use different programming languages—for example, Java for the former and Python for the latter. Using Java unit testing coding standards for SDK testing requires testers to spend time and effort learning them, increasing the risk of test defects.

[0004] If SDK testing uses interface testing, it is necessary to encapsulate the interfaces of numerous SDKs one by one. Traditional SDK interface encapsulation methods involve manually encapsulating each interface and its parameters. This can easily lead to missing interfaces or parameters, resulting in low efficiency and quality.

[0005] Therefore, the existing SDK testing technology still involves a lot of manual participation in the process of SDK testing, and the degree of automation is not high, which reduces the efficiency of SDK testing. Summary of the Invention

[0006] The main purpose of the present invention is to provide an SDK interface testing method, system and computer-readable storage medium, aiming to improve the efficiency of SDK interface testing and reduce labor costs.

[0007] To achieve the above object, the present invention provides an SDK interface testing method, which includes the following steps:

[0008] Receive the SDK source code address request sent by the front end;

[0009] Pull the specified SDK source code from the code library according to the SDK source code address request;

[0010] Convert the SDK source code to generate a corresponding SDK interface service project;

[0011] The SDK interface service project is uploaded to the code library, and the SDK interface service project is automatically deployed and tested.

[0012] Optionally, the step of converting the SDK source code to generate a corresponding SDK interface service project includes:

[0013] Parsing the SDK source code to obtain description information of the SDK source code;

[0014] Generate an SDK interface service project based on the description information.

[0015] Optionally, the step of parsing the SDK source code to obtain description information of the SDK source code includes:

[0016] Use a source code parsing tool to parse the SDK source code and parse a class file into an abstract syntax tree;

[0017] The abstract syntax tree is traversed and searched, and corresponding callback methods are called according to the node types encountered to obtain various description information that meets the requirements, and the various description information is stored using a preset data structure.

[0018] Optionally, the step of generating an SDK interface service project based on the description information includes:

[0019] Building a data model based on the description information;

[0020] Write and generate various template files required for the SDK interface service project;

[0021] The data model and template file are merged using a template engine to generate the SDK interface service project into a local SDK interface service project source code repository.

[0022] Optionally, the step of constructing a data model based on the description information includes:

[0023] Construct and automatically generate class name information of various class files in the SDK interface service project;

[0024] Build a hash table;

[0025] Based on the hash table, the description information and class name information are stored to obtain the data model.

[0026] Optionally, the step of writing and generating various template files required for the SDK interface service project includes:

[0027] Write and generate various .java, .xml, and .properties files required by the SDK interface service project as template files.

[0028] Optionally, the description information includes package information, class or interface information, and method information of the SDK source code.

[0029] In addition, an embodiment of the present invention further provides an SDK interface testing system, including a front end and a back end, wherein:

[0030] The front end includes a front end operation module, which is used to provide the user with an operation interface and a visual page for interface management, and send various operation requests to the back end according to the user's operation instructions. The operation request includes at least: SDK source code address request;

[0031] The backend includes:

[0032] The source code parsing and SDK interface service project generation module is used to receive various operation requests sent by the front end; request to pull the specified SDK source code from the code library according to the SDK source code address in the operation request; and convert the SDK source code to generate the corresponding SDK interface service project;

[0033] The automated deployment and testing module is used to upload the SDK interface service project to the code library and automatically deploy and test the SDK interface service project.

[0034] In addition, an embodiment of the present invention also proposes an SDK interface testing system, which includes: a memory, a processor, and an SDK interface testing program stored on the memory and runnable on the processor. When the SDK interface testing program is executed by the processor, the steps of the SDK interface testing method described above are implemented.

[0035] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which an SDK interface test program is stored. When the SDK interface test program is executed by a processor, the steps of the SDK interface test method described above are implemented.

[0036] The SDK interface testing method, system and computer-readable storage medium proposed in the embodiment of the present invention receive an SDK source code address request sent by the front end; pull the specified SDK source code from the code library according to the SDK source code address request; convert the SDK source code to generate a corresponding SDK interface service project; upload the SDK interface service project to the code library, and automatically deploy and test the SDK interface service project. In this solution, the SDK unit test is converted into an interface test. For testers who are not familiar with the SDK unit test coding specifications or the programming language used is a programming language that the tester is not familiar with, the solution of the present invention can greatly reduce the learning cost of the tester and the risk of test defects; and in the SDK interface packaging stage, the SDK source code is converted to generate the corresponding SDK interface service project. For example, the SDK source code can be parsed first to obtain the required description information, and then the SDK interface service project can be automatically generated by using the template engine by building a data model and writing a template file; finally, the SDK interface service project is automatically uploaded to the code library and automatically deployed and tested. Compared with the traditional manual packaging of SDK interfaces, which is prone to the problem of missing an interface or a parameter, the present invention packages the SDK interface in an automated manner, thereby improving the SDK packaging efficiency and quality, and improving the SDK interface testing efficiency; in the entire process of converting SDK unit testing to interface testing, including a series of operations such as SDK source code acquisition, SDK interface packaging, SDK interface service project deployment, and SDK interface testing, these operations are performed in an automated service manner, reducing manual workload and further improving SDK testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 This is a schematic diagram of the functional modules of a terminal device to which the SDK interface testing device according to an embodiment of the present invention belongs;

[0038] Figure 2 This is a flow chart of the first embodiment of the SDK interface testing method of the present invention;

[0039] Figure 3 Schematic diagram of the interaction principle between the front-end and the back-end in an embodiment of the present invention;

[0040] Figure 4 This is a detailed flowchart of an embodiment of the SDK interface testing method of the present invention;

[0041] Figure 5 This is a schematic diagram of the architecture of the SDK interface testing system involved in an embodiment of the present invention.

[0042] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0043] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0044] The main solution of the embodiment of the present invention is: based on the front-end sending the SDK source code address request, the SDK source code is automatically pulled from the code library to the local source code warehouse; the specified SDK source code is parsed to obtain various description information such as packages, classes, methods, etc.; a data model is constructed, a template file is written, and the SDK interface service project is automatically generated by the template engine; the SDK interface service project is automatically uploaded to the code library and automatically deployed; the SDK interface service project is tested in combination with the existing interface automation testing solution. In this solution, the SDK unit test is converted into an interface test. For testers who are not familiar with the SDK unit test coding specification or the programming language used is a programming language that the tester is not familiar with, the solution of the present invention can greatly reduce the learning cost of the tester and the risk of test defects; and in the SDK interface packaging stage, the SDK source code is converted to generate the corresponding SDK interface service project. For example, the SDK source code can be parsed first to obtain the required description information, and then the SDK interface service project can be automatically generated by constructing a data model and writing a template file using the template engine; finally, the SDK interface service project is automatically uploaded to the code library and automatically deployed and tested. Compared with the traditional manual packaging of SDK interfaces, which is prone to the problem of missing an interface or a parameter, the present invention packages the SDK interface in an automated manner, thereby improving the efficiency and quality of SDK packaging; in the entire process of converting SDK unit testing to interface testing, including a series of operations such as SDK source code acquisition, SDK interface packaging, SDK interface service project deployment, and SDK interface testing, these operations are performed in an automated service manner, reducing manual workload and further improving SDK testing efficiency.

[0045] Technical terms involved in the embodiments of the present invention:

[0046] SDK, or Software Development Kit, is a collection of development tools used by software engineers to build application software for a specific software package, software framework, hardware platform, operating system, etc. It can simply provide a set of files that provide an application program interface for a programming language, but it can also include complex hardware that communicates with an embedded system.

[0047] The embodiments of the present invention take into account that conventional SDK testing methods are mostly performed through unit testing, and usually, the programming languages ​​used by developers' cloud development frameworks and testers' automated testing frameworks are different, which results in testers needing to spend time and energy learning when testing the SDK, and also increases the risk of test defects. If the SDK adopts an interface testing method, it is necessary to encapsulate the interfaces of numerous SDKs one by one. The traditional SDK interface encapsulation method is to manually encapsulate each interface and the parameters it contains. It is easy to miss an interface or a parameter, which is inefficient and of low quality. That is, the existing SDK testing technology still involves a lot of manual participation, and the degree of automated execution is not high, which reduces the efficiency of SDK testing.

[0048] Based on this, an embodiment of the present invention provides a solution that can improve SDK interface testing efficiency and reduce labor costs.

[0049] Specifically, refer to Figure 1 , Figure 1 This is a schematic diagram of the functional modules of a terminal device to which the SDK interface testing device of the present invention belongs. The SDK interface testing device can be a device independent of the terminal device, and can be hosted on the terminal device or system in the form of hardware or software. The terminal device can be a smart mobile terminal such as a mobile phone or tablet computer, or a network device such as a server.

[0050] In this embodiment, the terminal device to which the SDK interface testing apparatus belongs includes at least an output module 110 , a processor 120 , a memory 130 and a communication module 140 .

[0051] The memory 130 stores an operating system and an SDK interface test program. The output module 110 may be a display screen, a speaker, etc. The communication module 140 may include a WIFI module, a mobile communication module, and a Bluetooth module, etc., and communicates with an external device or server through the communication module 140.

[0052] As an embodiment, the SDK interface test program in the memory 130 implements the following steps when executed by the processor:

[0053] Receive the SDK source code address request sent by the front end;

[0054] Pull the specified SDK source code from the code library according to the SDK source code address request;

[0055] Convert the SDK source code to generate a corresponding SDK interface service project;

[0056] The SDK interface service project is uploaded to the code library, and the SDK interface service project is automatically deployed and tested.

[0057] Furthermore, when the SDK interface test program in the memory 130 is executed by the processor, the following steps are also implemented:

[0058] Parsing the SDK source code to obtain description information of the SDK source code;

[0059] Generate an SDK interface service project based on the description information.

[0060] Furthermore, when the SDK interface test program in the memory 130 is executed by the processor, the following steps are also implemented:

[0061] Use a source code parsing tool to parse the SDK source code and parse a class file into an abstract syntax tree;

[0062] The abstract syntax tree is traversed and searched, and corresponding callback methods are called according to the node types encountered to obtain various description information that meets the requirements, and the various description information is stored using a preset data structure.

[0063] Furthermore, when the SDK interface test program in the memory 130 is executed by the processor, the following steps are also implemented:

[0064] Building a data model based on the description information;

[0065] Write and generate various template files required for the SDK interface service project;

[0066] The data model and template file are merged using a template engine to generate the SDK interface service project into a local SDK interface service project source code repository.

[0067] Furthermore, when the SDK interface test program in the memory 130 is executed by the processor, the following steps are also implemented:

[0068] Construct and automatically generate class name information of various class files in the SDK interface service project;

[0069] Build a hash table;

[0070] Based on the hash table, the description information and class name information are stored to obtain the data model.

[0071] Furthermore, when the SDK interface test program in the memory 130 is executed by the processor, the following steps are also implemented:

[0072] Write and generate various .java, .xml, and .properties files required by the SDK interface service project as template files.

[0073] This embodiment receives the SDK source code address request sent by the front end through the above scheme; pulls the specified SDK source code from the code library according to the SDK source code address request; converts the SDK source code to generate the corresponding SDK interface service project; uploads the SDK interface service project to the code library, and automatically deploys and tests the SDK interface service project. In this scheme, the SDK unit test is converted into an interface test. For testers who are not familiar with the SDK unit test coding specifications or the programming language used is a programming language that the tester is not familiar with, the scheme of the present invention can greatly reduce the learning cost of the tester and the risk of test defects; and in the SDK interface packaging stage, the SDK source code is converted to generate the corresponding SDK interface service project. For example, the SDK source code can be parsed first to obtain the required description information, and then the SDK interface service project can be automatically generated by using the template engine by building a data model and writing a template file; finally, the SDK interface service project is automatically uploaded to the code library and automatically deployed and tested. Compared with the traditional manual packaging of SDK interfaces, which is prone to the problem of missing an interface or a parameter, the present invention packages the SDK interface in an automated manner, thereby improving the efficiency and quality of SDK packaging. In the entire process of converting SDK unit testing to interface testing, including a series of operations such as SDK source code acquisition, SDK interface packaging, SDK interface service project deployment, and SDK interface testing, these operations are performed in an automated service manner, reducing manual workload and further improving SDK testing efficiency.

[0074] Based on the above terminal device architecture but not limited to the above architecture, an embodiment of the method of the present invention is proposed.

[0075] Reference Figure 2 , Figure 2 This is a flow chart of the first embodiment of the SDK interface testing method of the present invention.

[0076] like Figure 2 As shown, an SDK interface testing method proposed in an embodiment of the present invention includes the following steps:

[0077] Step S101: receiving an SDK source code address request sent by the front end;

[0078] The embodiment of the present invention mainly implements SDK interface testing. Based on the front-end sending an SDK source code address request, the SDK source code is automatically pulled from the code library to the local source code warehouse; the specified SDK source code is parsed to obtain various description information such as packages, classes, methods, etc.; a data model is constructed, a template file is written, and an SDK interface service project is automatically generated using a template engine; the SDK interface service project is automatically uploaded to the code library and automatically deployed; and the SDK interface service project is tested in combination with relevant interface automation testing solutions.

[0079] Among them, the front end is used to provide users with an operation interface and a visual page for interface management; Figure 3 The front-end and back-end interaction diagram is shown: Enter the SDK source code address on the homepage and submit it to the backend. This page will display the SDK project directory structure, method names contained in the source files, and the source code of the class files. Select the method to be tested, save it, and submit it to the backend. The Swagger interface documentation page will display the interface information of the generated SDK interface service project. Furthermore, you can return to the SDK project page from the Swagger interface documentation page to select and submit methods to be tested multiple times.

[0080] Step S102: Pull the specified SDK source code from the code library according to the SDK source code address request;

[0081] Among them, based on the SDK source code address request sent by the front end, the specified SDK source code is automatically pulled from the code library to the local source code warehouse.

[0082] Specifically, as an implementation method, you can use the version control system access tool to call its corresponding interface to automatically pull the SDK source code from the code library to the local source code repository, such as the JGit tool, including clone, add, commit, pull, push and other automated operations.

[0083] Step S103, converting the SDK source code to generate a corresponding SDK interface service project;

[0084] Specifically, as an implementation method, the SDK source code is parsed to obtain description information of the SDK source code; and an SDK interface service project is generated based on the description information.

[0085] The step of parsing the SDK source code to obtain description information of the SDK source code may include:

[0086] Use a source code parsing tool to parse the SDK source code and parse a class file into an abstract syntax tree; traverse and search the abstract syntax tree, call the corresponding callback method according to the node type encountered, obtain various descriptive information that meets the requirements, and use a preset data structure to store the various descriptive information.

[0087] More specifically, the specified SDK source code is parsed to obtain various descriptive information such as packages, classes, and methods. For example, the source code parsing tool JavaParser can be used to parse a class file into an abstract syntax tree, and then traverse and search the syntax tree. According to the node type encountered, a specific callback method is called to obtain various descriptive information of interest, and the various descriptive information is stored using a suitable data structure.

[0088] The various description information includes SDK source code package information, class or interface information, and method information, specifically:

[0089] Package information includes: the package name of the class file itself and the package names of the imported packages it contains;

[0090] Class or interface information includes: class name and fully qualified name of class file, interface name and fully qualified name of interface file;

[0091] Method information includes: method access modifier, return value type, method name, method signature, and parameter list.

[0092] The step of generating an SDK interface service project based on the description information may include:

[0093] First, a data model is constructed based on the description information;

[0094] Specifically, construct and automatically generate class name information of various class files in the SDK interface service project;

[0095] Constructing a hash table; based on the hash table, storing the description information and class name information to obtain the data model.

[0096] Then, write and generate various template files required for the SDK interface service project;

[0097] As an implementation method, various .java, .xml, and .properties files required for generating the SDK interface service project are written as template files.

[0098] Finally, the data model and template file are merged using a template engine to generate the SDK interface service project into a local SDK interface service project source code repository.

[0099] In this embodiment, the template engine can use Freemarker. Taking this as an example, the construction of the data model and the writing process of the template file in the process of automatically generating the SDK interface service project are described in detail:

[0100] Construction of the data model: On the one hand, it needs to include various descriptive information stored in the above steps; on the other hand, it constructs the class name information of various class files in the SDK interface service project that are automatically generated, such as the class files of the controller / service layer. Given that the class names of these class files are dynamically generated, you can consider using the "class name of the class file of the SDK source code + Controller / Service.java" method to name the dynamically changing class names; finally, a hash table is constructed to store the data constructed in these two aspects to obtain the data model, which facilitates the subsequent template engine to load the data source from the constructed data model.

[0101] Preparation of template files: The template files are used to generate various .java, .xml, and .properties files required in the SDK interface service project. The prepared template files are as follows:

[0102] controller.ftl: Write controller.ftl according to the coding style of the controller layer of the Spring Boot project. It is used to dynamically generate Java files for the controller layer of the SDK interface service project. These generated Java files are named "SDK source code class file class name + Controller.java";

[0103] service.ftl: Write service.ftl according to the coding style of the service layer of the Spring Boot project. It is used to dynamically generate Java files for the service layer of the SDK interface service project. These generated Java files are named "SDK source code class file class name + Service.java";

[0104] pom.ftl: Write pom.ftl according to the code style of pom.xml. It is used to dynamically generate the pom.xml file of the SDK interface service project. It contains the basic information of the SDK interface service project and various required dependency information. The dependency information can be divided into general dependency information and SDK source code dependency information.

[0105] StartApplication.ftl: Write StartApplication.ftl according to the startup class file coding style of the Spring Boot project, which is used to dynamically generate the StartApplication.java startup class file of the SDK interface service project;

[0106] UniqueBeanNameGenerator.ftl: Dynamically generates the UniqueBeanNameGenerator.java file for the SDK interface service project according to the Java file coding style of the Spring Boot project, resolving bean conflicts in the generated SDK interface service project.

[0107] application.ftl: used to dynamically generate the application.properties file of the SDK interface service project, which contains various configuration information;

[0108] swagger.ftl: Used to dynamically generate the Swagger.java file for the SDK interface service project. By scanning the java files under the controller package under the SDK interface service project, you can add interface document management functions to it.

[0109] Furthermore, the writing of the controller.ftl template file also includes:

[0110] Usage of annotations @GetMapping and @PostMapping: traverse each method stored in the data model. When all parameter types in the parameter list are primitive types, add @GetMapping before the method and add @RequestParam before each parameter in the method parameter list. When the parameter type in the parameter list contains entity class types, add @PostMapping before the method, locate the entity class parameter in the method parameter list, and add @RequestBody.

[0111] Ensure the uniqueness of the request path mapped to the method: When there are multiple methods in the data model, use the fully qualified name of the method, that is, package name + class name + method name + index. The advantage of this is that even if multiple overloaded methods are stored in the data model, the uniqueness of the request path mapped to each method can still be guaranteed.

[0112] Furthermore, the writing of the service.ftl template file also includes:

[0113] Handling private methods in the SDK source code: Traverse the methods stored in the data model. When the method access modifier is "private", write code in the service.ftl template file to use the reflection mechanism to create an object and call its properties.

[0114] Furthermore, the writing of the pom.ftl template file also includes:

[0115] Add the dependency information from the pom.xml file in the SDK source code to the pom.xml file of the dynamically generated SDK interface service project: Use an XML parsing tool, such as dom4j, to traverse the pom.xml file in the SDK source code and extract the required key dependency information. Then, traverse all node information in the pom.xml file of the generated SDK interface service project and compare the extracted key dependency information. If they are different, add them to the pom.xml file of the generated SDK interface service project; otherwise, do not add them. This is to prevent running the same SDK source code program multiple times, which would result in duplicate dependency information being added to the pom.xml file of the SDK interface service project.

[0116] Step S104: Upload the SDK interface service project to the code library, and automatically deploy and test the SDK interface service project.

[0117] The SDK interface service project is automatically uploaded to the code library and automatically deployed, and the SDK interface service project is tested in combination with the relevant interface automation test solution. The interface automation test solution is not limited in this embodiment.

[0118] The specific process of implementing SDK interface testing in this embodiment can be referred to Figure 4 shown.

[0119] Compared with the existing technology, the embodiment of the present invention automatically pulls the SDK source code from the code library to the local source code warehouse based on the front-end sending the SDK source code address request; parses the specified SDK source code to obtain various description information such as packages, classes, methods, etc.; builds a data model, writes a template file, and uses the template engine to automatically generate the SDK interface service project; automatically uploads the SDK interface service project to the code library and automatically deploys it; and tests the SDK interface service project in combination with the existing interface automation testing solution. The solution of the present invention solves the problem of spending time and energy to learn SDK unit testing and the problem of manually encapsulating the interfaces of numerous SDKs one by one when using SDK interface testing. By converting SDK unit testing into automatic service-oriented SDK interface testing, the learning cost is reduced, the manual workload is reduced, and the testing efficiency is improved.

[0120] In addition, an embodiment of the present invention further provides an SDK interface testing system, including a front end and a back end, wherein:

[0121] The front end includes a front end operation module, which is used to provide the user with an operation interface and a visual page for interface management, and send various operation requests to the back end according to the user's operation instructions. The operation request includes at least: SDK source code address request;

[0122] The backend includes:

[0123] The source code parsing and SDK interface service project generation module is used to receive various operation requests sent by the front end; request to pull the specified SDK source code from the code library according to the SDK source code address in the operation request; and convert the SDK source code to generate the corresponding SDK interface service project;

[0124] The automated deployment and testing module is used to upload the SDK interface service project to the code library and automatically deploy and test the SDK interface service project.

[0125] The principle of implementing SDK interface testing in this embodiment can be referred to the above embodiments and will not be described in detail here. Among them, the various functional modules involved in the front-end and back-end can be increased, decreased or recombined according to actual conditions.

[0126] The following combination Figure 5 , the principle of the SDK interface testing system of the present invention is illustrated by examples.

[0127] like Figure 5 As shown, the SDK interface test system proposed in the present invention includes:

[0128] Front-end operation module, used to provide users with a friendly operation interface and a visual page for interface management; Figure 3 The front-end and back-end interaction diagram is shown: Enter the SDK source code address on the homepage and submit it to the backend. This page will display the SDK project directory structure, method names contained in the source files, and the source code of the class files. Select the method to be tested, save it, and submit it to the backend. The Swagger interface documentation page will display the interface information of the generated SDK interface service project. Furthermore, you can return to the SDK project display page from the Swagger interface documentation page to select and submit methods to be tested multiple times.

[0129] The automated execution module is used to transfer source code between the code base and the local warehouse. The source code is divided into SDK source code and its corresponding SDK interface service project source code. Based on the version control system access tool, it realizes automated operations such as obtaining SDK source code and uploading SDK interface service projects;

[0130] The source code parsing module is used to parse the SDK source code pulled from the code library to the local warehouse. Based on the source code parsing tool, it obtains various descriptive information of interest and stores this descriptive information using appropriate data structures.

[0131] SDK interface service project generation module, used to build the data model of the SDK interface service project, write various template files required by the SDK interface service project, and automatically convert the SDK source code to generate the corresponding SDK interface service project;

[0132] The automated deployment and testing module is used to automatically upload the generated SDK interface service project to the code library for automated construction and deployment, and then perform automated testing on the SDK interface service project in combination with the existing interface automation testing solution.

[0133] Furthermore, the automation execution module includes:

[0134] The permission management unit is used to verify permissions when performing operations such as clone, commit, pull, and push;

[0135] The SDK source code acquisition unit is used to create a local SDK source code repository. According to the SDK source code address delivered by the front end, if the SDK source code project corresponding to the SDK source code address does not exist in the local SDK source code repository, the SDK source code project is cloned; if it exists, the SDK source code project is pulled;

[0136] The SDK interface service project upload unit is used to commit and push the SDK interface service project generated in the local SDK interface service project source code repository to the code library.

[0137] Furthermore, the source code parsing module includes:

[0138] A parsing unit is used to parse the SDK source code. Based on the source code parsing tool JavaParser, the class file is parsed into an abstract syntax tree, and then the syntax tree is traversed and searched. A specific callback method is called according to the node type encountered, and finally various description information of interest is obtained;

[0139] The storage unit is used to store the parsed descriptive information and its corresponding relationships using appropriate data structures. The corresponding relationship means that a class file may contain multiple methods, a method may contain multiple parameters, and the method's access modifier, return value type, method name, method signature, and parameter list must match.

[0140] Furthermore, the SDK interface service project generation module includes:

[0141] A data model construction unit is used to provide a data source to the SDK interface service project when it is generated, construct a hash table, store the various descriptive information stored above and the file names of new files automatically generated in the SDK interface service project, and obtain the data model;

[0142] The template file writing unit is used to provide the SDK interface service project with various required files when generating it, and write the template files required to generate these files according to the code style of these files;

[0143] Generate an SDK interface service engineering unit, which is used to automatically convert the SDK source code to generate the corresponding SDK interface service engineering into the local SDK interface service engineering source code repository, merge the data model and the template file using the template engine, and output the content into the SDK interface service engineering file;

[0144] Furthermore, the SDK interface service engineering automated deployment and testing module includes:

[0145] An automated deployment unit, configured to call the SDK interface service project upload unit, automatically upload the SDK interface service project to the code repository, and automatically build and deploy the SDK interface service project based on the continuous integration tool Jenkins;

[0146] The automated testing unit is used to call the relevant interface automated testing solution to perform automated testing on the SDK interface service project.

[0147] Compared with the existing technology, the SDK unit testing method requires testers to spend time and energy to learn SDK unit test coding. The embodiment of the present invention converts SDK unit testing into interface testing. For testers who are not familiar with SDK unit test coding specifications or the programming language used is a programming language that the testers are not familiar with, the present invention will greatly reduce the learning cost of testers and the risk of test defects. In addition, traditional SDK interface testing uses manual interface packaging and then tests the packaged interface, which has the problems of low packaging efficiency and low quality. To solve this problem, the present invention automatically packages each SDK interface in an automated manner, thereby improving the SDK interface packaging efficiency and quality. Specifically, in the SDK interface packaging stage, the SDK source code is first packaged. parse to obtain the required description information; then, by constructing a data model and writing a template file, the template engine is used to automatically generate an SDK interface service project; finally, the SDK interface service project is automatically uploaded to the code library and automatically deployed. Compared with the traditional manual packaging of SDK interfaces, it is easy to miss a certain interface or a certain parameter. The present invention provides an automated method for packaging SDK interfaces, which improves the SDK packaging efficiency and quality; furthermore, in order to solve the problem of SDK testing efficiency, the present invention's solution includes a series of operations such as SDK source code acquisition, SDK interface packaging, SDK interface service project deployment, and SDK interface testing during the entire process of converting SDK unit testing to interface testing. These operations are performed in an automated service manner, reducing manual workload and further improving SDK testing efficiency.

[0148] In addition, an embodiment of the present invention also proposes an SDK interface testing system, which includes: a memory, a processor, and an SDK interface testing program stored on the memory and runnable on the processor. When the SDK interface testing program is executed by the processor, the steps of the SDK interface testing method described in the above embodiment are implemented.

[0149] The principle of implementing SDK interface testing in the present invention can be referred to the above embodiments and will not be described in detail here.

[0150] In addition, an embodiment of the present invention further proposes a computer-readable storage medium, on which an SDK interface test program is stored. When the SDK interface test program is executed by a processor, the steps of the SDK interface test method described in the above embodiment are implemented.

[0151] The principle of implementing SDK interface testing in the present invention can be referred to the above embodiments and will not be described in detail here.

[0152] The SDK interface testing method, system and computer-readable storage medium proposed in the embodiment of the present invention receive an SDK source code address request sent by the front end; pull the specified SDK source code from the code library according to the SDK source code address request; convert the SDK source code to generate a corresponding SDK interface service project; upload the SDK interface service project to the code library, and automatically deploy and test the SDK interface service project. In this solution, the SDK unit test is converted into an interface test. For testers who are not familiar with the SDK unit test coding specifications or the programming language used is a programming language that the tester is not familiar with, the solution of the present invention can greatly reduce the learning cost of the tester and the risk of test defects; and in the SDK interface packaging stage, the SDK source code is converted to generate the corresponding SDK interface service project. For example, the SDK source code can be parsed first to obtain the required description information, and then the SDK interface service project can be automatically generated by using the template engine by building a data model and writing a template file; finally, the SDK interface service project is automatically uploaded to the code library and automatically deployed and tested. Compared with the traditional manual packaging of SDK interfaces, which is prone to the problem of missing an interface or a parameter, the present invention packages the SDK interface in an automated manner, thereby improving the efficiency and quality of SDK packaging. In the entire process of converting SDK unit testing to interface testing, including a series of operations such as SDK source code acquisition, SDK interface packaging, SDK interface service project deployment, and SDK interface testing, these operations are performed in an automated service manner, reducing manual workload and further improving SDK testing efficiency.

[0153] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.

[0154] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0155] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium as above (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a recommendation effect evaluation system (which can be a mobile phone, computer, server, controlled terminal, or network device, etc.) to execute the method of each embodiment of the present invention.

[0156] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A SDK interface testing method, characterized in that: The method comprises the following steps: Receive the SDK source code address request sent by the front end; Pull the specified SDK source code from the code library according to the SDK source code address request; Convert the SDK source code to generate a corresponding SDK interface service project; Uploading the SDK interface service project to the code library, and automatically deploying and testing the SDK interface service project; The step of converting the SDK source code to generate a corresponding SDK interface service project includes: Parsing the SDK source code to obtain description information of the SDK source code, wherein the description information includes package information, class or interface information, and method information of the SDK source code; Generate an SDK interface service project based on the description information, wherein the SDK interface service project includes a controller layer and a service layer; The step of generating an SDK interface service project based on the description information includes: Construct and automatically generate class name information of various class files in the SDK interface service project; Build a hash table; Based on the hash table, the description information and class name information are stored to obtain a data model; Write and generate various template files required for the SDK interface service project. The template files include at least controller.ftl and service.ftl generated for the class files of the SDK source code. The controller.ftl is a Java file used to dynamically generate the controller layer of the SDK interface service project, and the service.ftl is a Java file used to dynamically generate the service layer of the SDK interface service project. The data model and template file are merged using a template engine to generate the SDK interface service project into a local SDK interface service project source code repository.

2. The SDK interface testing method according to claim 1, wherein: The step of parsing the SDK source code to obtain description information of the SDK source code includes: Use a source code parsing tool to parse the SDK source code and parse a class file into an abstract syntax tree; The abstract syntax tree is traversed and searched, and corresponding callback methods are called according to the node types encountered to obtain various description information that meets the requirements, and the various description information is stored using a preset data structure.

3. The SDK interface testing method according to claim 1, wherein: The steps of writing and generating various template files required for the SDK interface service project include: Write and generate various .xml and .properties files required by the SDK interface service project as template files.

4. An SDK interface testing system, characterized in that: Including front-end and back-end, including: The front end includes a front end operation module, which is used to provide the user with an operation interface and a visual page for interface management, and send various operation requests to the back end according to the user's operation instructions. The operation request includes at least: SDK source code address request; The backend includes: The source code parsing and SDK interface service project generation module is used to receive various operation requests sent by the front end; request to pull the specified SDK source code from the code library according to the SDK source code address in the operation request; and convert the SDK source code to generate the corresponding SDK interface service project; The source code parsing and SDK interface service project generation module is further used to parse the SDK source code to obtain description information of the SDK source code, the description information including package information, class or interface information, and method information of the SDK source code; and generate an SDK interface service project based on the description information, the SDK interface service project including a controller layer and a service layer; The step of generating an SDK interface service project based on the description information includes: Constructing class name information for automatically generating various class files in the SDK interface service project; building a hash table; storing the description information and class name information based on the hash table to obtain a data model; compiling and generating various template files required for the SDK interface service project, wherein the template files at least include controller.ftl and service.ftl generated for the class files of the SDK source code, wherein the controller.ftl is a java file for dynamically generating the controller layer of the SDK interface service project, and the service.ftl is a java file for dynamically generating the service layer of the SDK interface service project; utilizing a template engine to merge the data model and template files, and generating the SDK interface service project into a local SDK interface service project source code repository; The automated deployment and testing module is used to upload the SDK interface service project to the code library and automatically deploy and test the SDK interface service project.

5. An SDK interface testing system, characterized in that: The SDK interface testing system includes: a memory, a processor, and an SDK interface testing program stored in the memory and executable on the processor. When the SDK interface testing program is executed by the processor, the steps of the SDK interface testing method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores an SDK interface test program, which, when executed by a processor, implements the steps of the SDK interface test method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • SDK generation method, device and equipment and readable storage medium

    CN112380145A