Interface verification method and device, storage medium and electronic equipment
By considering the dependencies between interfaces in interface verification and comparing the access results of the interface, the problem of low interface verification accuracy in the prior art is solved, and higher verification accuracy and reliability are achieved.
Patent Information
- Application Number
- CN202411488744.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-14
AI Technical Summary
The prior art does not consider the dependencies between interfaces during the interface verification process, resulting in low verification accuracy.
By determining the interface set configured in the target page, using the dependencies between interfaces, obtaining the interface's access results, and determining the target access result matching the interface's access result in the reference access result set, and comparing it to determine the interface's access through Verified.
It improves the accuracy of interface verification, covers the logical relationship of interfaces, and ensures the reliability of verification results.
Smart Images

Figure CN119441003A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to an interface verification method and device, a storage medium, and an electronic device. Background Art
[0002] The interface of a page is the communication method between the page and the backend service. These interfaces allow the front-end page to send requests and receive responses, thereby realizing data interaction. Generally speaking, a page can include multiple interfaces. In order to ensure the correctness of the application function, the interface usually needs to be verified.
[0003] Currently, for interface verification, a common method is to verify each interface in the page one by one to determine whether the return result of each interface is normal.
[0004] However, when using the interface verification method in the above-mentioned related technology, each interface is independent during the verification process, and the influence of the dependency relationship between the interfaces on the verification result is not considered, which leads to a technical problem of low interface verification accuracy.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present application provide an interface verification method and device, a storage medium, and an electronic device to at least solve the technical problem of low accuracy of interface verification.
[0007] According to one aspect of an embodiment of the present application, a method for verifying an interface is provided, comprising: determining an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified; when a first interface in the interface set belongs to a first type and a second access result of a second interface in the interface set has been obtained, accessing the first interface in the interface set and obtaining a first access result of the first interface, wherein the second interface is a previous interface in the interface set adjacent to the first interface, and an access condition for an interface of the first type is obtaining an access result of a previous interface in the interface set adjacent to the interface of the first type; determining a target access result that matches the first access result in a reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface; comparing the target access result with the first access result, and determining that the first interface has passed the interface verification when the target access result matches the first access result.
[0008] According to another aspect of an embodiment of the present application, an interface verification device is also provided, including: a first determination unit, used to determine an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified; an access unit, used to access the first interface in the interface set and obtain the first access result of the first interface when the first interface in the interface set belongs to the first type and the second access result of the second interface in the interface set has been obtained, wherein the second interface is the previous interface adjacent to the first interface in the interface set, and the access condition of the first type of interface is to obtain the access result of the previous interface adjacent to the first type of interface in the interface set; a second determination unit, used to determine a target access result matching the first access result in a reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface; a comparison unit, used to compare the target access result with the first access result, and when the target access result matches the first access result, determine that the first interface has passed the interface verification.
[0009] Optionally, in this embodiment, the above-mentioned second determination unit includes: a first determination module, used to determine the target access order corresponding to the first interface in the interface set, and determine the target access response information used to verify the first interface based on the access response information of the second interface indicated by the second access result, wherein the target access result includes the target access order and the target access response information; the above-mentioned comparison unit includes: a first comparison module, used to compare the target access order with the access order of the first interface in the interface set indicated by the first access result; compare the target access response information with the access response information of the first interface indicated by the first access result; when the access order is consistent with the target access order, and the access response information is consistent with the target access information, it is determined that the first interface has passed the interface verification.
[0010] Optionally, in this embodiment, the above-mentioned device also includes: a first acquisition unit, used to acquire project information of the target application, wherein the project information includes requirement information, design information, and user information of the target application; a third determination unit, used to determine the page in the target application on which the interface verification operation is to be performed based on the project information, and obtain a target page set; a fourth determination unit, used to determine the target page from the page set, and determine all interfaces configured in the target page, and obtain a candidate interface set.
[0011] Optionally, in this embodiment, the above-mentioned device also includes: a fifth determination unit, which is used to determine the project sub-information corresponding to the target page in the project information; a sixth determination unit, which is used to determine the reference access order of each interface in the candidate interface set and the reference access response information of each interface based on the project sub-information, and obtain a reference access result set, wherein the nth reference access result in the reference access result set includes the reference access order of the nth interface in the interface set and the reference access response information of the nth interface; a sorting processing unit, which is used to sort the interfaces included in the candidate interface set based on the reference access order of each interface, and obtain an interface set; a seventh determination unit, which is used to determine the association relationship between each interface in the interface set and the operation control in the target page based on the project sub-information, and generate an access instruction set corresponding to the interface set based on the association relationship; an association processing unit, which is used to associate the reference access result set to the interface set, and associate the access instruction set to the interface set.
[0012] Optionally, in this embodiment, the access unit includes: a first access module, configured to access the first interface using a target access instruction matching the first interface in an access instruction set associated with the interface set, wherein the target access instruction is used to simulate an operation on an operation control associated with the first interface in a target page;
[0013] Optionally, in this embodiment, the above-mentioned device further includes: an eighth determining unit, configured to determine the reference access result set based on an association relationship between the reference access result set and the interface set.
[0014] Optionally, in this embodiment, the above-mentioned device also includes: a ninth determination unit, used to determine, based on project information, an interface pair with a dependency relationship in the interface set, wherein the interface pair includes two interfaces; a tenth determination unit, used to determine the second interface in the interface pair whose access condition is to obtain the access result of the first interface in the interface pair, as an interface belonging to the first type.
[0015] Optionally, in this embodiment, the above-mentioned device also includes: a second access unit, which is used to access the third interface in the interface set by using the reference access instruction in the access instruction set when the third interface in the interface set belongs to the second type, and obtain a third access result of the third interface, wherein the access condition of the second type of interface is to perform an operation on the operation control associated with the second type of interface in the target page; an eleventh determination unit, which is used to determine the object access result for verifying the third interface in the reference access result set; and a second comparison unit, which is used to compare the object access result and the third access result, and determine that the third interface has passed the interface verification when the object access result and the third access result match.
[0016] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned interface verification method when running.
[0017] According to another aspect of the embodiments of the present application, there is further provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned interface verification method through the computer program.
[0018] In an embodiment of the present application, an interface set configured in a target page is determined, wherein the interface set includes at least two interfaces to be verified; when a first interface in the interface set belongs to a first type and a second access result of a second interface in the interface set has been obtained, the first interface in the interface set is accessed, and a first access result of the first interface is obtained, wherein the second interface is a previous interface in the interface set that is adjacent to the first interface, and an access condition for an interface of the first type is to obtain an access result of a previous interface in the interface set that is adjacent to the first type; a target access result that matches the second access result is determined in a reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface; the target access result is compared with the first access result, and when the target access result matches the first access result, it is determined that the first interface has passed the interface verification. In other words, by adopting the embodiment of the present application, in the process of verifying interfaces with dependent relationships, the method for verifying the target access result of the interface is determined by utilizing the access result of the interface on which the interface being verified depends, so that the verification of the interface covers the logical relationship of the interface, thereby achieving the technical effect of improving the accuracy of interface verification and solving the technical problem of inaccurate interface verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 is a flowchart of an optional interface verification method according to an embodiment of the present application;
[0021] Figure 2 is a flowchart of another optional interface verification method according to an embodiment of the present application;
[0022] Figure 3 is a flowchart of another optional interface verification method according to an embodiment of the present application;
[0023] Figure 4 is a flowchart of another optional interface verification method according to an embodiment of the present application;
[0024] Figure 5 is a schematic diagram of the structure of an optional interface verification device according to an embodiment of the present application;
[0025] Figure 6 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] Alternatively, as an alternative, Figure 1 As shown, the verification method of the above interface includes:
[0029] S102: Determine an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified.
[0030] It should be noted that the above interface verification method can be, but is limited to, applied to the interface verification scenario in an application. Specifically, an application can include, but is not limited to, multiple pages, and the above target page is one of the pages in the target application. In this embodiment, each interface in the interface set configured in the above target page is verified to determine whether the result returned after the interface is accessed is correct.
[0031] S104, when the first interface in the interface set belongs to the first type and the second access result of the second interface in the interface set has been obtained, access the first interface in the interface set and obtain the first access result of the first interface, wherein the second interface is the previous interface adjacent to the first interface in the interface set, and the access condition of the first type of interface is to obtain the access result of the previous interface adjacent to the first type of interface in the interface set.
[0032] It should be noted that the first type of interface mentioned above can be, but is not limited to, an interface used to indicate access results that depend on other interfaces. For example, suppose there is an e-commerce website, and a certain page of the website includes the following three interfaces: User login interface: The user first needs to verify his identity through the login interface, Get order list interface: After the user logs in, he can call an interface to get their order list, Get order details interface: After the user selects an order, he can call another interface to get detailed information of the order, such as a list of goods, delivery information, etc. The Get order details interface on this page depends on the user having verified his identity through the login interface and having selected an order through the Get order list interface. Without these preconditions, the Get order details interface will not be able to provide correct information.
[0033] Optionally, in some embodiments, the second access result may include, but is not limited to, the access sequence of accessing the second interface and the access response information returned by the second interface after accessing the second interface. Specifically, the access sequence may be, but is not limited to, used to indicate the number of the second interface accessed in the interface set, and the access response information is used to indicate the interface information returned by the second interface and the page information displayed on the page after accessing the second interface, which is not limited in this embodiment.
[0034] Correspondingly, referring to the second access result, the first access result may include, but is not limited to, the access sequence of accessing the first interface and the access response information returned by the first interface after accessing the first interface. Specifically, the access sequence may be, but is not limited to, used to indicate the first interface is the number of the interface accessed in the interface set, and the access response information is used to indicate the interface information returned by the first interface after accessing the first interface and the page information displayed on the page, which is not limited in this embodiment.
[0035] S106: Determine a target access result that matches the second access result in the reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface.
[0036] It should be noted that the target access result determined in the reference access result set to match the second access result and used to verify the first interface may include but is not limited to: determining the target access sequence corresponding to the first interface in the interface set, and based on the access response information of the second interface indicated by the second access result, determining the target access response information used to verify the first interface, wherein the target access result includes the target access sequence and the target access response information.
[0037] S108 , comparing the target access result and the first access result, and determining that the first interface passes the interface verification when the target access result and the first access result match.
[0038] Optionally, in some embodiments, the above-mentioned comparison of the target access result and the first access result, and determining that the first interface has passed the interface verification when the target access result and the first access result match, may include but is not limited to: comparing the target access order and the access order of the first interface indicated by the first access result in the interface set; comparing the target access response information with the access response information of the first interface indicated by the first access result; and determining that the first interface has passed the interface verification when the access order and the target access order are consistent, and the access response information and the target access information are consistent.
[0039] In an embodiment of the present application, an interface set configured in a target page is determined, wherein the interface set includes at least two interfaces to be verified; when a first interface in the interface set belongs to a first type and a second access result of a second interface in the interface set has been obtained, the first interface in the interface set is accessed, and a first access result of the first interface is obtained, wherein the second interface is a previous interface in the interface set that is adjacent to the first interface, and an access condition for an interface of the first type is to obtain an access result of a previous interface in the interface set that is adjacent to the first type; a target access result that matches the second access result is determined in a reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface; the target access result is compared with the first access result, and when the target access result matches the first access result, it is determined that the first interface has passed the interface verification. In other words, by adopting the embodiment of the present application, in the process of verifying interfaces with dependent relationships, the method for verifying the target access result of the interface is determined by utilizing the access result of the interface on which the interface being verified depends, so that the verification of the interface covers the logical relationship of the interface, thereby achieving the technical effect of improving the accuracy of interface verification and solving the technical problem of inaccurate interface verification.
[0040] Optionally, as an optional scheme, determining a target access result that matches the second access result in a reference access result set includes: determining a target access sequence corresponding to the first interface in the interface set, and based on the access response information of the second interface indicated by the second access result, determining the target access response information used to verify the first interface, wherein the target access result includes the target access sequence and the target access response information.
[0041] Comparing the target access result and the first access result includes: comparing the target access sequence and the access sequence of the first interface indicated by the first access result in the interface set; comparing the target access response information and the access response information of the first interface indicated by the first access result.
[0042] When the target access result matches the first access result, determining that the first interface has passed the interface verification includes: when the access sequence is consistent with the target access sequence, and the access response information is consistent with the target access information, determining that the first interface has passed the interface verification.
[0043] Specifically, the access response information of the second interface may include, but is not limited to, interface information and page information, wherein the interface information may include, but is not limited to, the URL of the interface, request method, request parameters, expected response, interface access time information, and the page information may include, but is not limited to, a screenshot of the content displayed on the target page after accessing the second interface. In this embodiment, the interface information may be obtained by using, but is not limited to, a network proxy (such as proxy tools charles, fiddler, mitmproxy) or traffic capture (traffic capture such as Kafka).
[0044] Correspondingly, the access response information of the first interface may also include, but is not limited to, interface information and page information. The interface information may include, but is not limited to, the URL of the interface, request method, request parameters, expected response, interface access time information, and other information, and the page information may include, but is not limited to, a screenshot of the content displayed on the target page after accessing the first interface.
[0045] It should be noted that the above-mentioned target access response information for verifying the first interface based on the query response information of the second interface indicated by the second access result may include, but is not limited to: determining the type of the target access response information of the first interface based on the type of the i-1th access response information. Specifically, the type of the above-mentioned i-1th access response information may include, but is not limited to: successful return, error return, timeout return, and abnormal content return, wherein the successful return access response information is used to indicate that the second interface is successfully accessed and the correct data is returned. The above-mentioned access response information that returns an error may be, but is not limited to, used to indicate that access to the second interface has failed. The above-mentioned access response information that returns a timeout may be, but is not limited to, used to indicate that no data is returned within a predetermined time period after accessing the second interface. The above-mentioned access response information that returns abnormal content may be, but is not limited to, used to indicate that the data returned after accessing the second interface is incorrect data.
[0046] It should be noted that, in some embodiments, an automated tool may be used to simulate access to the second interface to obtain the i-1th access response information of the expected type, such as an interface testing tool Postman, an interface testing tool JMeter, an interface testing tool WireMock, or other tools with similar functions, which are not limited in this embodiment.
[0047] Optionally, in some embodiments, it is necessary to determine the access response information that should be given in the first access result of the first interface according to the type of the access response information in the second access result, that is, the above-mentioned target access response information. For example, taking the type of the access response information in the above-mentioned second access result as an access error, the above-mentioned target access response information may include, but is not limited to, a prompt message for prompting the user that the i-th interface cannot be accessed at present and please try again later.
[0048] It should be noted that the above examples are optional examples provided to facilitate explanation of the verification method of the above interface, and there is no limitation on the verification method of the above interface.
[0049] Furthermore, in the present embodiment, by comparing the access order indicated in the first access result obtained after accessing the first interface with the expected access order to the first interface (i.e., the above-mentioned target access order), the technical problem of disordered application interface access order caused by the inability to verify the interface order after the application is updated in the verification method of a single interface in the related technology is avoided, thereby achieving the technical effect of improving the accuracy of interface verification.
[0050] In an embodiment of the present application, the target access sequence corresponding to the first interface in the interface set is determined, and based on the access response information of the second interface indicated by the second access result, the target access response information for verifying the first interface is determined, wherein the target access result includes the target access sequence and the target access response information. Then, the target access sequence is compared with the access sequence of the first interface in the interface set indicated by the first access result; the target access response information is compared with the access response information of the first interface indicated by the first access result. Furthermore, when the access sequence is consistent with the target access sequence, and the access response information is consistent with the target access information, it is determined that the first interface has passed the interface verification. That is, using an embodiment of the present application, in the process of interface verification of interfaces with dependencies, the method for determining the target access result for verifying the interface is determined by using the access result of the interface on which the interface being verified depends, so that the interface verification covers the logical relationship of the interface, thereby achieving the technical effect of improving the accuracy of interface verification and solving the technical problem of inaccurate interface verification.
[0051] Optionally, as an optional solution, before determining the interface set configured in the target page, the method further includes:
[0052] S1, obtaining project information of a target application, wherein the project information includes requirement information, design information, and user information of the target application.
[0053] It should be noted that, in some embodiments, the project information of the target application may be, but is not limited to, used to indicate a set of documents that record in detail relevant information in the process of application development, design, testing, deployment, and maintenance, including: requirement documents, design documents, user stories, etc., which are not limited in this embodiment.
[0054] S2, determining the pages in the target application program on which the interface verification operation is to be performed based on the project information, and obtaining a target page set.
[0055] Optionally, in this embodiment, by parsing the project information of the target application, it is possible to determine which pages in the target application need to be verified, thereby obtaining the target page set. By further reading and parsing the project information of the target application, it is possible to determine which interfaces are included in each page.
[0056] S3, determine the target page from the page set, and determine all interfaces configured in the target page to obtain a candidate interface set.
[0057] It should be noted that in some embodiments, after the target page set is determined, verification information (i.e., reference access results and test instructions) will be prepared for each page in the target page set in turn, and then the interfaces in the above-mentioned pages will be accessed in turn, and then the interfaces in each page will be compared and verified in turn.
[0058] In an embodiment of the present application, the project information of the target application is obtained, wherein the project information includes the required information, design information, and user information of the target application. Then, based on the project information, the page in the target application on which the interface verification operation is to be performed is determined to obtain a target page set. Furthermore, the target page is determined from the page set, and all interfaces configured in the target page are determined to obtain a candidate interface set. In other words, by using the embodiment of the present application, the technical effect of improving the verification efficiency of the interface in the page is achieved by using the project information of the target application to predetermine the page scenario to be tested.
[0059] Optionally, as an optional solution, after determining the target page from the page set and determining all interfaces configured in the target page to obtain the candidate interface set, the method further includes:
[0060] S1, determining the project sub-information corresponding to the target page in the project information.
[0061] Optionally, in some embodiments, the above-mentioned project sub-information may be, but is not limited to, information about the target page recorded in the above-mentioned project information, and this is not limited in the present embodiment.
[0062] S2, based on the project sub-information, determine the reference access order of each interface in the candidate interface set and the reference access response information of each interface, and obtain a reference access result set, wherein the nth reference access result in the reference access result set includes the reference access order of the nth interface in the interface set and the reference access response information of the nth interface in the interface set.
[0063] It should be noted that the reference access sequence of each interface in the above-mentioned candidate interface set can be but is not limited to the access sequence corresponding to the expected correct access order of each interface obtained by parsing the historical access log related to the target page and the above-mentioned project sub-information.
[0064] Furthermore, the reference access information of each interface mentioned above may be, but is not limited to, used to indicate the interface information and page information returned by each interface for different access situations.
[0065] For example, for the first type of interface mentioned above, the interface information and page information returned by this interface for different access situations may include, but are not limited to: when the interface on which it depends returns successfully, returns an error, returns a timeout, returns abnormal content, etc., the interface information and page information returned by this interface. And when this interface returns successfully, returns an error, returns a timeout, returns abnormal content, etc., other interface information and page information returned by this interface. It should be noted that, as can be seen from the relevant examples above, these access situations can be, but are not limited to, simulated using automated tools, and this will not be repeated in this embodiment.
[0066] To give another example, for the second type of interface mentioned above, that is, an interface whose access does not rely on other interfaces, the interface information and page information returned by this interface for different access situations may include but are not limited to: other interface information and page information returned by this interface when the interface returns successfully, returns an error, returns a timeout, returns abnormal content, etc.
[0067] S3, sorting the interfaces included in the candidate interface set based on the reference access order of each interface to obtain an interface set.
[0068] Optionally, in some embodiments, the interfaces in the candidate set are sorted according to the reference access order, so that the interfaces can be accessed in the expected order in the subsequent interface access process.
[0069] S4, determining the association relationship between each interface in the interface set and the operation control in the target page based on the project sub-information, and generating an access instruction set corresponding to the interface set based on the association relationship.
[0070] It should be noted that the access instructions included in the above-mentioned access instruction set can be but are not limited to being used to simulate click operations on the above-mentioned operation controls. Specifically, some interfaces in the above-mentioned interface set require touch page operations to trigger access. In this embodiment, based on software requirement documents, user stories, design documents and other materials, all important user operation paths are confirmed to generate instructions for simulating the operations of the operation controls associated with each interface, thereby obtaining the above-mentioned access instruction set.
[0071] Optionally, the above-mentioned determination of the association relationships between each interface in the interface set and the operation controls in the target page based on the project sub-information, and generation of an access instruction set corresponding to the interface set based on the association relationship may include but is not limited to: determining the candidate interfaces in the above-mentioned interface set that need to be triggered by page operations to access, determining the operation controls that need to be triggered by each of the above-mentioned candidate interfaces, generating simulated touch instructions for the operation controls that need to be triggered by each of the candidate interfaces, and obtaining the above-mentioned access instruction set.
[0072] It should be further explained that, in some embodiments, after determining the reference access result set and the access instruction set, the reference access result set and the access instruction set may be packaged and stored, but is not limited to being packaged and stored.
[0073] S5, associating the reference access result set with the interface set, and associating the access instruction set with the interface set.
[0074] Optionally, in some embodiments, the above-mentioned associating the reference access result set to the interface set, and associating the access instruction set to the interface set may include but is not limited to: associating each reference access result in the reference access result with the corresponding interface in the interface set to obtain an association relationship record table between the reference access result set and the interface set, and associating each reference access result in the access instruction with the corresponding interface in the interface set to obtain an association relationship record table between the access instruction set and the interface set.
[0075] In an embodiment of the present application, the project sub-information corresponding to the target page in the project information is determined. Then, based on the project sub-information, the reference access order of each interface in the candidate interface set and the reference access response information of each interface are determined to obtain a reference access result set, wherein the nth reference access result in the reference access result set includes the reference access order of the nth interface and the reference access response information of the nth interface in the interface set. Furthermore, the interfaces included in the candidate interface set are sorted based on the reference access order of each interface to obtain an interface set. Thus, the association relationship between each interface in the interface set and the operation control in the target page is determined based on the project sub-information, and an access instruction set corresponding to the interface set is generated based on the association relationship. Next, the reference access result set is associated with the interface set, and the access instruction set is associated with the interface set. In other words, by adopting the embodiment of the present application, by pre-creating an access instruction set and a reference access result set for verifying the interface in the interface set corresponding to the target page, and associating the access instruction set and the reference access result set with the interface set, the access instructions and reference access results for verifying the interface can be directly obtained through these associations during the subsequent interface verification process, thereby achieving the technical effect of improving the verification efficiency of the interface.
[0076] Optionally, as an optional scheme, accessing the first interface in the interface set includes: accessing the first interface using a target access instruction in an access instruction set associated with the interface set that matches the first interface, wherein the target access instruction is used to simulate an operation on an operation control associated with the first interface in a target page; when the first interface in the interface set belongs to a first type and a second access result of a second interface in the interface set has been obtained, accessing the first interface in the interface set, and after obtaining the first access result of the first interface, further includes: determining a reference access result set based on an association relationship between the reference access result set and the interface set.
[0077] Optionally, in this embodiment, based on the association relationship record table corresponding to the access instruction set and the interface set, the access instruction set for verifying the interface set can be determined, and the access instruction for accessing the first interface can be determined.
[0078] It should be noted that, in this embodiment, the reference access result set used to verify the interface set can be determined based on the association relationship record table corresponding to the reference access result set and the interface set.
[0079] In an embodiment of the present application, a target access instruction matching the first interface in an access instruction set associated with an interface set is used to access the first interface, wherein the target access instruction is used to simulate an operation on an operation control associated with the first interface in a target page. A reference access result set is determined based on an association relationship between a reference access result set and an interface set. That is, using an embodiment of the present application, in the process of interface verification, by utilizing the association relationship between an interface set, an access instruction set, and a reference access result set, access instructions and reference access results for verifying the interface can be quickly obtained, thereby achieving a technical effect of improving the verification efficiency of the interface.
[0080] Optionally, as an optional solution, after determining the interface set configured in the target page, the method further includes:
[0081] Based on the project information, an interface pair having a dependency relationship in the interface set is determined, wherein the interface pair includes two interfaces.
[0082] The second interface in the interface pair whose access condition is obtaining the access result of the first interface in the interface pair is determined as an interface of the first type.
[0083] It should be noted that in some embodiments, the interface document in the project information can be parsed but is not limited to determining the above-mentioned interface pairs with dependencies, wherein the above-mentioned interface document records the access order, dependencies, access logic relationships, etc. of each interface in the collection, and no limitation is made to this in the present embodiment.
[0084] Optionally, in some embodiments, the above-mentioned interface pair with a dependency relationship may be, but is not limited to, an interface pair used to indicate output information that depends on another interface when accessed, and the above-mentioned interface pair may be, but is not limited to, including a dependent interface and a dependent interface. In this embodiment, the dependent interface is determined as a first type of interface and is marked and saved.
[0085] For example, assuming that the interface collection includes interface A, interface B, and interface C, after parsing the interface document, the access dependency of interface B and the data returned by interface A are determined. Then, interface A and interface B need to be determined as an interface pair, and then the dependent party in the interface pair, that is, interface B, is determined as the first type of interface mentioned above.
[0086] It should be noted that the above example is an optional example provided to facilitate explanation of the verification method of the above interface, and there is no limitation on the verification method of the above interface.
[0087] In an embodiment of the present application, based on project information, an interface pair having a dependency relationship in an interface set is determined, wherein the interface pair includes two interfaces. Then, the second interface in the interface pair whose access condition is to obtain the access result of the first interface in the interface pair is determined to be an interface of the first type. In other words, by adopting an embodiment of the present application, by pre-analyzing the dependency relationship between interfaces and pre-marking the type of the dependent party interface in the interface having a dependency relationship as the first type, the interface can be verified through the dependency relationship between interfaces by the type of the interface in the subsequent interface verification process, thereby improving the accuracy of the interface verification.
[0088] Optionally, as an optional solution, after determining the interface set configured in the target page, the method further includes:
[0089] S1, when a third interface in the interface set belongs to the second type, access the third interface in the interface set using a reference access instruction in the access instruction set, and obtain a third access result of the third interface, wherein the access condition of the second type of interface is to perform an operation on an operation control associated with the second type of interface in a target page;
[0090] S2, determining an object access result for verifying the third interface in the reference access result set;
[0091] S3, comparing the object access result and the third access result, and determining that the third interface has passed the interface verification when the object access result and the third access result match.
[0092] It should be noted that, in some embodiments, the second type of interface is used to indicate that there is no need to rely on interfaces output from other interfaces when accessing, and that only the corresponding access instructions need to be executed when accessing the second type of interface.
[0093] Optionally, in some embodiments, the reference access response information included in the object access result of the above-mentioned third interface is related to the access situation of the third interface. Specifically, when the access to the above-mentioned third interface is a simulated successful return, the reference access response information included in the object access result of the above-mentioned third interface should match the situation of the simulated successful return; when the access to the above-mentioned third interface returns an error, the reference access response information included in the object access result of the above-mentioned third interface should match the situation of the returned error; when the access to the above-mentioned third interface returns a timeout, the reference access response information included in the object access result of the above-mentioned third interface should match the situation of the simulated return timeout; when the access to the above-mentioned third interface is a simulated return content exception, the reference access response information included in the object access result of the above-mentioned third interface should match the situation of the simulated return content exception.
[0094] Optionally, the above-mentioned comparison of the object access result and the third access result, and determining that the first interface has passed the interface verification when the object access result and the third access result match, may include but is not limited to: comparing the reference access order indicated by the object access result and the access order of the third interface indicated by the third access result in the interface set, and comparing the reference access response information indicated by the object access result with the access response information of the third interface indicated by the third access result; when the reference access order indicated by the object access result and the access order of the third interface indicated by the third access result in the interface set are consistent, and the reference access response information indicated by the object access result is consistent with the access response information of the third interface indicated by the third access result, determining that the third interface has passed the interface verification.
[0095] In an embodiment of the present application, when the third interface in the interface set belongs to the second type, the reference access instruction in the access instruction set is used to access the third interface in the interface set, and obtain the third access result of the third interface, wherein the access condition of the second type of interface is to perform an operation on the operation control associated with the second type of interface in the target page; determine the object access result for verifying the third interface in the reference access result set; compare the object access result with the third access result, and when the object access result and the third access result match, determine that the third interface has passed the interface verification. In other words, by using the embodiment of the present application, the technical effect of improving the verification efficiency of the interface is achieved by automatically verifying the interface using the access instruction.
[0096] Optionally, as an optional example, it can be but not limited to based on Figure 2 The following example illustrates the verification method of the above interface:
[0097] S202, test scenario entry. Specifically, write detailed test cases according to the defined scenarios. Each test case should include the order of interface calls, input parameters, expected results, and records of actual results. Select appropriate automated testing tools, such as Appium, UI Automator, etc., and write scripts to simulate user operations and trigger network interface access in corresponding scenarios.
[0098] It also includes: S202-1: Confirmation of client test scenarios: Determine the specific content of the test scenarios. According to the software requirements document, user stories, design documents and other materials, clarify the page scenarios that need to be tested. The purpose of confirming the test scenarios is to ensure that the test covers all important user operation paths. S202-2: Encapsulate the operation steps to enter a specific test scenario. Encapsulation usually refers to writing a series of operation steps into a script or test case so that they can be quickly executed during automated testing or manual testing. For example, open an application, click a specific button, enter specific information, etc. As for the specific tools, mainstream UI automation testing tools such as Appium, UI Automator, selenuim, etc. are used. S202-3: Encapsulation of client-related scenario network interface information acquisition: In client testing, data interaction with the server is often required. In this stage, the network interface information of the client and server interaction is obtained and saved using a network proxy (such as proxy tools charles, fiddler, mitmproxy) or traffic capture (traffic capture such as Kafka), including the URL of the interface, request method, request parameters, expected response, interface access time information, etc. The purpose of encapsulation is to facilitate the execution of subsequent steps after associating the test scenario, such as analyzing interface logic, interface access order, etc. S202-4: Client page scenario verification information encapsulation: Verification information encapsulation refers to organizing and encapsulating the information that needs to be verified in the test scenario. This information includes page activity information and page screenshots (these functions are generally included in UI automation tools). S202-5: The test scenario associates the interface list and scenario verification information under the scenario. Associate the test scenario with the relevant network interface list and scenario verification information. During the test process, a test scenario involves calls to multiple interfaces and multiple verification points.
[0099] S204, test scenario analysis, specifically, analyzing the access order and dependency relationship between interfaces in the same scenario (this step is to verify that before calling a certain interface, the interface it depends on has been successfully executed and returned the correct result).
[0100] S206, interface sequence and dependency generation; which also includes: S206-1, extracting scenario names from the data source, which usually represent different business processes or operation scenarios. At the same time, extracting network interface information related to each scenario, including the URL, request method, parameters, expected response, etc. of the interface. S206-2, loading the interface information under the first scenario: Extracting interface information: extracting all interface information under the first scenario from the data source. Sorting by access time: sorting the interface information in the order of access according to the access timestamp or log record of the interface to determine the access order of the interface. Obtaining the access logic between interfaces according to the interface document and saving it: Analyzing the interface document: reading and understanding the document of each interface to determine the dependency and access logic between interfaces. Saving logical relationships: saving the obtained interface logical relationships to a data structure, such as a database, file, or memory object, for subsequent use. S206-3, URL matching: matching the sorted interface URL with the saved interface logical relationship. Detecting logical relationships: checking whether each interface has a dependency or logical relationship with other interfaces, for example, the output of a certain interface may be the input of another interface. The interface access order and the logical relationship between interfaces in this scenario are saved and associated using the scenario name: Save interface access order: Save the sorted interface access order to a database or file. Save interface logical relationship: Save the detected interface logical relationship to the same data structure. Associate using scenario name: Use the scenario ID to associate the interface access order and logical relationship with the data generated by the solution to problem 1. Data association: Ensure that the scenario ID correctly corresponds to the data on the interface access order and logical relationship so that it can be quickly located and retrieved in subsequent data queries and analysis.
[0101] S208, interface logic and exception handling verification. Specifically, check whether the application status and data conform to the expected logic. For example, if interface A depends on the result of interface B, then before interface A is executed, it is necessary to verify whether the result of interface B is correct.
[0102] Optionally, as another optional example, it can be but not limited to based on Figure 3 The following example illustrates the above interface access sequence and dependency acquisition process:
[0103] Step S302, inputting preset data; specifically, inputting preset functions and corresponding page scenes into functions;
[0104] Step S304, network interface data capture service settings; specifically, configuring an automated service for acquiring network interface information of an interface;
[0105] Step S306, loading preset data; specifically, loading pre-entered preset data;
[0106] Step S308, entering the page scene; specifically, entering the scene to be verified;
[0107] Step S310, obtaining interface access information; specifically, obtaining interface access information through an interface crawling service;
[0108] Step S312, obtaining the interface access sequence according to the access time; specifically, obtaining the interface access sequence according to the interface access time recorded in the general log;
[0109] Step S314, associating and saving the page scene name; specifically, associating and saving the access information of the interface with the page scene;
[0110] Step S316, determining the logical relationship between interfaces according to the interface document.
[0111] Optionally, as another optional example, it can be but not limited to based on Figure 4 The following example illustrates the above interface logic and exception handling verification process:
[0112] Execute step S402 to load the page scenario information data and the corresponding interface association information. Then execute step S404 to start the proxy service. Then execute step S406 to simulate various exceptions starting from the first scenario according to the access order. Then execute step S408 to verify the access status of other interfaces in this scenario. Then execute step S410 to verify the application page. Then execute step S412 to verify the application log.
[0113] Then, step S414 is executed and the interface verification result is saved. It should be noted that after executing S414, the above steps S406-S414 can be executed for the next interface in the scenario until the verification of the last interface in the scenario is completed.
[0114] Next, when all interfaces in the scenario are verified, step S416 is executed and the scenario verification result is saved. Then, the above steps S402 to S416 are executed for the next verification scenario until all scenarios are verified.
[0115] Optionally, as another optional example, assuming that the pages to be verified include scenario 1: user login page, scenario 2: product list page, scenario 3: shopping cart page, the verification method of the above interface can be explained based on but not limited to the following examples:
[0116] Step S1, click the login button, click the view product button, click the view shopping cart button;
[0117] Step S2, starting the first scenario verification and presetting the first network interface error;
[0118] Step S3, entering the scene triggering interface access according to the client page scene entry operation: the user clicks the login button to trigger the login interface access.
[0119] Step S4, verification of the content returned by other interfaces in this scenario: verify whether the error information returned by the login interface is correct.
[0120] Step S5, verification of the returned content of the associated interface in this scenario: check whether there are other associated interfaces, and if so, verify their returned content.
[0121] Step S6, client page verification in this scenario: verify whether the login page displays the correct error message.
[0122] Step S7, client application log acquisition verification: check the client application log to confirm whether the error information is recorded.
[0123] Repeat steps S2-S7 to verify that the interface returns an error, returns a timeout, or returns abnormal content: Repeat the preset login interface to return an error, timeout, or return abnormal content, and verify the client behavior.
[0124] S8, save the interface verification result: scenario ID: 1, scenario name: user login page, interface name: login interface, simulation error type: return error, return timeout, return content exception, verification result.
[0125] Repeat steps S2-S8 to complete the verification of all interfaces in the scenario: Repeat the above verification process for all interfaces in scenario 1. Then repeat all the above steps to complete the verification of all scenarios: Repeat the above verification process for scenarios 2 and 3.
[0126] S9, overall report generation: Summarize the verification results of all scenarios and generate a detailed test report, including: verification results of each scenario, verification results of each interface under each scenario, and verification results of different abnormal simulations of each interface.
[0127] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0128] According to another aspect of the embodiment of the present application, there is also provided an interface verification device for implementing the above interface verification method. Figure 5 As shown, the device comprises:
[0129] A first determining unit 502 is used to determine an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified;
[0130] An access unit 504 is used to access the first interface in the interface set and obtain the first access result of the first interface when the first interface in the interface set belongs to the first type and the second access result of the second interface in the interface set has been obtained, wherein the second interface is the previous interface adjacent to the first interface in the interface set, and the access condition of the first type of interface is to obtain the access result of the previous interface adjacent to the first type of interface in the interface set;
[0131] A second determining unit 506 is used to determine a target access result matching the first access result in the reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface;
[0132] The comparison unit 508 is used to compare the target access result with the first access result, and determine that the first interface passes the interface verification when the target access result matches the first access result.
[0133] Optionally, in this embodiment, the above-mentioned second determination unit includes: a first determination module, used to determine the target access order corresponding to the first interface in the interface set, and determine the target access response information used to verify the first interface based on the access response information of the second interface indicated by the second access result, wherein the target access result includes the target access order and the target access response information; the above-mentioned comparison unit includes: a first comparison module, used to compare the target access order with the access order of the first interface in the interface set indicated by the first access result; compare the target access response information with the access response information of the first interface indicated by the first access result; when the access order is consistent with the target access order, and the access response information is consistent with the target access information, it is determined that the first interface has passed the interface verification.
[0134] Optionally, in this embodiment, the above-mentioned device also includes: a first acquisition unit, used to acquire project information of the target application, wherein the project information includes requirement information, design information, and user information of the target application; a third determination unit, used to determine the page in the target application on which the interface verification operation is to be performed based on the project information, and obtain a target page set; a fourth determination unit, used to determine the target page from the page set, and determine all interfaces configured in the target page, and obtain a candidate interface set.
[0135] Optionally, in this embodiment, the above-mentioned device also includes: a fifth determination unit, which is used to determine the project sub-information corresponding to the target page in the project information; a sixth determination unit, which is used to determine the reference access order of each interface in the candidate interface set and the reference access response information of each interface based on the project sub-information, and obtain a reference access result set, wherein the nth reference access result in the reference access result set includes the reference access order of the nth interface in the interface set and the reference access response information of the nth interface; a sorting processing unit, which is used to sort the interfaces included in the candidate interface set based on the reference access order of each interface, and obtain an interface set; a seventh determination unit, which is used to determine the association relationship between each interface in the interface set and the operation control in the target page based on the project sub-information, and generate an access instruction set corresponding to the interface set based on the association relationship; an association processing unit, which is used to associate the reference access result set to the interface set, and associate the access instruction set to the interface set.
[0136] Optionally, in this embodiment, the access unit includes: a first access module, configured to access the first interface using a target access instruction matching the first interface in an access instruction set associated with the interface set, wherein the target access instruction is used to simulate an operation on an operation control associated with the first interface in a target page;
[0137] Optionally, in this embodiment, the above-mentioned device further includes: an eighth determining unit, configured to determine the reference access result set based on an association relationship between the reference access result set and the interface set.
[0138] Optionally, in this embodiment, the above-mentioned device also includes: a ninth determination unit, used to determine, based on project information, an interface pair with a dependency relationship in the interface set, wherein the interface pair includes two interfaces; a tenth determination unit, used to determine the second interface in the interface pair whose access condition is to obtain the access result of the first interface in the interface pair, as an interface belonging to the first type.
[0139] Optionally, in this embodiment, the above-mentioned device also includes: a second access unit, which is used to access the third interface in the interface set by using the reference access instruction in the access instruction set when the third interface in the interface set belongs to the second type, and obtain a third access result of the third interface, wherein the access condition of the second type of interface is to perform an operation on the operation control associated with the second type of interface in the target page; an eleventh determination unit, which is used to determine the object access result for verifying the third interface in the reference access result set; and a second comparison unit, which is used to compare the object access result and the third access result, and determine that the third interface has passed the interface verification when the object access result and the third access result match.
[0140] For a specific embodiment, reference may be made to the example shown in the above-mentioned interface verification method, and this embodiment will not be described in detail here.
[0141] According to another aspect of the embodiments of the present application, an electronic device for implementing the above interface verification method is also provided. Figure 6 As shown, the electronic device includes a memory 602 and a processor 604. The memory 602 stores a computer program, and the processor 604 is configured to execute the steps in any of the above method embodiments through the computer program.
[0142] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0143] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0144] S1, determining an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified;
[0145] S2, when the first interface in the interface set belongs to the first type and the second access result of the second interface in the interface set has been obtained, access the first interface in the interface set and obtain the first access result of the first interface, wherein the second interface is the previous interface adjacent to the first interface in the interface set, and the access condition of the first type of interface is to obtain the access result of the previous interface adjacent to the first type of interface in the interface set;
[0146] S3, determining a target access result matching the second access result in the reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface;
[0147] S4, comparing the target access result and the first access result, and when the target access result and the first access result match, determining that the first interface passes the interface verification.
[0148] Alternatively, a person skilled in the art may understand that: Figure 6 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 6 The structure of the electronic device is not limited. Figure 6 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 6 Different configurations are shown.
[0149] Among them, the memory 602 can be used to store software programs and modules, such as the program instructions / modules corresponding to the interface verification method and device in the embodiment of the present application. The processor 604 executes various functional applications and data processing by running the software programs and modules stored in the memory 602, that is, implementing the above-mentioned interface verification method. The memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 602 may further include a memory remotely located relative to the processor 604, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. As an example, Figure 6 As shown, the memory 602 may include but is not limited to the determination unit 502, access unit 504, second determination unit 506 and comparison unit 508 in the verification device of the interface. In addition, other module units in the verification device of the interface may also be included but are not limited to, which will not be repeated in this example.
[0150] Optionally, the transmission device 606 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 606 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 606 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0151] In addition, the electronic device further includes: a display 608, and a connection bus 610 for connecting various module components in the electronic device.
[0152] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. The nodes may form a point-to-point network, and any form of computing device, such as a server, terminal or other electronic device, may become a node in the blockchain system by joining the point-to-point network.
[0153] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program / instruction, the computer program / instruction comprising a program code for executing the above method. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit, various functions provided by the embodiments of the present application are executed.
[0154] According to one aspect of the present application, another computer program product is also provided, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the method in each embodiment of the present application are implemented.
[0155] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above method.
[0156] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0157] S1, determining an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified;
[0158] S2, when the first interface in the interface set belongs to the first type and the second access result of the second interface in the interface set has been obtained, access the first interface in the interface set and obtain the first access result of the first interface, wherein the second interface is the previous interface adjacent to the first interface in the interface set, and the access condition of the first type of interface is to obtain the access result of the previous interface adjacent to the first type of interface in the interface set;
[0159] S3, determining a target access result matching the second access result in the reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface;
[0160] S4, comparing the target access result and the first access result, and when the target access result and the first access result match, determining that the first interface passes the interface verification.
[0161] Optionally, in the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0162] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0163] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0164] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0165] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0166] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0167] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0168] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for verifying an interface, characterized in that: include: Determine an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified; When a first interface in the interface set belongs to a first type and a second access result of a second interface in the interface set has been obtained, access the first interface in the interface set and obtain the first access result of the first interface, wherein the second interface is the previous interface in the interface set that is adjacent to the first interface, and the access condition of the interface of the first type is to obtain the access result of the previous interface in the interface set that is adjacent to the interface of the first type; Determining a target access result matching the second access result in a reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface; The target access result and the first access result are compared, and when the target access result and the first access result match, it is determined that the first interface passes the interface verification.
2. The method according to claim 1, characterized in that The determining of a target access result matching the second access result in the reference access result set comprises: determining a target access sequence corresponding to the first interface in the interface set, and determining target access response information for verifying the first interface based on the access response information of the second interface indicated by the second access result, wherein the target access result comprises the target access sequence and the target access response information; The comparing the target access result and the first access result comprises: comparing the target access sequence and the access sequence of the first interface indicated by the first access result in the interface set; comparing the target access response information and the access response information of the first interface indicated by the first access result; The determining that the first interface has passed the interface verification when the target access result and the first access result match includes: determining that the first interface has passed the interface verification when the access sequence and the target access sequence are consistent, and the access response information and the target access information are consistent.
3. The method according to claim 1, characterized in that Before determining the interface set configured in the target page, the method further includes: Acquire project information of a target application, wherein the project information includes requirement information, design information, and user information of the target application; Determine, based on the project information, pages in the target application program on which the interface verification operation is to be performed, and obtain a target page set; The target page is determined from the page set, and all interfaces configured in the target page are determined to obtain a candidate interface set.
4. The method according to claim 3, characterized in that After determining the target page from the page set and determining all interfaces configured in the target page to obtain a candidate interface set, the method further includes: Determine the project sub-information corresponding to the target page in the project information; Based on the project sub-information, determine the reference access sequence of each interface in the candidate interface set and the reference access response information of each interface, and obtain the reference access result set, wherein the nth reference access result in the reference access result set includes the reference access sequence of the nth interface in the interface set and the reference access response information of the nth interface; Sorting the interfaces included in the candidate interface set based on the reference access order of each interface to obtain the interface set; Determine, based on the project sub-information, the association relationship between each interface in the interface set and the operation control in the target page, and generate an access instruction set corresponding to the interface set based on the association relationship; The reference access result set is associated with the interface set, and the access instruction set is associated with the interface set.
5. The method according to claim 4, characterized in that The accessing the first interface in the interface set comprises: accessing the first interface using a target access instruction matching the first interface in an access instruction set associated with the interface set, wherein the target access instruction is used to simulate an operation on an operation control associated with the first interface in the target page; In a case where a first interface in the interface set belongs to a first type and a second access result of a second interface in the interface set has been obtained, after accessing the first interface in the interface set and obtaining the first access result of the first interface, the method further includes: The reference access result set is determined based on an association relationship between the reference access result set and the interface set.
6. The method according to claim 3, characterized in that After determining the interface set configured in the target page, the method further includes: Based on the project information, determining an interface pair having a dependency relationship in the interface set, wherein the interface pair includes two interfaces; The second interface in the interface pair, whose access condition is obtaining the access result of the first interface in the interface pair, is determined as an interface belonging to the first type.
7. The method according to claim 5, characterized in that After determining the interface set configured in the target page, the method further includes: In a case where the third interface in the interface set belongs to the second type, using the reference access instruction in the access instruction set, accessing the third interface in the interface set, and obtaining a third access result of the third interface, wherein the access condition of the interface of the second type is to perform an operation on an operation control associated with the interface of the second type in the target page; Determining, in the reference access result set, an object access result for verifying the third interface; The object access result and the third access result are compared, and when the object access result and the third access result match, it is determined that the third interface has passed the interface verification.
8. An interface verification device, characterized in that: include: A first determining unit, configured to determine an interface set configured in a target page, wherein the interface set includes at least two interfaces to be verified; an access unit, configured to access the first interface in the interface set and obtain a first access result of the first interface if the first interface in the interface set belongs to a first type and a second access result of the second interface in the interface set has been obtained, wherein the second interface is a previous interface in the interface set that is adjacent to the first interface, and an access condition for an interface of the first type is to obtain an access result of a previous interface in the interface set that is adjacent to the interface of the first type; A second determining unit, configured to determine a target access result matching the first access result in a reference access result set, wherein the reference access result set is used to perform interface verification on the target page, and the target access result is used to verify the first interface; A comparing unit is used to compare the target access result with the first access result, and determine that the first interface passes the interface verification when the target access result matches the first access result.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program is executed by a processor to perform the method described in any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
Citation Information
Patent Citations
Functional interface calling verification method and device, electronic device and storage medium
CN110334007A
Interface verification method and device, storage medium and electronic equipment
CN114253788A