CN117033208A - Interface contract checking method and device, electronic equipment and storage medium - Google Patents

Interface contract checking method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117033208A
CN117033208A CN202310997538.3A CN202310997538A CN117033208A CN 117033208 A CN117033208 A CN 117033208A CN 202310997538 A CN202310997538 A CN 202310997538A CN 117033208 A CN117033208 A CN 117033208A
Authority
CN
China
Prior art keywords
interface
contract
list
file
developer platform
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310997538.3A
Other languages
Chinese (zh)
Inventor
白雪枫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202310997538.3A priority Critical patent/CN117033208A/en
Publication of CN117033208A publication Critical patent/CN117033208A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application discloses an interface contract checking method, an interface contract checking device, electronic equipment and a storage medium, wherein the method comprises the following steps: adding the file to be checked to the first list; extracting the value of the target annotation from the first list, and saving the value as an interface path into a second list; comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract; executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform; acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with an interface contract in the developer platform; if the interface contract is inconsistent, contract updating processing is carried out on the second interface, whether the interface contract exists on the developer platform or not can be checked, and the accuracy of the interface contract can be checked and maintained.

Description

Interface contract checking method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of interface testing technologies, and in particular, to a method and apparatus for checking interface contracts, an electronic device, and a storage medium.
Background
In software development, in order to ensure performance such as stability of developed software, it is often necessary to test the developed software. Wherein the correctness and stability of the system are ensured by the interface test, and the accuracy of the interface contract management tool is important.
At present, a plurality of companies maintain interface contracts through a developer platform, but the interface contract update iteration is fast, the off-line update is lagged, omission and mistakes are easy to occur, and the product quality is affected; and the interface contract styles are inconsistent, so that the communication cost between the test and the development is increased, and the test efficiency is lower.
Disclosure of Invention
The embodiment of the application provides an interface contract checking method, an interface contract checking device, electronic equipment and a storage medium, which can check whether an interface contract exists on a developer platform and check and maintain the accuracy of the interface contract.
In a first aspect, an embodiment of the present application provides a method for checking an interface contract, where the method includes:
adding the file to be checked to the first list;
extracting a value of a target annotation from the first list, and saving the value as an interface path into a second list;
comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract;
executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform;
acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with interface contract in the developer platform;
and if the contract update processing is inconsistent, performing contract update processing on the second interface.
In an alternative embodiment, the performing contract maintenance processing on the first interface includes:
updating the interface path of the first interface in the second list to the developer platform;
and acquiring an inlet parameter class variable of the first interface specified by the file as an inlet parameter of the first interface, and acquiring an outlet parameter class variable of the first interface specified by the file as an outlet parameter of the first interface.
In an optional implementation manner, the performing contract update processing on the second interface includes:
updating the inlet parameters of the second interface by using the inlet parameter class variables of the second interface specified by the file, and updating the outlet parameters of the second interface by using the outlet parameter class variables of the second interface specified by the file.
In an optional implementation manner, the comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface has an interface contract includes:
if the interface path of the first interface in the developer platform is inconsistent with the interface path in the second list, confirming that the first interface does not maintain an interface contract;
and if the interface path of the second interface in the developer platform is consistent with the interface path in the second list, confirming that the second interface has an interface contract.
In an alternative embodiment, before said adding the file to be checked to the first list, the method further comprises:
extracting a source file from a code management repository;
searching a file with a preset type and target annotation in the source file as the file to be checked.
In an alternative embodiment, the extracting the value of the target annotation from the first list and saving the value as the interface path to the second list includes:
and circularly traversing the classes in the first list, extracting the values of target annotations in the classes, and storing the values as the interface paths in the second list.
In an alternative embodiment, the method further comprises:
and generating and outputting an interface contract state notification, wherein the interface contract state notification is used for prompting the first interface to generate contract maintenance processing or the second interface to generate contract updating processing.
In a second aspect, an embodiment of the present application provides an interface contract checking apparatus, including:
the acquisition module is used for adding the file to be checked to the first list;
the searching module is used for extracting the value of the target annotation from the first list and storing the value as an interface path into a second list;
the checking module is used for comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract;
the processing module is used for executing contract maintenance processing on a first interface, wherein the first interface is an interface without maintaining an interface contract in the developer platform;
the checking module is further configured to obtain an interface parameter of a second interface, and compare the parameter of the second interface in the developer platform with a parameter of the second interface specified by a file, where the second interface is an interface with an interface contract in the developer platform;
and the processing module is further used for performing contract updating processing on the second interface if the parameters of the second interface in the developer platform are inconsistent with the parameters of the second interface specified by the file.
Optionally, the processing module is specifically configured to:
updating the interface path of the first interface in the second list to the developer platform;
and acquiring an inlet parameter class variable of the first interface specified by the file as an inlet parameter of the first interface, and acquiring an outlet parameter class variable of the first interface specified by the file as an outlet parameter of the first interface.
Optionally, the processing module is specifically further configured to:
updating the inlet parameters of the second interface by using the inlet parameter class variables of the second interface specified by the file, and updating the outlet parameters of the second interface by using the outlet parameter class variables of the second interface specified by the file.
Optionally, the inspection module is specifically configured to:
if the interface path of the first interface in the developer platform is inconsistent with the interface path in the second list, confirming that the first interface does not maintain an interface contract;
and if the interface path of the second interface in the developer platform is consistent with the interface path in the second list, confirming that the second interface has an interface contract.
Optionally, the acquiring module is further configured to:
extracting a source file from a code management repository before said adding the file to be inspected to the first list;
searching a file with a preset type and target annotation in the source file as the file to be checked.
Optionally, the searching module is specifically configured to:
and circularly traversing the classes in the first list, extracting the values of target annotations in the classes, and storing the values as the interface paths in the second list.
Optionally, the interface contract checking device further includes a notification module, configured to generate and output an interface contract status notification, where the interface contract status notification is used to prompt the first interface to generate contract maintenance processing or the second interface to generate contract update processing.
In a third aspect, an embodiment of the present application further provides an electronic device, including a processor, an input device, an output device, and a memory, where the processor, the input device, the output device, and the memory are connected to each other, and where the memory is configured to store a computer program, where the computer program includes program instructions, and where the processor is configured to invoke the program instructions to perform a method according to the first aspect and any possible implementation manner thereof.
In a fourth aspect, embodiments of the present application provide a computer storage medium storing a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of the first aspect and any one of its possible embodiments.
The embodiment of the application adds the file to be checked to the first list; extracting a value of a target annotation from the first list, and saving the value as an interface path into a second list; comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract; executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform; acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with interface contract in the developer platform; if the contract update processing is inconsistent, contract update processing is carried out on the second interface; whether the interface contract exists on the developer platform or not can be checked, the interfaces without the interface contract can be maintained, the accuracy of the interface contract can be checked, the interface contract can be updated and maintained in time, the production bug is reduced, and the test efficiency is improved.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described.
Fig. 1 is a flow chart of an interface contract checking method according to an embodiment of the present application;
fig. 2 is a schematic flow chart of checking interface contract completion rate according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an interface contract checking device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms first, second and the like in the description and in the claims and in the above-described figures are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It is also to be understood that the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In order to better understand the embodiments of the present application, a method for applying the embodiments of the present application will be described below.
The interface test referred to in the embodiments of the present application is a test for testing interfaces between components of a system. Interface testing is mainly used for detecting interaction points between external systems and between internal subsystems. The key point of the test is to check the exchange of data, the transfer and control management process, and the mutual logic dependency between systems.
The contract tests involved in the embodiments of the present application are also referred to as consumer driven tests. Wherein the contract file is a specification commonly defined by a Consumer (Consumer) side and a producer (Provider) side, and comprises an interface path, input parameters (input parameters), output parameters (output parameters), and is generally generated by Consumer. The implementation principle is mainly that Consumer provides a "contract" like object (such as json file) to Provider, tells Provider what needs are, and then Provider implements according to the "contract". The interface contract can also be called an interface file, and accurate configuration is required to realize the correct function of the interface.
The terminal devices mentioned in the embodiments of the present application include, but are not limited to, desktop computers, mobile terminals, which may include various handheld devices with wireless communication capabilities, computing devices such as notebook computers, or other processing devices connected to wireless modems, and so forth.
Referring to fig. 1, a schematic flow chart of an interface contract checking method according to an embodiment of the application is shown in fig. 1, where the method may include:
101. the file to be checked is added to the first list.
The execution body in the embodiment of the application can be an interface contract checking device, and specifically, the execution body can be implemented by using electronic equipment, and the electronic equipment can be terminal equipment.
The above-mentioned file to be checked may be understood as a code for performing an interface test or an interface contract check. The first list may be pre-established, and the required files to be checked may be found and obtained and added to the first list.
In an alternative embodiment, before the step 101, the method further includes:
extracting a source file from a code management repository;
searching a file with a preset type and target annotation in the source file as the file to be checked.
The source file is a system code file, specifically, a source code can be extracted from a code management warehouse Gitlab, a file with a preset type and target annotation is searched, wherein the preset type can be identified according to a file type suffix, and the target annotation is an annotation corresponding to an interface and is used for searching the interface as a keyword. For example, find the entire item Controller folder, suffix is the file of ". Java", and there is an annotation @ ESA; the found file may then be added to the first list, e.g. here assumed to be file list a.
The ESA is generally called Enterprise Service Action, and supports Dubbo protocol and Restful (http protocol) calls, and the access parameters are weak type (map/json) service interfaces, which are not mandatory types.
102. And extracting the value of the target annotation from the first list, and saving the value as an interface path into a second list.
The values of the target annotations indicate the interface paths, and the values of the target annotations in the first list can be extracted entirely, i.e. the interface paths are stored in another list (the second list). Specifically, the classes in the first list may be traversed circularly, and the values of the target annotations in the classes may be extracted and stored as the interface paths in the second list. For example, loop through class in file list a while extracting the value of name of annotation @ ESA in the class and save it as an interface path to list B.
For example, the role of class and ESA service interface annotation includes traversing out interfaces from the key ESA, explained in detail below:
public class PutoutController- -class name
@ESA(name="${sar.name}.putout")
Name- -Server Domain name, putout- -interface Path
The method comprises the following steps: ( Wherein: simpleResponse returns out of the reference, loanApplyRequest goes into the reference )
public SimpleResponse putoutWriteWrapper(@Valid LoanApplyRequest request){};
After the above operation is completed, step 103 may be performed.
103. And comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract.
Specifically, the developer platform may be any developer platform, for example, the interface contract may be maintained by the Arena developer platform. Taking this as an example, in the Arena developer platform, the interface paths in the list B are searched, and compared with the interface paths in the Arena developer platform, it is possible to determine whether the interface has a contract.
In an alternative embodiment, the step 103 includes:
if the interface path of the first interface in the developer platform is inconsistent with the interface path in the second list, confirming that the first interface does not maintain an interface contract;
and if the interface path of the second interface in the developer platform is consistent with the interface path in the second list, confirming that the second interface has an interface contract.
The first interface and the second interface may be any interfaces in a developer platform, and only the description is convenient here. Specifically, in the developer platform, retrieving the interface paths in the second list, and if there are consistent paths, indicating that the interface has an interface contract; if not, it indicates that the interface does not have an interface contract.
For the interfaces not maintaining the interface contract, contract maintenance processing is needed, that is, a newly added interface contract may be executed in step 104;
for the interfaces of the existing interface contract, a further check may be performed, i.e. step 104 may not be performed, and step 105 may be performed.
104. And executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform.
The contract maintenance processing refers to setting an interface of an undetermined interface contract, and adding contract management, and mainly includes setting an interface path, an input parameter and an output parameter of the interface.
In an alternative embodiment, the step 104 includes:
updating the interface path of the first interface in the second list to the developer platform;
and acquiring an inlet parameter class variable corresponding to the first interface as an inlet parameter of the first interface, and acquiring an outlet parameter class variable corresponding to the first interface as an outlet parameter of the first interface.
Specifically, an undetermined interface is extracted, interface contract maintenance is completed, the name value of the class annotation @ ESA is updated to an Arena developer platform to serve as an interface path, a variable corresponding to a parameter is taken as an interface input parameter, a variable of the parameter is taken as an interface output parameter, and interface contract maintenance is completed.
105. And acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with an interface contract in the developer platform.
If the parameters of the second interface in the developer platform are consistent with the parameters of the second interface in the second list, it may be determined that the second interface has a complete and accurate interface contract, and step 106 may not be performed.
If the parameters of the second interface in the developer platform are inconsistent with the parameters of the second interface in the second list, indicating that the contract for the second interface needs to be updated, step 106 may be performed.
Specifically, the parameters are mainly the input parameters and the output parameters of the interface. If the second interface has a maintenance contract, the interface parameters specified by the file, namely the class variables of the method input parameters, can be continuously analyzed downwards, and are compared with the input parameters and the output parameters under the interface of the developer platform, if the second interface has consistency, the interface has complete and accurate interface contract; if not, the interface contract update processing is needed. The interface parameters specified in the above-mentioned files mainly refer to interface parameters specified in the source file or the file to be checked.
106. And performing contract updating processing on the second interface.
When the parameters of the second interface in the developer platform are inconsistent with the parameters corresponding to the second interface, contract updating processing is needed, namely, the actual parameters of the second interface in the developer platform are updated into parameters specified by the file.
In an alternative embodiment, the step 106 includes:
and updating the inlet parameters of the second interface by using the inlet parameter class variables of the second interface specified by the file, and updating the outlet parameters of the second interface by using the outlet parameter class variables of the second interface specified by the file.
Specifically, the inconsistent interface can be extracted, the parameter entering variable and the parameter exiting variable specified by the file are taken and updated to the developer platform, so that the interface contract of the second interface is updated to the required setting.
The naming rule of the interface contract provided by the embodiment of the application is as follows:
the value of the target annotation (the value of name of annotation @ ESA) acts as the interface path;
the class variable corresponding to the input parameter of the method is used as the input parameter of the interface to update to the developer platform;
and the corresponding class variable returned by the method is used as the output parameter of the interface to be updated to the developer platform.
Based on the above description, reference may be made to fig. 2, and fig. 2 is a schematic flow chart for checking the completion rate of interface contracts according to an embodiment of the present application. As shown in fig. 2, the GitLab is a code management repository, and the interface path, the in-parameters, and the out-parameters acquired from the code management repository check the complete rate flow of the developer platform interface contract is as follows:
1. firstly, extracting source codes from a code management warehouse Gitlab;
2. searching the whole item Controller folder, wherein the suffix is a file of 'java', and annotation @ ESA exists, and adding the file to a file list A;
3. circularly traversing class in the file list A, extracting the value of name of annotation @ ESA in the class, and storing the value as an interface path in the list B;
4. in the Arena developer platform, searching an interface path in the list B, comparing the interface path with the path of the interface in the Arena developer platform, and if the interface paths are consistent, indicating that the interface has an interface contract; if not, indicating that the interface does not maintain the interface contract;
5. extracting an undetermined interface, completing maintenance of an interface contract, updating the name value of a class annotation @ ESA to an Arena developer platform to serve as an interface path (path), taking in a variable corresponding to a parameter as an interface input parameter, taking out the variable of the parameter as an interface output parameter, completing maintenance of the interface contract, and notifying an interface responsible person of contract updating;
6. if the interface has a maintenance contract, continuously analyzing class variables of the input parameters of the method downwards, comparing the class variables with the input parameters and the output parameters of the Arena interface, and if the input parameters and the output parameters are consistent, indicating that the interface has a complete and accurate interface contract; if the interface contract is inconsistent, updating the interface contract is needed;
7. and extracting inconsistent interfaces, taking in parameter variables and parameter-out variables, updating the parameters to an Arena developer platform, and informing an interface responsible person.
In an alternative embodiment, the method further comprises:
and generating and outputting an interface contract state notification for prompting the first interface to generate contract maintenance processing or the second interface to generate contract update processing.
After the interface contract update process or the interface contract maintenance process is performed, a corresponding notification can be generated and notified to the interface responsible person so as to know the interface state in time.
At present, an Arena developer platform maintains an interface contract, and the following disadvantages are to be improved:
the interface contract update iteration is fast, the off-line update is delayed, the test is carried out to obtain an inaccurate interface contract, the test accuracy is affected, and the occurrence rate of bug production is greatly improved;
the contract style of the off-line updated interface is inconsistent, the interpretation of the input and output parameter fields of the interface is inaccurate, a unified design mode is not available, the communication cost between the test and the development is increased, and the test progress is affected;
off-line updating is easy to miss and make mistakes, communication cost between testing and development is increased, and project completion progress is affected.
According to the interface contract checking method, the system code file is scanned and analyzed, and the class file method is analyzed, so that whether an interface contract exists on a developer platform or not is checked, the accuracy of the interface contract is verified, the problems that quality, performance and the like are affected due to off-line updating, and the problem that bug occurs due to test omission caused by interface maintenance and updating lag can be reduced.
In the method for checking the interface contract, the on-line updating is timely, the test obtains the accurate interface contract, the production bug is reduced, in addition, the on-line updating is performed through the system, the input and output parameter fields of the interface are extracted, the format is unified, the manpower is released, the communication cost between test development is reduced, the test efficiency is improved, and the product quality is improved.
On the basis of the method embodiment, the embodiment of the application also provides an interface contract checking device.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an interface contract checking device according to an embodiment of the application. As shown in fig. 3, the interface contract checking apparatus 300 includes:
an obtaining module 310, configured to add a file to be checked to the first list;
a searching module 320, configured to extract a value of the target annotation from the first list, and store the value as an interface path in a second list;
a checking module 330, configured to compare the interface paths in the developer platform with the interface paths in the second list, and determine whether each interface in the developer platform has an interface contract;
a processing module 340, configured to perform contract maintenance processing on a first interface, where the first interface is an interface of the developer platform that does not maintain an interface contract;
the checking module 330 is further configured to obtain an interface parameter of a second interface, and compare the parameter of the second interface in the developer platform with a parameter of the second interface specified by a file, where the second interface is an interface having an interface contract in the developer platform;
the processing module 340 is further configured to perform contract update processing on the second interface if the parameter of the second interface in the developer platform does not match the parameter of the second interface specified by the file.
Optionally, the processing module 340 is specifically configured to:
updating the interface path of the first interface in the second list to the developer platform;
and acquiring an inlet parameter class variable of the first interface specified by the file as an inlet parameter of the first interface, and acquiring an outlet parameter class variable of the first interface specified by the file as an outlet parameter of the first interface.
Optionally, the processing module 340 is specifically further configured to:
and updating the inlet parameters of the second interface by using the inlet parameter class variables of the second interface specified by the file, and updating the outlet parameters of the second interface by using the outlet parameter class variables of the second interface specified by the file.
Optionally, the above-mentioned inspection module 330 is specifically configured to:
if the interface path of the first interface in the developer platform is inconsistent with the interface path in the second list, confirming that the first interface does not maintain an interface contract;
and if the interface path of the second interface in the developer platform is consistent with the interface path in the second list, confirming that the second interface has an interface contract.
Optionally, the acquiring module 310 is further configured to:
extracting a source file from a code management repository before adding the file to be inspected to the first list;
searching a file with a preset type and target annotation in the source file as the file to be checked.
Optionally, the above-mentioned searching module 320 is specifically configured to:
and circularly traversing the classes in the first list, extracting the values of target annotations in the classes, and storing the values as the interface paths in the second list.
Optionally, the interface contract checking device 300 further includes a notification module 350, configured to generate and output an interface contract status notification, where the interface contract status notification is configured to prompt the first interface to generate a contract maintenance process or the second interface to generate a contract update process.
According to the embodiment of the present application, the steps involved in the interface contract checking method shown in fig. 1 and fig. 2 may be executed by each module in the interface contract checking apparatus 300 shown in fig. 3, which is not described herein.
With the interface contract checking apparatus 300 of the embodiment of the present application, the interface contract checking apparatus 300 adds a file to be checked to the first list; extracting a value of a target annotation from the first list, and saving the value as an interface path into a second list; comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract; executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform; acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with interface contract in the developer platform; if the contract update processing is inconsistent, contract update processing is carried out on the second interface; whether the interface contract exists on the developer platform or not can be checked, the interfaces without the interface contract can be maintained, the accuracy of the interface contract can be checked, the interface contract can be updated and maintained in time, the production bug is reduced, and the test efficiency is improved.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the application. As shown in fig. 4, the electronic device 400 includes a processor 401 and a memory 402, wherein the electronic device 400 may further include a bus 403, the processor 401 and the memory 402 may be connected to each other by the bus 403, and the bus 403 may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The bus 403 may be classified into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 4, but not only one bus or one type of bus. The electronic device 400 may further include an input/output device 404, where the input/output device 404 may include a display screen, such as a liquid crystal display screen. Memory 402 is used to store one or more programs that include instructions; the processor 401 is arranged to invoke instructions stored in the memory 402 to perform some or all of the method steps mentioned in the embodiments of fig. 1 or fig. 2 above.
It should be appreciated that in embodiments of the present application, the processor 401 may be a central processing unit (Central Processing Unit, CPU), which may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSPs), application specific integrated circuits (Application Specific Integrated Circuit, ASICs), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The input device 402 may include a touch pad, a fingerprint sensor (for collecting fingerprint information of a user and direction information of a fingerprint), a microphone, etc., and the output device 403 may include a display (LCD, etc.), a speaker, etc.
The memory 404 may include read only memory and random access memory and provide instructions and data to the processor 401. A portion of memory 404 may also include non-volatile random access memory. For example, memory 404 may also store information of device type.
Through the electronic device 400 of the embodiment of the present application, the electronic device 400 may add a file to be inspected to the first list; extracting a value of a target annotation from the first list, and saving the value as an interface path into a second list; comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract; executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform; acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with interface contract in the developer platform; if the contract update processing is inconsistent, contract update processing is carried out on the second interface; whether the interface contract exists on the developer platform or not can be checked, the interfaces without the interface contract can be maintained, the accuracy of the interface contract can be checked, the interface contract can be updated and maintained in time, the production bug is reduced, and the test efficiency is improved.
The embodiment of the present application also provides a computer storage medium storing a computer program for electronic data exchange, where the computer program causes a computer to execute some or all of the steps of any one of the interface contract checking methods described in the above method embodiments.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, such as the division of the modules, merely a logical function division, and there may be additional manners of dividing actual implementations, such as multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or modules, which may be in electrical or other forms.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical modules, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The integrated modules, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable memory. Based on this understanding, the technical solution of the present application may be embodied essentially or partly in the form of a software product, or all or part of the technical solution, which is stored in a memory, and includes several instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned memory includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.

Claims (10)

1. A method of checking interface contracts, the method comprising:
adding the file to be checked to the first list;
extracting a value of a target annotation from the first list, and saving the value as an interface path into a second list;
comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract;
executing contract maintenance processing on a first interface, wherein the first interface is an interface which does not maintain an interface contract in the developer platform;
acquiring interface parameters of a second interface, and comparing the parameters of the second interface in the developer platform with the parameters of the second interface specified by the file, wherein the second interface is an interface with interface contract in the developer platform;
and if the contract update processing is inconsistent, performing contract update processing on the second interface.
2. The method of claim 1, wherein performing a contract maintenance process on the first interface comprises:
updating the interface path of the first interface in the second list to the developer platform;
and acquiring an inlet parameter class variable of the first interface specified by the file as an inlet parameter of the first interface, and acquiring an outlet parameter class variable of the first interface specified by the file as an outlet parameter of the first interface.
3. The method of claim 1, wherein performing contract update processing on the second interface comprises:
updating the inlet parameters of the second interface by using the inlet parameter class variables of the second interface specified by the file, and updating the outlet parameters of the second interface by using the outlet parameter class variables of the second interface specified by the file.
4. The method of claim 1, wherein the comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface has an interface contract comprises:
if the interface path of the first interface in the developer platform is inconsistent with the interface path in the second list, confirming that the first interface does not maintain an interface contract;
and if the interface path of the second interface in the developer platform is consistent with the interface path in the second list, confirming that the second interface has an interface contract.
5. The method of claim 1, wherein prior to the adding the file to be inspected to the first list, the method further comprises:
extracting a source file from a code management repository;
searching a file with a preset type and target annotation in the source file as the file to be checked.
6. The method of claim 5, wherein extracting the value of the target annotation from the first list and saving as an interface path to a second list comprises:
and circularly traversing the classes in the first list, extracting the values of target annotations in the classes, and storing the values as the interface paths in the second list.
7. The method of claim 6, wherein the method further comprises:
and generating and outputting an interface contract state notification, wherein the interface contract state notification is used for prompting the first interface to generate contract maintenance processing or the second interface to generate contract updating processing.
8. An interface contract checking device, comprising:
the acquisition module is used for adding the file to be checked to the first list;
the searching module is used for extracting the value of the target annotation from the first list and storing the value as an interface path into a second list;
the checking module is used for comparing the interface paths in the developer platform with the interface paths in the second list to determine whether each interface in the developer platform has an interface contract;
the processing module is used for executing contract maintenance processing on a first interface, wherein the first interface is an interface without maintaining an interface contract in the developer platform;
the checking module is further configured to obtain an interface parameter of a second interface, and compare the parameter of the second interface in the developer platform with a parameter of the second interface specified by a file, where the second interface is an interface with an interface contract in the developer platform;
and the processing module is further used for performing contract updating processing on the second interface if the parameters of the second interface in the developer platform are inconsistent with the parameters of the second interface specified by the file.
9. An electronic device comprising a processor, an input device, an output device, and a memory, the processor, the input device, the output device, and the memory being interconnected, wherein the memory is configured to store a computer program comprising program instructions, the processor being configured to invoke the program instructions to perform the method of any of claims 1-7.
10. A computer storage medium storing a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1-7.
CN202310997538.3A 2023-08-08 2023-08-08 Interface contract checking method and device, electronic equipment and storage medium Pending CN117033208A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310997538.3A CN117033208A (en) 2023-08-08 2023-08-08 Interface contract checking method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310997538.3A CN117033208A (en) 2023-08-08 2023-08-08 Interface contract checking method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117033208A true CN117033208A (en) 2023-11-10

Family

ID=88623939

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310997538.3A Pending CN117033208A (en) 2023-08-08 2023-08-08 Interface contract checking method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117033208A (en)

Similar Documents

Publication Publication Date Title
CN110704304B (en) Application program testing method and device, storage medium and server
CN112199300B (en) Interface testing method and device, electronic equipment and storage medium
CN114116496A (en) Automatic testing method, device, equipment and medium
CN110737689A (en) Data standard conformance detection method, device, system and storage medium
CN109871368B (en) Database detection method, database detection device, computer device and storage medium
US20220350857A1 (en) Methods and systems for browser extension used to generate relative xpath, absolute xpath and/or css selectors
CN115630036A (en) Error information processing method, apparatus, device, storage medium and program product
CN113946510A (en) WEB page testing method, device and equipment and computer storage medium
CN110704311B (en) Application program testing method and device, electronic equipment and readable storage medium
US8589734B2 (en) Verifying correctness of processor transactions
CN114139161A (en) Method, device, electronic equipment and medium for batch vulnerability detection
CN113434400A (en) Test case execution method and device, computer equipment and storage medium
CN110874475A (en) Vulnerability mining method, vulnerability mining platform and computer readable storage medium
CN113407449A (en) Interface testing method and device
CN116483888A (en) Program evaluation method and device, electronic equipment and computer readable storage medium
CN108829590B (en) Software testing method, device and system
CN117033208A (en) Interface contract checking method and device, electronic equipment and storage medium
CN113282496B (en) Automatic interface testing method, device, equipment and storage medium
CN110532186B (en) Method, device, electronic equipment and storage medium for testing by using verification code
CN109697141B (en) Method and device for visual testing
CN111782527A (en) Interface testing method and device, computer equipment and storage medium
CN113238940A (en) Interface test result comparison method, device, equipment and storage medium
CN111858377A (en) Quality evaluation method and device for test script, electronic device and storage medium
CN112256252A (en) Interface generation method and device, storage medium and electronic equipment
CN110555090B (en) Method, system, terminal and storage medium for automatically acquiring CPU BUS Number

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination