Interface testing method and device, electronic equipment, storage medium and computer program
By acquiring and utilizing interface test configuration information, the test combination that matches the interface test instructions is determined, which solves the inefficiency problem caused by repeated calls and complex dependencies in interface testing, and realizes efficient testing of multiple interfaces under the same business state.
Patent Information
- Application Number
- CN202410447562.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-12
- Publication Date
- 2024-09-17
AI Technical Summary
In business scenarios, especially in interface testing for identity authentication, improving testing efficiency has become a hot research topic. Existing technologies suffer from low testing efficiency due to repeated interface calls and complex dependencies.
By obtaining the interface test configuration information of the target business scenario, the test combination that matches the interface test instructions is determined, and the interface to be tested is called to perform business processing, generating interface test results. The same input parameter data can be reused in the testing process of multiple interfaces under the same business state, reducing the amount of data preparation and the number of tests.
In the testing process of multiple interfaces under the same business state, the amount of data preparation work was reduced, and the testing of multiple interfaces was completed in one test, which improved testing efficiency and reduced the number of tests.
Smart Images

Figure CN118656294A
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to an interface testing method, device, electronic device, storage medium and computer program. Background Art
[0002] Interface testing is a test of the interfaces between system components. Interface testing is mainly used to detect the interaction points between external systems and internal subsystems. The focus of the test is to check the data exchange, transmission and control management process, as well as the mutual logical dependencies between systems.
[0003] In some business scenarios, such as identity authentication scenarios, the business process may involve multiple interfaces, and there may be dependencies between the input and output parameters of each interface. In the interface testing of such business scenarios, how to improve the testing efficiency has become a hot research issue. Summary of the invention
[0004] Embodiments of the present application provide an interface testing method, device, electronic device, storage medium, and computer program to improve interface testing efficiency.
[0005] In a first aspect, an embodiment of the present application provides an interface testing method, comprising:
[0006] In response to an interface test instruction for a target business scenario, interface test configuration information of the target business scenario is obtained, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state;
[0007] Determine a test combination that matches the interface test instruction from the test combination, and determine the interface to be tested in the matching test combination;
[0008] Call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination;
[0009] An interface test result for the interface test instruction is generated according to the output parameter data and the preset test result.
[0010] In a second aspect, an embodiment of the present application provides an interface testing device, including:
[0011] An acquisition unit, configured to acquire interface test configuration information of a target business scenario in response to an interface test instruction for the target business scenario, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state;
[0012] A determination unit, used to determine a test combination matching the interface test instruction from the test combination, and determine an interface to be tested in the matching test combination;
[0013] A calling unit, used for calling the interface to be tested to perform business processing based on target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination;
[0014] A generating unit is used to generate an interface test result for the interface test instruction according to the output parameter data and a preset test result.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory configured to store computer executable instructions, wherein the computer executable instructions, when executed, cause the processor to execute the interface testing method as described in the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the interface testing method as described in the first aspect.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the interface testing method as described in the first aspect.
[0018] It can be seen that in the embodiment of the present application, first, in response to the interface test instruction for the target business scenario, the interface test configuration information of the target business scenario is obtained, and the interface test configuration information includes the test combination of the target business scenario, and a test combination includes input parameter data under a business state and the interface required to be called when the business is executed under the business state; then, the test combination matching the interface test instruction is determined from the test combination, and the interface to be tested in the matching test combination is determined; then, the interface to be tested is called to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; finally, according to the output parameter data and the preset test result, the interface test result for the interface test instruction is generated. In this way, on the one hand, by binding the business state, the input parameter data and the interface to be called, it is conducive to the reuse of the same input parameter data in the test process of multiple interfaces in the same business state, which reduces the workload of data preparation compared with configuring the input parameter data under multiple business states for each interface. On the other hand, considering that when performing interface testing on a single interface, different input parameter data may be required to test the performance of the single interface under different business states respectively, by determining a test combination that matches the interface test instructions from the test combination to perform interface testing, it is beneficial to complete interface testing of multiple interfaces under the same business state at one time. Compared with performing interface testing on a single interface under multiple business states separately, the same testing purpose can be achieved while reducing the number of tests, thereby improving testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative labor.
[0020] Figure 1 A processing flow chart of an interface testing method provided in an embodiment of the present application;
[0021] Figure 2 A flowchart of an identity authentication process provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of a business status of an identity authentication scenario provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of another business state of an identity authentication scenario provided in an embodiment of the present application;
[0024] Figure 5A schematic diagram of an interface testing device provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions 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 this specification, not all of the embodiments. Based on the embodiments of 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] This specification provides an interface testing method embodiment:
[0028] In some business scenarios, business processing operations may be implemented by calling interfaces. Therefore, it is necessary to test the interfaces called during business processing to ensure that the business can proceed smoothly.
[0029] Taking the identity authentication scenario as an example, the identity authentication process involves the calling of multiple interfaces, and there are dependencies between the input and output parameters of different interfaces. Therefore, in the interface testing process for a single interface, it is often necessary to determine one or more pre-conditional interfaces that have dependencies on the input parameters of the single interface in the identity authentication process, and call the pre-conditional interfaces first, and then call the single interface. Overall, in the process of performing interface testing on each interface involved in the identity authentication process, repeated calls to interfaces may occur, which is inefficient.
[0030] When the entire identity authentication process involves a large number of interfaces and the dependencies are more complex, if the tester chooses which pre-condition interfaces to call before a single interface involved in the test and in what order to call the pre-condition interfaces based on personal experience, mistakes are inevitable, which will consume more time to eliminate the causes of interface abnormalities, delay the progress of interface testing, and reduce testing efficiency.
[0031] Therefore, in order to solve the above problems, an embodiment of the present application provides an interface testing method.
[0032] The interface testing method provided in one or more embodiments of the present specification may be applicable to an implementation environment of the interface testing method, which implementation environment includes at least an electronic device for performing interface testing, which may be a terminal or a server.
[0033] The server may be a single server, or a server cluster consisting of several servers, or one or more cloud servers in a cloud computing platform for performing interface testing. Unless otherwise specified, the interface testing method of the embodiment of the present application may be described by taking the electronic device as a server as an example.
[0034] In the implementation environment, during the process of interface testing, the server first responds to the interface test instruction for the target business scenario, obtains the interface test configuration information of the target business scenario, and the interface test configuration information includes the test combination of the target business scenario, and a test combination includes input parameter data under a business state and the interface required to be called when the business is executed under the business state; then, the test combination matching the interface test instruction is determined from the test combination, and the interface to be tested in the matching test combination is determined; then, the interface to be tested is called to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; finally, according to the output parameter data and the preset test result, the interface test result for the interface test instruction is generated. In this way, on the one hand, by binding the business state, input parameter data and the interface to be called, it is conducive to reusing the same input parameter data in the test process of the same business state of multiple interfaces, and compared with configuring the input parameter data under multiple business states for each interface, the data preparation workload is reduced. On the other hand, considering that when performing interface testing on a single interface, different input parameter data may be required to test the performance of the single interface under different business states respectively, by determining a test combination that matches the interface test instructions from the test combination to perform interface testing, it is beneficial to complete interface testing of multiple interfaces under the same business state at one time. Compared with performing interface testing on a single interface under multiple business states separately, the same testing purpose can be achieved while reducing the number of tests, thereby improving testing efficiency.
[0035] Figure 1 A processing flow chart of an interface testing method provided in an embodiment of the present application. Figure 1 The interface testing method provided in this embodiment specifically includes steps S102 to S108:
[0036] Step S102, in response to the interface test instruction for the target business scenario, obtain the interface test configuration information of the target business scenario, the interface test configuration information includes the test combination of the target business scenario, a test combination includes input parameter data under a business state and the interface required to be called when the business is executed under the business state.
[0037] The target business scenario can be any business scenario that needs to call an interface during the execution of a business, such as identity authentication scenarios, permission authorization scenarios, etc. Business refers to the transactions that need to be processed in various industries. For example, in a shopping scenario, the business may include ordering, payment, user login, etc. Specifically, during the execution of a business, services may be provided to users, or physical or virtual goods may be provided to users, etc.
[0038] The interface test instruction may be an instruction for performing an interface test on a service state in a target service scenario. The interface test instruction may include some instruction information on how to perform an interface test or on which service state to perform an interface test. For example, the interface test instruction may include a service state identifier, or an identifier of a test interface to be tested, etc. In an actual service scenario, an interface test instruction carrying different information may be generated according to the test requirements. This is not limited in the embodiments of the present application.
[0039] For each business scenario, the interface test configuration information required for the interface test of the business scenario can be pre-generated. The interface test configuration information includes the test combination of the target business scenario. The number of test combinations can be determined by the number of business states in the target business scenario. For example, taking the target business scenario as an identity authentication scenario, the business state can include an authentication success state and an authentication failure state. At this time, the test combination includes a test combination for the authentication success state and a test combination for the authentication failure state. For another example, taking the target business scenario as a transaction scenario, the business state includes a transaction success state, a transaction failure state, and a transaction in progress state. Then the test combination includes a test combination corresponding to the transaction success state, a test combination corresponding to the transaction failure state, and a test combination corresponding to the transaction in progress.
[0040] The test combination of the target business scenario may be pre-added to the interface test configuration information of the target business scenario. The business status may be one or more status information of the target business scenario pre-configured based on historical data of the target business scenario.
[0041] A test combination includes input parameter data under a business state and the interface that needs to be called when the business is executed under the business state. Input parameter data refers to the input data of the interface that needs to be called when the business is executed. Taking the target business scenario as an identity authentication scenario as an example, the input parameter data can be the user identity information required in the identity authentication process. For example, name, user ID number, identity credentials in image form, and so on. In addition, considering that the purpose of interface testing is to find abnormal interfaces to be tested rather than to obtain user authentication results, pre-recorded facial video data can also be added to the input parameter data as user information.
[0042] In the target business scenario, the number of interfaces that need to be called during the business execution process may be one or more. For example, the target business scenario may be an identity authentication scenario, in which a comparison interface needs to be called during the execution of the identity authentication business to perform identity authentication processing.
[0043] It should be noted that in different business scenarios, the information about test combinations, business status, and input parameter data may be different. The following takes the target business scenarios including identity authentication scenarios and transaction scenarios as examples to introduce the test combinations, business status, and input parameter data in different business scenarios.
[0044] When the target business scenario is an identity authentication scenario, the interface test configuration information of the identity authentication scenario includes a test combination of the identity authentication scenario, and a test combination includes user information in a target authentication state and an interface required to be called during identity authentication in the target authentication state. The target authentication state may include any one of an authentication success state and an authentication failure state.
[0045] When the target business scenario is a transaction scenario, the interface test configuration information of the transaction scenario includes a test combination of the transaction scenario, and a test combination includes input data under a transaction state and an interface to be called when executing transaction processing under the transaction state. The transaction state may include transaction success, transaction failure, transaction cancellation, and transaction in progress, etc.
[0046] Based on the same concept, other business scenarios can refer to the corresponding descriptions of the identity authentication scenario and / or transaction scenario, and this application will not go into details here.
[0047] Identity authentication refers to the confirmation of the user's identity through certain means. In the identity authentication scenario, identity authentication can be performed through an identity authentication method based on a shared key, an identity authentication method based on a biological feature, an identity authentication method based on a public key encryption algorithm, etc. The embodiments of this specification do not impose special restrictions on the identity authentication method used in the identity authentication scenario.
[0048] In the process of configuring the business status, the basis for dividing the business status can be the input parameter data of the interface that needs to be called under the business status. There is a corresponding relationship between the business status and the input parameter data.
[0049] For example, N business states are pre-configured for the target business scenario, where N is an integer greater than 1. In the N business states, the input parameter data of the interface required to be called when the business is executed in each business state is different. The input parameter data of the interface required to be called when the business is executed in the first business state is input parameter data 1; the input parameter data of the interface required to be called when the business is executed in the second business state is input parameter data 2; ...; the input parameter data of the interface required to be called when the business is executed in the Nth business state is input parameter data N. Input parameter data 1 is not suitable for interface testing under the second to Nth business states, input parameter data 2 is not suitable for interface testing under the first, third to Nth business states, ..., input parameter data N is not suitable for interface testing under the first to N-1th business states.
[0050] For another example, user information in a successful authentication state is not applicable to interface testing in a failed authentication state, and vice versa.
[0051] When there is no abnormality in the interfaces participating in the interface test, the interface test result corresponding to the input parameter data under a business state is the same as the preset test result under the business state.
[0052] In the same target business scenario, in multiple business states, the interfaces required to be called when executing the business in each business state may be the same or different.
[0053] For example, in the first business scenario, when executing a business in business state 1, interface 1 and interface 2 need to be called, and when executing a business in business state 2, interface 1 and interface 2 need to be called.
[0054] In the second business scenario, when executing the business in business state 3, interface 1 and interface 2 need to be called, and when executing the business in business state 4, interface 2, interface 3, and interface 4 need to be called.
[0055] In this specification, ordinal numbers such as "first" and "second" are used to distinguish different distinguishing technical features and have no actual meaning, so they will not be elaborated below.
[0056] The following can be combined Figure 2 An example of an identity authentication scenario is given below. Figure 2 An identity authentication process flow chart provided for an embodiment of the present application.
[0057] like Figure 2 As shown, step S202 receives the name and identity identification number entered by the user on the front-end page, and calls the two-factor authentication interface.
[0058] The front end can be a user terminal. The front end page is the page displayed by the user terminal.
[0059] Users who need identity authentication may include user 1, user 2, user 3, and so on.
[0060] For each of the multiple users who have identity authentication requirements, the name and identity identification number input by the user on the front-end page are received.
[0061] In addition, it is also possible to receive an identity certificate in the form of an image uploaded by the user on the front-end page, and extract one or more user information from the identity certificate, such as the user's name, identification number, avatar, validity period of the identity certificate, and so on.
[0062] The two-factor authentication interface is used to trigger identity authentication through face recognition when receiving a specified type of user information. The specified type of user information can be a name and an ID number, or one or more types of user information extracted from an identity certificate.
[0063] Step S204, calling up the face recognition page.
[0064] The front end displays the face recognition page. The face recognition page is used to assist users in face recognition.
[0065] Step S206: The user performs face recognition as prompted by the page.
[0066] The face recognition page can display real-time generated action prompt information, such as blinking, turning the head to the left, etc. The user's face is facing the camera component of the user terminal, and the action is performed according to the action prompt information. The camera component of the user terminal collects the user's facial video data during the user's action, and the facial video data is used for face recognition.
[0067] Step S208, divert to the specified comparison method.
[0068] The diversion interface is called to determine the target comparison method among the candidate comparison methods, and then the facial video data is diverted to the target comparison method.
[0069] In addition, the diversion interface can also be called to associate the user and target comparison method and store them in the specified storage table.
[0070] The number of candidate comparison methods may be one or more. The multiple candidate comparison methods may be provided by different third parties, wherein each candidate comparison method may be implemented using the comparison technology provided by the third party corresponding to the candidate comparison method.
[0071] Step S210, obtaining a key.
[0072] Call the key acquisition interface to obtain key information.
[0073] The key information may include a first key that proves that the face recognition execution end has the authority to obtain pre-stored user information for face comparison with facial video data, and may also include a second key that proves that the face recognition execution end has the authority to call the comparison interface to perform comparison processing using a target comparison method, and so on.
[0074] In addition, the key interface can be called to associate user and key information acquisition records and store them in the specified storage table.
[0075] Step S212, obtaining the face comparison result through the key.
[0076] The key information and facial video data are used as input data of the comparison interface, and the comparison interface is called. When the key information passes the verification, the comparison is performed based on the facial video data and the pre-stored user information to obtain the face comparison result, which is used as the output data of the comparison interface.
[0077] During specific implementation, the key information, the avatar in the identity credential, and the facial video data can also be used as input data of the comparison interface to call the comparison interface. When the key information passes the verification, the comparison is performed based on the facial video data and the avatar in the identity credential, and the comparison is performed based on the facial video data and the pre-stored user information to obtain the face comparison result.
[0078] In the case where the face in the facial video data and the head portrait in the identity certificate do not belong to the same person, the face recognition can be terminated and the identity authentication is determined to have failed. In the case where the face in the facial video data and the head portrait in the identity certificate belong to the same person, the facial video data and the pre-stored user information are continued to be compared to obtain a face comparison result.
[0079] Before the comparison process is performed, the face image in the pre-stored user information can be obtained by querying the user's identity identification number. In addition, the comparison interface can be called to associate the user and the face comparison result and store it in a specified storage table.
[0080] Step S214: Identity authentication succeeds or fails.
[0081] If the face comparison result indicates that the face in the facial video data and the face image in the pre-stored user information belong to the same person, the identity authentication succeeds. If the face comparison result indicates that the face in the facial video data and the face image in the pre-stored user information belong to different people, the identity authentication fails.
[0082] In addition, the query interface can be called to query the storage table to obtain one or more of the user's target comparison method, key information acquisition record, and comparison result.
[0083] The number of query interfaces may be one or more. In the case where the number of query interfaces is multiple, each query interface may have corresponding index information. For example, query interface 1 may be used to query one or more of a user's target comparison method, key information acquisition record, and comparison result based on a name. Query interface 2 may be used to query one or more of a user's target comparison method, key information acquisition record, and comparison result based on an identity identification number.
[0084] In the identity authentication scenario, the identity authentication results in the historical data are used as the basis for division, and multiple business states can be pre-configured for the identity authentication scenario: authentication success state and authentication failure state.
[0085] In the identity authentication scenario, the identity authentication result in the authentication success state is authentication success. In the identity authentication scenario, the identity authentication result in the authentication failure state is authentication failure.
[0086] The following can be combined Figure 3 and Figure 4 The business status is illustrated.
[0087] Figure 3 A schematic diagram of a business status of an identity authentication scenario provided in an embodiment of the present application.
[0088] like Figure 3 As shown, one service status of the identity authentication scenario may be a successful authentication status. The interface testing method provided in the embodiment of this specification may be used for example Figure 3 In the identity authentication scenario shown.
[0089] When authentication is successful, the test data is bound to a successful user and the entire process begins.
[0090] The test data may be data required for interface testing, for example, one or more interfaces to be tested that participate in the interface testing in a successfully authenticated state, a calling sequence of one or more interfaces to be tested, and the like.
[0091] A successful user can be: a user whose identity authentication result is successfully authenticated if there is no abnormality in the interface. Taking face recognition as an example, during the identity authentication process, a successful user, on the one hand, provides real and valid user information such as his / her name and user ID number, and on the other hand, performs face recognition according to the prompts on the face recognition page so that the front end can collect facial video data.
[0092] like Figure 3 As shown, in the authentication success state, the interfaces to be tested participating in the interface test may include: a shunt interface 302, a comparison interface 304, and a query interface.
[0093] During the interface test, the diversion interface 302 is called first, then the comparison interface 304 is called, and finally the query interface is called.
[0094] In the process of calling the diversion interface 302, after the successful user is diverted to the target comparison method, the successful user and the target comparison method may be sent to the storage 306 and stored in association.
[0095] In the process of calling the comparison interface 304 , after the user information of the successful user is compared with the pre-stored user information to obtain a comparison result, the successful user and the comparison result may be sent to the storage 306 and stored in association.
[0096] In the authentication success state, the expected result of the query interface is success, which means that the identity authentication result obtained by calling the query interface is expected to be authentication success. The identity authentication result can be determined by the comparison result.
[0097] The expected result of the verification query interface is success, which can be achieved by calling the query interface to obtain the identity authentication result, and the identity authentication result is success, which is consistent with the expectation.
[0098] By verifying that the expected result of the query interface is successful, it can be determined that there is no abnormality in the interface to be tested when the authentication is successful.
[0099] If the query interface is called to obtain the authentication result, the authentication result is authentication failure, which is inconsistent with expectations, indicating that there is a problem with the interface to be tested and further analysis is required.
[0100] Figure 4 A schematic diagram of another business status of an identity authentication scenario provided in an embodiment of the present application.
[0101] like Figure 4 As shown, another business state of the identity authentication scenario may be an authentication failure state. The interface test method provided in the embodiment of this specification can be used for the following Figure 4 In the identity authentication scenario shown.
[0102] In the case of authentication failure, the test data is bound to a failed user and the entire process is started.
[0103] The test data may be data required for interface testing, for example, one or more interfaces to be tested that participate in the interface testing in an authentication failure state, a calling sequence of one or more interfaces to be tested, and the like.
[0104] A failed user may be a user whose identity authentication result is an authentication failure when there is no abnormality in the interface. Taking face recognition as an example, for a failed user, the name and user ID number provided by the user during the identity authentication process may not be authentic and valid. For example, the name and user ID number provided by the failed user belong to another person.
[0105] like Figure 4 As shown, in the authentication failure state, the interfaces to be tested participating in the interface test may include: a shunt interface 402, a comparison interface 404, and a query interface.
[0106] During the interface testing process, the diversion interface 402 is called first, then the comparison interface 404 is called, and finally the query interface is called.
[0107] In the process of calling the diversion interface 402, after the failed users are diverted to the target comparison mode, the failed users and the target comparison mode are sent to the storage 406 and stored in association.
[0108] In the process of calling the comparison interface 404 , after the user information of the failed user is compared with the pre-stored user information to obtain a comparison result, the failed user and the comparison result may be sent to the storage 406 and stored in association.
[0109] In the authentication failure state, the expected result of the query interface is failure, which may be that the identity authentication result obtained by calling the query interface is expected to be authentication failure. The identity authentication result may be determined by the comparison result.
[0110] The expected result of the verification query interface is failure. The query interface can be called to obtain the identity authentication result, and the identity authentication result is failure, which is consistent with the expectation.
[0111] By verifying that the expected result of the query interface is failure, it can be determined that there is no abnormality in the interface to be tested in the authentication failure state.
[0112] If the query interface is called to obtain the authentication result, the authentication result is successful, which is inconsistent with expectations, indicating that there is a problem with the interface to be tested and further analysis is required.
[0113] Step S104, determining a test combination that matches the interface test instruction from the test combination, and determining the interface to be tested in the matching test combination.
[0114] The interface test instruction can be used to instruct to perform an interface test in a business state of a target business scenario. Determining a test combination that matches the interface test instruction from the test combination can be to determine, from multiple test combinations, a test combination corresponding to the business state indicated by the interface test instruction as the test combination that matches the interface test instruction.
[0115] Determining the interface to be tested in the matching test combination may include reading one or more interfaces to be tested from the test combination that matches the interface test instruction.
[0116] In the case where the test combination includes multiple interfaces to be tested, the arrangement order of the multiple interfaces to be tested in the test combination may reflect the calling order of the multiple interfaces to be tested.
[0117] In specific implementation, a test combination in the interface test configuration information can be represented by a target array, which can include interface identification information of multiple interfaces to be tested. Furthermore, the calling order of the multiple interfaces to be tested can be determined by the arrangement order of the multiple interfaces to be tested in the target array.
[0118] For example, the target array includes (user 1, interface 1, interface 2, interface 3, interface 4), and the interfaces to be tested read from the target array include: "interface 1, interface 2, interface 3, interface 4".
[0119] According to the arrangement order of the multiple interfaces to be tested in the target array, it can be determined that the calling order of the multiple interfaces to be tested is, from front to back, interface 1, interface 2, interface 3, and interface 4. That is, interface 1 is called first, then interface 2, then interface 3, and finally interface 4.
[0120] In a specific implementation, an interface test instruction includes a scenario identifier and a test combination identifier; in response to an interface test instruction for a target business scenario, interface test configuration information of the target business scenario is obtained, including: obtaining a test file of the target business scenario according to the scenario identifier; parsing the target annotation information in the test file through a reflection mechanism to obtain the interface test configuration information of the target business scenario; determining a test combination that matches the interface test instruction from the test combination, including: determining a test combination corresponding to the test combination identifier in the test combination of the target business scenario, and using the test combination corresponding to the test combination identifier as the test combination that matches the interface test instruction.
[0121] Each business scenario may have a unique corresponding scenario identifier. The scenario identifier carried by the interface test instruction may be the scenario identifier of the target business scenario.
[0122] In one or more test combinations of the target business scenario, each test combination may have a unique corresponding test combination identifier. The test combination identifier carried by the interface test instruction may be a test combination identifier of a test combination that needs to participate in the interface test specified by the interface test instruction.
[0123] According to the scenario identifier, the test file of the target business scenario is obtained. This can be done by performing a query in a pre-configured correspondence table between business scenario identifiers and test files according to the scenario identifier, obtaining the test file corresponding to the scenario identifier of the target business scenario, and using the test file as the test file of the target business scenario.
[0124] The target annotation information in the test file is parsed through the reflection mechanism to obtain the interface test configuration information of the target business scenario. The target annotation information in the test file is parsed through the reflection mechanism to obtain the target array, and the target array is used as the interface test configuration information of the target business scenario.
[0125] Exemplarily, the target annotation information may be a @DataProvider annotation.
[0126] @DataProvider annotation is an important feature in the TestNG framework, which is used to provide data to test methods. TestNG (Test Next Generation) is an open source automated testing framework. Before explaining the principle of @DataProvider annotation, let's briefly explain the principle of @Test annotation.
[0127] In the TestNG source code, the execution process of the @Test annotation mainly includes the following steps:
[0128] (1) Parsing annotations: When TestNG runs, it scans the methods in the test class and parses the methods with @Test annotations. TestNG uses reflection to parse annotations and obtain relevant information.
[0129] (2) Build a test instance: TestNG will create a test instance for each method annotated with @Test. The test instance includes information such as the tested class, method, and parameters. This process is implemented by calling TestNG's TestRunner class.
[0130] (3) Execute tests: TestNG uses TestRunner to execute tests. TestRunner calls the tested classes and methods, passes parameters, and records test results. During the execution process, TestNG can also extend the test functionality through the plug-in mechanism, such as adding additional annotations, data providers, executors, etc.
[0131] (4) Collecting test results: TestNG collects the execution results of each test method, including test pass, failure, or skip status. These results are stored in the TestNG TestResult object.
[0132] (5) Generate test reports: TestNG can generate different types of test reports as needed. The reports contain information such as test results, test suites, test classes, and test methods.
[0133] The parsing process of the @DataProvider annotation exists in the above-mentioned (1) step of parsing the annotation.
[0134] First, through reflection, the method modified by the Test annotation is found in the target class, so as to parse the dataProvider attribute in the @Test annotation to obtain the IDataProvidable object, that is, the name and class name referred to by the @DataProvider annotation to be parsed, in preparation for the subsequent parsing of the @DataProvider annotation.
[0135] Secondly, according to the IDataProvidable object, all methods of the target class are traversed through reflection to find the dataProvider method modified by the @DataProvider annotation, and the target class object, dataProvider method and IDataProvidable object registration information are encapsulated into the context of the @dataProvider annotation for subsequent calls.
[0136] Then, the dataProvider method is called based on the reflection context to obtain test data: a) the parameters of the target method can be obtained through the reflection mechanism; b) the target method can be called through the reflection mechanism; c) the return value can be obtained through the reflection mechanism. The target method is the aforementioned dataProvider method.
[0137] From the source code, we can see that the parameter types supported by the dataProvider method are the following types: Method, Constructor, ConstructorOrMethod, ITestContext, ITestNGMethod, etc. The return value types supported by the dataProvider method are Object[][], Object[] and Iterator.
[0138] Finally, the reflection result is traversed and injected into the parameters of the test method to execute the call.
[0139] In this implementation, the @DataProvider annotation in the test file is parsed through the reflection mechanism to obtain the target array.
[0140] Exemplarily, the target array may include a successful user, and may also include a two-factor authentication interface, a diversion interface, a key acquisition interface, a comparison interface, a query interface 1, a query interface 2, a query interface 3, and a query interface 4.
[0141] The interface test configuration information of the target business scenario may include one or more test combinations. In the case where the interface test configuration information includes multiple test combinations, the test combination corresponding to the test combination identifier can be determined from the multiple test combinations according to the test combination identifier carried by the interface test instruction, and the test combination corresponding to the test combination identifier can be used as the test combination that matches the interface test instruction.
[0142] Step S106, calling the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination.
[0143] The target input parameter data can be the variable data input to the interface to be tested during the interface test process. The output parameter data can be the variable data output by the interface to be tested during the interface test process.
[0144] The business process can be determined by the target business scenario. For example, if the target business scenario is an identity authentication scenario, the business process is an identity authentication process. If the target business scenario is a transaction scenario, the business process is a transaction process. If the target business scenario is an item rental scenario, the business process is an item rental process.
[0145] It should be noted that in this step, if there are multiple interfaces to be tested, calling the interface to be tested to perform business processing based on the target input parameter data to obtain the output parameter data does not mean that the target input parameter data is input into each of the multiple interfaces to be tested for business processing to obtain the output parameter data of each interface to be tested, but that the multiple interfaces to be tested are taken as a whole to form a set of interfaces to be tested, and the target input parameter data is input into the set of interfaces to be tested for business processing to obtain the output parameter data of the set of interfaces to be tested. The data processing logic within the set of interfaces to be tested can be determined by the calling order of the multiple interfaces to be tested.
[0146] For example, the target input parameter data is user information A, and the interfaces to be tested include: interface 1, interface 2, and interface 3. The above three interfaces can together constitute a set 1 of interfaces to be tested.
[0147] In the process of calling the interface set 1 to be tested to perform business processing on user information A and obtaining the output parameter data of the interface set 1 to be tested, the following operations are performed: call interface 1 to perform the first data processing on user information A to obtain intermediate data 1; call interface 2 to perform the second data processing on intermediate data 1 to obtain intermediate data 2; call interface 3 to perform the third data processing on intermediate data 2 to obtain the output parameter data.
[0148] Alternatively, in the process of calling the interface set 1 to be tested to perform business processing on user information A and obtaining the output parameter data of the interface set 1 to be tested, perform the following operations: call interface 1 to perform the first data processing on user information A to obtain intermediate data 1; call interface 2 to perform the second data processing on user information A to obtain intermediate data 2; call interface 3 to perform the third data processing on intermediate data 1 and intermediate data 2 to obtain the output parameter data.
[0149] In a specific implementation method, the target business scenario is an identity authentication scenario, the business status in the test combination that matches the interface test instruction is the target authentication status, and the target authentication status is one of an authentication success status and an authentication failure status; after determining the test combination that matches the interface test instruction from the test combination, the interface testing method also includes: determining the calling order of the interface to be tested in the test combination that matches the interface test instruction; calling the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data, including: calling the interface to be tested in the calling order to perform identity authentication processing based on the target input parameter data to obtain output parameter data under the target authentication state.
[0150] In the test combination matching the interface test instructions, the arrangement order of the interfaces to be tested can reflect the calling order of each interface to be tested.
[0151] For example, the permutation combination includes: interface 1, interface 2, interface 3, interface 4. The calling order of each interface to be tested can be determined by the arrangement order of each interface to be tested in the permutation combination, that is, interface 1 is called first, then interface 2, then interface 3, and finally interface 4.
[0152] In the identity authentication scenario, the identity authentication result in the authentication success state is authentication success. In the identity authentication scenario, the identity authentication result in the authentication failure state is authentication failure.
[0153] During specific implementation, the interface to be tested is called in the calling order to perform identity authentication based on the target input parameter data to obtain the output parameter data under the target authentication state. The comparison interface can be called to perform comparison processing based on the target input parameter data and pre-stored user information to obtain the comparison result, and the query interface is called to query the comparison result to obtain the output parameter data under the target authentication state.
[0154] Call the interface to be tested in the calling order to perform identity authentication based on the target input parameter data to obtain the output parameter data under the target authentication state. Alternatively, call the diversion interface to perform diversion processing on the target input parameter data to obtain the diversion result. Call the comparison interface to perform comparison processing based on the diversion result, the target input parameter data and the pre-stored user information to obtain the comparison result. Call the query interface to query the comparison result to obtain the output parameter data under the target authentication state.
[0155] In the target business scenario, if an interface test is performed on a single interface, the input and output parameters of a single interface may be dependent on other interfaces. For example, in the identity authentication scenario, the identity authentication process involves a diversion interface, a comparison interface, and multiple query interfaces, and each query interface queries the comparison results from different dimensions. The input parameters of the comparison interface depend on the output parameters of the diversion interface, and the input parameters of each query interface depend on the output parameters of the comparison interface. When testing query interface 1, query interface 2, query interface 3, etc., considering that different operations need to be taken in the case of successful authentication and failed authentication in the identity authentication scenario, it is necessary to test whether a single query interface has exceptions in both cases of successful authentication and failed authentication. Therefore, the test of a single interface requires the user information of successful users and the user information of failed users, and the comparison interface has to be called multiple times.
[0156] For example, first, when testing query interface 1: call the comparison interface to generate the comparison result of successful user 1, and call the comparison interface to generate the comparison result of failed user 2; then, when testing query interface 2: call the comparison interface to generate the comparison result of successful user 3, and call the comparison interface to generate the comparison result of failed user 4; then, when testing query interface 3: call the comparison interface to generate the comparison result of successful user 5, and call the comparison interface to generate the comparison result of failed user 6; when testing query interface 4: call the comparison interface to generate the comparison result of successful user 7, and call the comparison interface to generate the comparison result of failed user 8... In this way, in order to complete the interface test of N query interfaces, 2N interface tests need to be performed, N is an integer greater than or equal to 1, and the test efficiency is low.
[0157] In this implementation, the service state in the test combination that matches the interface test instruction is the target authentication state, and the target authentication state is one of an authentication success state and an authentication failure state.
[0158] When the target authentication state is the authentication success state, determine the test combination that matches the interface test instruction from the test combination, which includes the target input parameter data in the authentication success state and the interface required to be called when the business is executed in the authentication success state, such as the diversion interface, the comparison interface, and multiple query interfaces. Determine the calling order of the interfaces to be tested in the test combination that matches the interface test instruction; call the interfaces to be tested in the calling order to perform identity authentication based on the target input parameter data, and obtain the output parameter data in the authentication success state.
[0159] For example, the target input data is the user identity information of successful user 1. During the identity authentication process, a comparison interface can be called once to generate the comparison interface of the successful user 1, and each query interface can be called separately to query the comparison result of the successful user 1.
[0160] When the target authentication state is an authentication failure state, determine a test combination that matches the interface test instruction from the test combination, which includes the target input parameter data in the authentication failure state and the interface required to be called when executing the business in the authentication failure state, such as a diversion interface, a comparison interface, and multiple query interfaces. Determine the calling order of the interfaces to be tested in the test combination that matches the interface test instruction; call the interfaces to be tested in the calling order to perform identity authentication based on the target input parameter data, and obtain the output parameter data in the authentication failure state.
[0161] For example, the target input data is the user identity information of failed user 2. During the identity authentication process, a comparison interface can be called once to generate a comparison interface for the successful user 1, and each query interface can be called separately to query the comparison result of the failed user 2.
[0162] Therefore, in the process of completing the interface testing of multiple query interfaces in the identity authentication scenario, no matter how many query interfaces there are, only two interface tests, one in the authentication success state and the other in the authentication failure state, are needed to determine whether each query interface is abnormal. Compared with interface testing for a single interface separately, the number of tests is reduced while achieving the same test purpose, which significantly improves the test efficiency. The more query interfaces there are, the more obvious the improvement in test efficiency.
[0163] For example, in an identity authentication scenario, there are four query interfaces. If interface tests are performed on each interface separately, a total of eight interface tests need to be performed. If the interface testing method provided in an embodiment of the present application is adopted, only two interface tests need to be performed to achieve the same test effect.
[0164] The above identity authentication scenario is an exemplary target business scenario. Due to similar technical concepts, other business scenarios can refer to the corresponding description of the identity authentication scenario.
[0165] In a specific implementation, the interface to be tested includes a diversion interface, a comparison interface and a query interface, and the calling order indicates that the diversion interface is located before the comparison interface, and the comparison interface is located before the query interface, and the target input parameter data includes user information; the interface to be tested is called in the calling order to perform identity authentication processing based on the target input parameter data to obtain output parameter data under the target authentication state, including: calling the diversion interface, determining the target comparison method suitable for user information among the candidate comparison methods, obtaining the first diversion result of the user information being diverted to the target comparison method and storing it in a preset storage area; the probability that the user information is diverted to each candidate comparison method is determined by the diversion ratio of the candidate comparison method; when the first diversion result indicates that the diversion is successful, calling the comparison interface to compare the user information and the pre-stored user information according to the target comparison method, obtaining the comparison result and storing it in the preset storage area; calling the query interface to obtain the first diversion result and the comparison result from the preset storage area according to the user information, and generating the output parameter data according to the first diversion result and the comparison result.
[0166] There may be multiple interfaces to be tested. In this implementation, the interfaces to be tested include a shunt interface, a comparison interface, and a query interface.
[0167] The diversion interface is called to determine the target comparison method suitable for the user information from the candidate comparison methods; the probability of the user information being diverted to each candidate comparison method is determined by the diversion ratio of the candidate comparison method.
[0168] The number of candidate alignment methods may be one or more.
[0169] When the number of candidate comparison methods is one, the diversion interface is called to determine the candidate comparison method as a target comparison method suitable for the user information.
[0170] When there are multiple candidate comparison methods, a diversion interface is called to determine a target comparison method suitable for the user information from among the multiple candidate comparison methods.
[0171] The diversion ratio of candidate comparison methods means that when there are multiple candidate comparison methods, each candidate comparison method has a pre-configured ratio. When the diversion interface receives any input parameter data, it will randomly determine the target comparison method corresponding to the input parameter data based on the ratio of each candidate comparison method.
[0172] For example, the diversion ratio of comparison method 1 is 30%, and the diversion ratio of comparison method 2 is 70%. When receiving input data 1, the diversion interface randomly determines the target comparison method of the input data 1. The probability that the target comparison method is comparison method 1 is 30%, and the probability that the target comparison method is comparison method 2 is 70%.
[0173] For example, the split ratio of the candidate comparison method can be configured in a JSON file, and the JSON file is as follows:
[0174]
[0175]
[0176] In the above JSON file, data is used to represent the configuration information of the candidate comparison method, which includes multiple candidate comparison methods and the diversion ratio of the candidate comparison methods. back is used to represent the configuration information of the backup comparison method. In addition, although not shown in the above example, back can support the configuration of multiple backup comparison methods and the diversion ratio of the backup comparison methods. tech is used to identify the comparison method, and weight is used to represent the diversion ratio.
[0177] Multiple candidate comparison methods can be provided by different third parties. Before performing identity authentication, you can specify which candidate comparison method provided by a third party is used for identity authentication. By calling the diversion interface and determining the target comparison method suitable for user information in the candidate comparison methods, different user information can be diverted to the comparison methods provided by different third parties. Each third party can be configured with a corresponding backup comparison method. The purpose is that if the current diversion to the target comparison method fails and identity authentication cannot be performed through the target comparison method, it can be switched to the backup comparison method to continue identity authentication.
[0178] A first diversion result of the user information being diverted to the target comparison mode is obtained. The first diversion result may indicate that the user information is successfully diverted to the target comparison mode, or the first diversion result may indicate that the user information is failed to be diverted to the target comparison mode.
[0179] If the first diversion result indicates that the user information is successfully diverted to the target comparison method, it means that the subsequent steps of calling the comparison interface can use the target comparison method for comparison processing. If the first diversion result indicates that the user information is failed to be diverted to the target comparison method, it means that the subsequent steps of calling the comparison interface cannot use the target comparison method for comparison processing.
[0180] The diversion interface is called to send the user information and the first diversion result to a preset storage area and store them in association.
[0181] The preset storage area may be a pre-designated storage area, which may be used to store data generated during an interface test in a business state in a target business scenario.
[0182] The first diversion result indicates that the diversion is successful, that is, the first diversion result indicates that the user information is successfully diverted to the target comparison method.
[0183] In a specific implementation, the user information may include an identity identification number and pre-recorded facial video data. The comparison interface is called, and the user information and the pre-stored user information are compared in a target comparison manner to obtain a comparison result, which may be to query the pre-stored user information according to the identity identification number to obtain a facial image of the target user, and to compare the pre-recorded facial video data and the facial image of the target user in a target comparison manner to obtain a comparison result.
[0184] In a specific implementation, the user information may include an identity identification number, a headshot in an identity certificate, and pre-recorded facial video data. The comparison interface is called to compare the user information with the pre-stored user information in a target comparison manner to obtain a comparison result, which may be to compare the headshot in the identity certificate with the pre-recorded facial video data in a target comparison manner, and when it is determined that the headshot in the identity certificate and the pre-recorded facial video data belong to the same person, then compare the pre-recorded facial video data with the facial image of the target user in the pre-stored user information in a target comparison manner to obtain a comparison result.
[0185] In addition, there can be multiple target comparison methods, so "comparing the avatar in the identity credential with the pre-recorded facial video data" and "comparing the pre-recorded facial video data with the facial image of the target user" can respectively adopt two different target comparison methods.
[0186] The comparison interface is called to send the user information and the comparison result to the preset storage area and store them in association.
[0187] The query interface is called to query the preset storage area according to the user information to obtain the first diversion result and the comparison result, and the parameter data is generated according to the first diversion result and the comparison result.
[0188] The first diversion result is stored in association with the user information in the preset storage area, and the comparison result is stored in association with the user information in the preset storage area. Therefore, by calling the query interface, the first diversion result and the comparison result can be queried from the preset storage area according to the user information.
[0189] Generating the output parameter data according to the first diversion result and the comparison result may be generating an identity authentication result according to the first diversion result and the comparison result, and adding the identity authentication result to the output parameter data.
[0190] When the first diversion result indicates that the diversion is successful, and the comparison result indicates that the pre-recorded facial video data and the facial image of the target user in the pre-stored user information belong to the same person, the identity authentication result can be determined to be successful.
[0191] When the first diversion result indicates that the diversion is successful, and the comparison result indicates that the pre-recorded facial video data and the facial image of the target user in the pre-stored user information belong to different people, it can be determined that the identity authentication result is an authentication failure.
[0192] When the identity authentication result is an authentication failure, analysis and processing can be performed based on the first diversion result and the comparison result to locate the cause of the failure, and the failure cause can be added to the output parameter data.
[0193] In a specific implementation, after obtaining a first diversion result in which user information is diverted to a target comparison method and storing it in a preset storage area, the interface testing method further includes: when the first diversion result indicates a diversion failure, obtaining a second diversion result in which user information is diverted to a backup comparison method of the target comparison method and storing it in a preset storage area; when the second diversion result indicates a diversion failure, determining to skip calling the comparison interface, calling a query interface to obtain the first diversion result and the second diversion result from the preset storage area based on the user information, and generating parameter data based on the first diversion result and the second diversion result.
[0194] Each candidate comparison method may have one or more corresponding backup comparison methods. For a candidate comparison method, if there are multiple backup comparison methods for the candidate comparison method, the diversion ratio of the backup comparison method may be pre-configured, and the diversion ratio of the backup comparison method may refer to the corresponding description part of the diversion ratio of the candidate comparison method.
[0195] A second diversion result of diverting the user information to the backup comparison mode is obtained. The second diversion result may indicate that the user information is successfully diverted to the backup comparison mode, or the second diversion result may indicate that the user information is failed to be diverted to the backup comparison mode.
[0196] If the second diversion result indicates that the user information is successfully diverted to the backup comparison method, it means that the subsequent steps of calling the comparison interface can use the backup comparison method for comparison processing. If the second diversion result indicates that the user information is failed to be diverted to the backup comparison method, it means that the subsequent steps of calling the comparison interface cannot use the backup comparison method for comparison processing.
[0197] The diversion interface is called to send the user information and the second diversion result to a preset storage area and store them in association.
[0198] When the second diversion result indicates a diversion failure, it means that the comparison interface can use neither the target comparison method nor the backup comparison method. Therefore, it can be determined to skip calling the comparison interface, call the query interface, and obtain the first diversion result and the second diversion result from the preset storage area according to the user information, and generate parameter data according to the first diversion result and the second diversion result.
[0199] When the first diversion result indicates a diversion failure and the second diversion result indicates a diversion failure, it can be determined that the identity authentication result is that the authentication cannot be performed. It should be emphasized that the identity authentication result is different from the authentication failure. The authentication failure is due to inconsistent comparison results. However, in this implementation, since both the target comparison method and the backup comparison method cannot be used normally, the comparison processing cannot be performed to obtain the comparison result.
[0200] In a specific implementation, the query interface includes multiple query sub-interfaces, each query sub-interface has an index information; calling the query interface to query from a preset storage area based on user information to obtain a first diversion result and a comparison result, including: for each query sub-interface, calling the query sub-interface to extract the index information of the query sub-interface from the user information; performing query processing in the preset storage area according to the index information to obtain a first diversion result and a comparison result.
[0201] Whether each query sub-interface is abnormal is independent of each other.
[0202] Each query sub-interface has an index information corresponding to the query sub-interface. Different index information reflects user characteristics of different dimensions. For example, the index information of query sub-interface 1 is the name, the index information of query sub-interface 2 is the identity identification number, and so on.
[0203] Index information is a separate, physical storage structure that sorts the values of one or more columns in a data table. It is a collection of values of one or more columns in a table and a corresponding list of logical pointers to the data pages that physically identify these values in the table. The role of an index is equivalent to the catalog of a book, and you can quickly find the required content based on the page numbers in the catalog.
[0204] Different query sub-interfaces have different index information, which takes into account the user experience of users who perform data query operations. For example, user 1 only remembers the index value of his index information in the first dimension, and needs to use the query sub-interface 1 corresponding to the index information of the first dimension when performing a query. When user 2 performs a data query operation, in order to improve the query efficiency, the index value of the index information of the second dimension and the index value of the index information of the third dimension are provided at the same time, that is, when user 2 performs a query, he needs to use the query sub-interface 2 corresponding to the index information of the second dimension and the query sub-interface 3 corresponding to the index information of the third dimension.
[0205] The user information is stored in association with the first diversion result in the preset storage area, and the user information is stored in association with the comparison result. For each query sub-interface, the query sub-interface is called to extract the index information corresponding to the query sub-interface from the user information; query processing is performed in the preset storage area according to the index information to obtain the first diversion result and the comparison result.
[0206] Step S108, generating an interface test result for the interface test instruction according to the output parameter data and the preset test result.
[0207] According to the output parameter data and the preset test results, an interface test result of the interface to be tested under a business state of the target business scenario can be generated, and the interface test result can be used as the interface test result for the interface test instruction.
[0208] Considering that in some business scenarios, the number of business states is much smaller than the number of interfaces to be tested. By implementing the interface testing method provided in the embodiment of the present application, an interface test is performed in each business state to obtain interface test results of multiple interfaces to be tested in different business states. Compared with performing interface testing on a single interface, the total number of interface tests can be reduced while achieving the same test purpose, thereby improving test efficiency.
[0209] For example, in an identity authentication scenario, the interfaces to be tested include a diversion interface, a comparison interface, and 10 query interfaces, a total of 12. The identity authentication scenario has two business states: authentication success state and authentication failure state. By implementing the interface testing method provided in the embodiment of the present application, it is only necessary to perform one interface test in the authentication success state and one interface test in the authentication failure state, a total of 2 interface tests, to obtain the interface test results of the 12 interfaces to be tested. If an interface test is performed on a single interface in the identity authentication scenario, a total of 24 interface tests need to be performed to test each interface to be tested, which is much greater than 2 times.
[0210] In a specific implementation method, an interface test result for an interface test instruction is generated based on output parameter data and preset test results, including: comparing the preset test result and the output parameter data to obtain an output reference comparison result; if the output reference comparison result indicates that the preset test result is the same as the output parameter data, then an interface test result is generated that the interface to be tested passes the interface test; if the output reference comparison result indicates that the preset test result is different from the output parameter data, then an interface test result is generated that the interface to be tested fails the interface test.
[0211] The output data may include identity authentication results.
[0212] When the test combination matched by the interface test instruction corresponds to the authentication success state, the preset test result is authentication success. If the identity authentication result in the output parameter data is authentication failure, the output reference comparison result indicates that the preset test result is different from the output parameter data; if the identity authentication result in the output parameter data is authentication success, the output reference comparison result indicates that the preset test result is the same as the output parameter data.
[0213] In the case where the test combination matched by the interface test instruction corresponds to the authentication failure state, the preset test result is authentication failure. If the identity authentication result in the output parameter data is authentication success, the output reference comparison result indicates that the preset test result is different from the output parameter data; if the identity authentication result in the output parameter data is authentication failure, the output reference comparison result indicates that the preset test result is the same as the output parameter data.
[0214] If the reference comparison result indicates that the preset test result is the same as the reference data, an interface test result is generated indicating that the interface to be tested passes the interface test. The interface test result indicating that the interface to be tested passes the interface test indicates that there is no abnormality in the interface to be tested.
[0215] If the reference comparison result indicates that the preset test result is different from the reference data, an interface test result indicating that the interface to be tested fails the interface test is generated. The interface test result indicating that the interface to be tested fails the interface test indicates that an abnormality exists in the interface to be tested.
[0216] In addition, if the reference comparison result indicates that the preset test result is different from the reference data, the reference data can also be analyzed and processed, and a test failure prompt message of the interface to be tested is generated based on the analysis result. The analysis result can include the abnormal interface to be tested and the abnormal reason of the interface to be tested.
[0217] Considering that the first diversion result and comparison result are obtained from the preset storage area by calling the query interface, the first diversion result and comparison result can reflect the phased processing results of the interface testing process. Therefore, the analysis results of the first diversion result and comparison result can be used to locate the abnormal interface to be tested and the abnormal cause of the interface to be tested among multiple interfaces to be tested.
[0218] In such Figure 1In the illustrated embodiment, first, in response to an interface test instruction for a target business scenario, the interface test configuration information of the target business scenario is obtained, the interface test configuration information includes a test combination of the target business scenario, a test combination includes input parameter data under a business state and an interface required to be called when executing the business under the business state; then, a test combination matching the interface test instruction is determined from the test combination, and the interface to be tested in the matching test combination is determined; then, the interface to be tested is called to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; finally, according to the output parameter data and the preset test result, an interface test result for the interface test instruction is generated. In this way, on the one hand, by binding the business state, the input parameter data and the interface to be called, it is conducive to reusing the same input parameter data in the test process of the same business state of multiple interfaces, and compared with configuring the input parameter data under multiple business states for each interface, the data preparation workload is reduced. On the other hand, considering that when performing interface testing on a single interface, different input parameter data may be required to test the performance of the single interface under different business states respectively, by determining a test combination that matches the interface test instructions from the test combination to perform interface testing, it is beneficial to complete interface testing of multiple interfaces under the same business state at one time. Compared with performing interface testing on a single interface under multiple business states separately, the same testing purpose can be achieved while reducing the number of tests, thereby improving testing efficiency.
[0219] An embodiment of an interface testing device provided in this specification is as follows:
[0220] In the above-mentioned embodiment, an interface testing method is provided. Based on the same technical concept, the embodiment of the present application also provides an interface testing device, which is described below in conjunction with the accompanying drawings.
[0221] Figure 5 This is a schematic diagram of an interface testing device provided in an embodiment of the present application. This embodiment provides an interface testing device 500, including:
[0222] An acquisition unit 502 is used to acquire interface test configuration information of a target business scenario in response to an interface test instruction for the target business scenario, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state;
[0223] A determination unit 504, configured to determine a test combination matching the interface test instruction from the test combination, and determine an interface to be tested in the matching test combination;
[0224] The calling unit 506 is used to call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination;
[0225] The generating unit 508 is used to generate an interface test result for the interface test instruction according to the output parameter data and the preset test result.
[0226] Optionally, the target business scenario is an identity authentication scenario, the business state in the test combination that matches the interface test instruction is a target authentication state, and the target authentication state is one of an authentication success state and an authentication failure state; after determining the test combination that matches the interface test instruction from the test combination, the determination unit 504 further performs the following steps:
[0227] Determine the calling order of the interfaces to be tested in the test combination that matches the interface test instruction;
[0228] When the calling unit 506 calls the interface to be tested to perform business processing based on the target input parameter data and obtains the output parameter data, the calling unit 506 executes the following steps:
[0229] The interface to be tested is called in the calling sequence to perform identity authentication based on the target input parameter data to obtain output parameter data in the target authentication state.
[0230] Optionally, the interface to be tested includes a shunt interface, a comparison interface and a query interface, the calling order indicates that the shunt interface is located before the comparison interface, and the comparison interface is located before the query interface, and the target input parameter data includes user information; when the calling unit 506 calls the interface to be tested according to the calling order and performs identity authentication based on the target input parameter data to obtain the output parameter data in the target authentication state, the following steps are performed:
[0231] Calling the diversion interface, determining a target comparison method suitable for the user information from the candidate comparison methods, obtaining a first diversion result of the user information being diverted to the target comparison method and storing it in a preset storage area; the probability of the user information being diverted to each of the candidate comparison methods is determined by the diversion ratio of the candidate comparison methods;
[0232] When the first diversion result indicates that the diversion is successful, calling the comparison interface to compare the user information with the pre-stored user information according to the target comparison method, obtaining the comparison result and storing it in the preset storage area;
[0233] The query interface is called to query the preset storage area according to the user information to obtain the first diversion result and the comparison result, and the output parameter data is generated according to the first diversion result and the comparison result.
[0234] Optionally, after obtaining the first diversion result of the user information being diverted to the target comparison mode and storing it in a preset storage area, the calling unit 506 further performs the following steps:
[0235] When the first diversion result indicates a diversion failure, obtaining a second diversion result of a backup comparison method in which the user information is diverted to the target comparison method and storing the result in a preset storage area;
[0236] In the case where the second diversion result indicates a diversion failure, it is determined to skip calling the comparison interface, and the query interface is called to query the first diversion result and the second diversion result from the preset storage area based on the user information, and the output parameter data is generated according to the first diversion result and the second diversion result.
[0237] Optionally, the query interface includes a plurality of query sub-interfaces, each query sub-interface having an index information; when the calling unit 506 calls the query interface to query the preset storage area based on the user information to obtain the first diversion result and the comparison result, the calling unit 506 performs the following steps:
[0238] For each query sub-interface, calling the query sub-interface to extract index information of the query sub-interface from the user information;
[0239] A query process is performed in the preset storage area according to the index information to obtain the first diversion result and the comparison result.
[0240] Optionally, the interface test instruction includes a scenario identifier and a test combination identifier; when the acquisition unit 502 acquires the interface test configuration information of the target business scenario in response to the interface test instruction for the target business scenario, the acquisition unit 502 performs the following steps:
[0241] According to the scenario identifier, obtaining a test file for the target business scenario;
[0242] Parsing the target annotation information in the test file through a reflection mechanism to obtain interface test configuration information of the target business scenario;
[0243] When determining the test combination matching the interface test instruction from the test combination, the determining unit 504 performs the following steps:
[0244] The test combination corresponding to the test combination identifier is determined in the test combination of the target business scenario, and the test combination corresponding to the test combination identifier is used as the test combination that matches the interface test instruction.
[0245] Optionally, when generating the interface test result for the interface test instruction according to the output parameter data and the preset test result, the generating unit 508 performs the following steps:
[0246] Comparing the preset test result with the reference data to obtain a reference comparison result;
[0247] If the reference comparison result indicates that the preset test result is the same as the reference data, an interface test result is generated indicating that the interface to be tested passes the interface test;
[0248] If the reference comparison result indicates that the preset test result is different from the reference data, an interface test result is generated indicating that the interface to be tested fails the interface test.
[0249] In an embodiment of the present application, the interface test device includes: an acquisition unit, which is used to respond to an interface test instruction for a target business scenario, obtain interface test configuration information of the target business scenario, the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing the business under the business state; a determination unit, which is used to determine a test combination that matches the interface test instruction from the test combination, and determine the interface to be tested in the matching test combination; a calling unit, which is used to call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; a generation unit, which is used to generate an interface test result for the interface test instruction according to the output parameter data and a preset test result. In this way, on the one hand, by binding the business state, the input parameter data and the interface to be called, it is conducive to reusing the same input parameter data in the test process of the same business state of multiple interfaces, and compared with configuring the input parameter data under multiple business states for each interface, the data preparation workload is reduced. On the other hand, considering that when performing interface testing on a single interface, different input parameter data may be required to test the performance of the single interface under different business states respectively, by determining a test combination that matches the interface test instructions from the test combination to perform interface testing, it is beneficial to complete interface testing of multiple interfaces under the same business state at one time. Compared with performing interface testing on a single interface under multiple business states separately, the same testing purpose can be achieved while reducing the number of tests, thereby improving testing efficiency.
[0250] Corresponding to the interface testing method described above, based on the same technical concept, an embodiment of the present application further provides an electronic device, which is used to execute the interface testing method provided above. Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0251] like Figure 6 As shown, the electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 601 and memory 602, and the memory 602 may store one or more storage applications or data. Among them, the memory 602 can be a temporary storage or a permanent storage. The application stored in the memory 602 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 601 can be configured to communicate with the memory 602 to execute a series of computer executable instructions in the memory 602 on the electronic device. The electronic device may also include one or more power supplies 603, one or more wired or wireless network interfaces 604, one or more input / output interfaces 605, one or more keyboards 606, etc.
[0252] In a specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs configured to be executed by one or more processors include the following computer executable instructions:
[0253] In response to an interface test instruction for a target business scenario, interface test configuration information of the target business scenario is obtained, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state;
[0254] Determine a test combination that matches the interface test instruction from the test combination, and determine the interface to be tested in the matching test combination;
[0255] Call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination;
[0256] An interface test result for the interface test instruction is generated according to the output parameter data and the preset test result.
[0257] The computer-readable storage medium provided in this embodiment is used to store computer-executable instructions. When the computer-executable instructions are executed by a processor, the following process is implemented:
[0258] In response to an interface test instruction for a target business scenario, interface test configuration information of the target business scenario is obtained, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state;
[0259] Determine a test combination that matches the interface test instruction from the test combination, and determine the interface to be tested in the matching test combination;
[0260] Call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination;
[0261] An interface test result for the interface test instruction is generated according to the output parameter data and the preset test result.
[0262] It should be noted that the embodiment of the computer-readable storage medium in this specification and the embodiment of the interface testing method in this specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the aforementioned corresponding method, and the repeated parts will not be repeated.
[0263] Another embodiment of the present disclosure further provides a computer program product, the computer program product comprising a computer program, and when the computer program is executed by a processor, the following process is implemented:
[0264] In response to an interface test instruction for a target business scenario, interface test configuration information of the target business scenario is obtained, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state;
[0265] Determine a test combination that matches the interface test instruction from the test combination, and determine the interface to be tested in the matching test combination;
[0266] Call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination;
[0267] An interface test result for the interface test instruction is generated according to the output parameter data and the preset test result.
[0268] The computer program product in the embodiment of the present disclosure can implement each process of the above-mentioned interface testing method embodiment and achieve the same effect and function, which will not be repeated here.
[0269] In an embodiment of the present application, first, in response to an interface test instruction for a target business scenario, the interface test configuration information of the target business scenario is obtained, the interface test configuration information includes a test combination of the target business scenario, a test combination includes input parameter data under a business state and an interface required to be called when executing the business under the business state; then, a test combination matching the interface test instruction is determined from the test combination, and the interface to be tested in the matching test combination is determined; then, the interface to be tested is called to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; finally, according to the output parameter data and the preset test result, an interface test result for the interface test instruction is generated. In this way, on the one hand, by binding the business state, the input parameter data and the interface to be called, it is beneficial to reuse the same input parameter data in the test process of the same business state of multiple interfaces, and compared with configuring the input parameter data under multiple business states for each interface, the data preparation workload is reduced. On the other hand, considering that when performing interface testing on a single interface, different input parameter data may be required to test the performance of the single interface under different business states respectively, by determining a test combination that matches the interface test instructions from the test combination to perform interface testing, it is beneficial to complete interface testing of multiple interfaces under the same business state at one time. Compared with performing interface testing on a single interface under multiple business states separately, the same testing purpose can be achieved while reducing the number of tests, thereby improving testing efficiency.
[0270] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0271] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may adopt the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0272] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable electronic device to produce a machine, so that the instructions executed by the processor of the computer or other programmable electronic device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0273] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable electronic device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0274] These computer program instructions may also be loaded onto a computer or other programmable electronic device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0275] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0276] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0277] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0278] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0279] Embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0280] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0281] The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.
Claims
1. An interface testing method, characterized in that: include: In response to an interface test instruction for a target business scenario, interface test configuration information of the target business scenario is obtained, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state; Determine a test combination that matches the interface test instruction from the test combination, and determine the interface to be tested in the matching test combination; Call the interface to be tested to perform business processing based on the target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; An interface test result for the interface test instruction is generated according to the output parameter data and the preset test result.
2. The method according to claim 1, characterized in that The target business scenario is an identity authentication scenario, the business state in the test combination matched by the interface test instruction is a target authentication state, and the target authentication state is one of an authentication success state and an authentication failure state; After determining the interface to be tested in the matching test combination, the method further includes: Determine the calling order of the interface to be tested; The calling of the interface to be tested performs business processing based on the target input parameter data to obtain output parameter data, including: The interface to be tested is called in the calling sequence to perform identity authentication based on the target input parameter data to obtain output parameter data in the target authentication state.
3. The method according to claim 2, wherein the interface to be tested comprises a shunt interface, a comparison interface and a query interface, the calling order indicates that the shunt interface is located before the comparison interface, and the comparison interface is located before the query interface, and the target input parameter data comprises user information; and the step of calling the interface to be tested in accordance with the calling order to perform identity authentication based on the target input parameter data to obtain output parameter data in the target authentication state comprises: Calling the diversion interface, determining a target comparison method suitable for the user information from candidate comparison methods, obtaining a first diversion result of the user information being diverted to the target comparison method and storing it in a preset storage area; When the first diversion result indicates that the diversion is successful, calling the comparison interface to compare the user information with the pre-stored user information according to the target comparison method, obtaining the comparison result and storing it in the preset storage area; The query interface is called to query the preset storage area according to the user information to obtain the first diversion result and the comparison result, and the output parameter data is generated according to the first diversion result and the comparison result.
4. The method according to claim 3, characterized in that After obtaining the first diversion result of the user information being diverted to the target comparison method and storing it in a preset storage area, the method further includes: In the case where the first diversion result indicates a diversion failure, obtaining a second diversion result of a backup comparison method in which the user information is diverted to the target comparison method, and storing the result in a preset storage area; In the case where the second diversion result indicates a diversion failure, it is determined to skip calling the comparison interface, and the query interface is called to query the first diversion result and the second diversion result from the preset storage area based on the user information, and the output parameter data is generated according to the first diversion result and the second diversion result.
5. The method according to claim 3, characterized in that: The query interface includes a plurality of query sub-interfaces, each query sub-interface having an index information; the calling of the query interface to query the preset storage area based on the user information to obtain the first diversion result and the comparison result includes: For each query sub-interface, calling the query sub-interface to extract index information of the query sub-interface from the user information; In the case where the index information of the query sub-interface is extracted successfully, query processing is performed in the preset storage area according to the index information to obtain the first diversion result and the comparison result.
6. The method according to claim 1, characterized in that The interface test instruction includes a scenario identifier and a test combination identifier; the step of obtaining interface test configuration information of the target business scenario in response to the interface test instruction for the target business scenario includes: According to the scenario identifier, obtaining a test file for the target business scenario; Parsing the target annotation information in the test file through a reflection mechanism to obtain interface test configuration information of the target business scenario; Determining a test combination matching the interface test instruction from the test combination includes: The test combination corresponding to the test combination identifier is determined in the test combination of the target business scenario, and the test combination corresponding to the test combination identifier is used as the test combination that matches the interface test instruction.
7. The method according to claim 1, characterized in that The step of generating an interface test result for the interface test instruction according to the output parameter data and the preset test result includes: Comparing the preset test result with the reference data to obtain a reference comparison result; If the reference comparison result indicates that the preset test result is the same as the reference data, then an interface test result is generated indicating that the interface to be tested passes the interface test; If the reference comparison result indicates that the preset test result is different from the reference data, an interface test result is generated indicating that the interface to be tested fails the interface test.
8. An interface testing device, characterized in that: include: An acquisition unit, configured to acquire interface test configuration information of a target business scenario in response to an interface test instruction for the target business scenario, wherein the interface test configuration information includes a test combination of the target business scenario, and a test combination includes input parameter data under a business state and an interface required to be called when executing a business under the business state; A determination unit, used to determine a test combination matching the interface test instruction from the test combination, and determine an interface to be tested in the matching test combination; A calling unit, used for calling the interface to be tested to perform business processing based on target input parameter data to obtain output parameter data; the target input parameter data refers to the input parameter data under the business state in the matching test combination; A generating unit is used to generate an interface test result for the interface test instruction according to the output parameter data and a preset test result.
9. An electronic device, characterized in that: include: processor; And, a memory configured to store computer executable instructions, which, when executed, cause the processor to perform the interface testing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store computer-executable instructions, and the computer-executable instructions, when executed by a processor, implement the interface testing method according to any one of claims 1 to 7.
11. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the interface testing method as claimed in any one of claims 1 to 7.
