Interface testing method, device, equipment and storage medium

By using the trained test keyword extraction model and scenario generation model in interface testing, rich, comprehensive, and wide-coverage test scenario cases are generated, which solves the problem of strong limitations of existing interface testing methods and improves test accuracy and efficiency.

CN113312258BActive Publication Date: 2024-09-27PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110570152.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-25
Publication Date
2024-09-27
Estimated Expiration
2041-05-25

AI Technical Summary

Technical Problem

Existing interface testing methods rely on tester design, resulting in test scenarios that are highly limited and not rich and comprehensive enough, which in turn leads to inaccurate interface test results, low efficiency, and incomplete functions.

Method used

By obtaining the test data of the interface to be tested, input it into the trained test keyword extraction model for processing, extract the test keywords, and generate rich, comprehensive, and wide-coverage test scenario cases based on these keywords and data for interface testing.

Benefits of technology

It achieves the accuracy of interface test results and comprehensive functionality, improves testing efficiency, and avoids missing test scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113312258B
    Figure CN113312258B
Patent Text Reader

Abstract

The present application is applicable to the field of interface testing, and provides an interface testing method, device, equipment and storage medium. The interface testing method comprises: obtaining test data corresponding to the interface to be tested; inputting the test data into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data; determining the test scenario use case corresponding to the interface to be tested based on the test keyword and the test data; and testing the interface to be tested based on the test scenario use case. In the above scheme, the test data is processed based on the test keyword extraction model, and comprehensive, rich and diverse test keywords can be extracted quickly and accurately. The test scenario use cases generated based on these test keywords and test data are rich, comprehensive, and have a wide coverage, avoiding missing test scenarios. The interface to be tested is tested based on these test scenario use cases, so that the results of the interface test are more accurate, the test functions are more complete, and the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] An interface is a shared boundary between two independent components in a computer system for information exchange. Interface testing is mainly used to detect the interaction points between external systems and between internal sub-modules. This test can be used to detect data exchange, transmission and control management processes, as well as the mutual logical dependencies between systems. It is a type of functional testing. Interface testing is crucial in ensuring product quality.

[0003] Current interface testing is usually designed based on the tester's understanding of the business being tested. In this case, it is easy to be inconsiderate, and the design ideas are narrow and one-sided, resulting in the designed test scenarios being highly limited and not rich and comprehensive enough, which in turn leads to inaccurate interface test results, low test efficiency, and incomplete test functions. Summary of the invention

[0004] In view of this, the embodiments of the present application provide an interface testing method, apparatus, equipment and storage medium to solve the problem that the existing test scenarios designed by testers are highly limited and not rich and comprehensive enough, which leads to inaccurate interface testing results, low testing efficiency and incomplete testing functions.

[0005] A first aspect of an embodiment of the present application provides an interface testing method, the interface testing method comprising:

[0006] Acquire test data corresponding to the interface to be tested, wherein the test data includes an interface identifier, attribute parameters, and return parameters corresponding to the interface to be tested;

[0007] Inputting the test data into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data;

[0008] Based on the test keyword and the test data, determine the test scenario use case corresponding to the interface to be tested;

[0009] The interface to be tested is tested based on the test scenario use case.

[0010] Optionally, the determining, based on the test keyword and the test data, a test scenario use case corresponding to the interface to be tested includes:

[0011] Input the test keyword into the trained test scenario generation model for processing to obtain a test scenario template corresponding to the interface to be tested;

[0012] Fill the interface identifier and the return parameter into the test scenario template to generate a test scenario case corresponding to the interface to be tested.

[0013] Optionally, the determining, based on the test keyword and the test data, a test scenario use case corresponding to the interface to be tested includes:

[0014] Searching for a target test scenario that matches the test keyword in a preset strategy library, wherein the preset strategy library stores a plurality of test scenarios and a scenario label corresponding to each test scenario;

[0015] Based on the target test scenario and the test data, a test scenario use case corresponding to the interface to be tested is generated.

[0016] Optionally, before searching the preset strategy library for a target test scenario matching the test keyword, the interface testing method further includes:

[0017] The preset strategy is constructed based on a plurality of preset basic test strategies, a plurality of preset test scenarios and test questions corresponding to each preset test scenario.

[0018] Optionally, the preset strategy library further stores a test tool corresponding to each test scenario. After searching the preset strategy library for a target test scenario matching the test keyword, the interface testing method further includes:

[0019] Acquire a target test tool associated with the target test scenario;

[0020] The target testing tool is recommended to the user, and the target testing tool is used to test the interface to be tested.

[0021] Optionally, before inputting the test data into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data, the interface testing method further includes:

[0022] Obtain a first sample training set, wherein the first sample training set includes a plurality of sample test data, wherein each sample test data corresponds to at least one label;

[0023] Training an initial test keyword extraction network based on the first sample training set, and updating parameters of the initial test keyword extraction network based on the training result;

[0024] When it is detected that the first loss function corresponding to the initial test keyword extraction network converges, the trained test keyword extraction model is obtained.

[0025] Optionally, before inputting the test keyword into a trained test scenario generation model for processing to obtain a test scenario template corresponding to the interface to be tested, the interface testing method further includes:

[0026] Acquire a second sample training set, where the second sample training set includes a plurality of sample test scenario templates and a sample test keyword corresponding to each sample test scenario template;

[0027] Training an initial test scenario generation network based on the second sample training set, and updating parameters of the initial test scenario generation network based on the training result;

[0028] When it is detected that the second loss function corresponding to the initial test scenario generation network converges, the trained test scenario generation model is obtained.

[0029] A second aspect of an embodiment of the present application provides an interface testing device, including:

[0030] An acquisition unit, used to acquire test data corresponding to the interface to be tested, wherein the test data includes an interface identifier, attribute parameters and return parameters corresponding to the interface to be tested;

[0031] A processing unit, used for inputting the test data into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data;

[0032] A determination unit, configured to determine a test scenario case corresponding to the interface to be tested based on the test keyword and the test data;

[0033] The testing unit is used to test the interface to be tested based on the test scenario use case.

[0034] A third aspect of an embodiment of the present application provides an interface testing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the interface testing method described in the first aspect above when executing the computer program.

[0035] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the interface testing method described in the first aspect above are implemented.

[0036] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product runs on an interface testing device, the interface testing device executes the steps of the interface testing method described in the first aspect.

[0037] The sixth aspect of an embodiment of the present application provides a chip or integrated circuit, which includes: a processor, used to call and run a computer program from a memory, so that a device equipped with the chip or integrated circuit executes the steps of the interface testing method described in the first aspect above.

[0038] The interface testing method, device, equipment and storage medium provided in the embodiments of the present application have the following beneficial effects:

[0039] Acquire test data corresponding to the interface to be tested, the test data including the interface identifier, attribute parameters and return parameters corresponding to the interface to be tested; input the test data into a trained test keyword extraction model for processing to obtain the test keyword corresponding to the test data; determine the test scenario use case corresponding to the interface to be tested based on the test keyword and the test data; test the interface to be tested based on the test scenario use case. In the above scheme, the test data is processed based on the test keyword extraction model, so that comprehensive, rich and diverse test keywords can be extracted quickly and accurately, and then the test scenario use cases generated based on these test keywords and test data are rich, comprehensive, and have a wide coverage, avoiding missing test scenarios, and testing the interface to be tested based on these test scenario use cases, so that the results of the interface test are more accurate, the test functions are more complete, and the test efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0041] Figure 1 is a schematic flow chart of an interface testing method provided in an embodiment of the present application;

[0042] Figure 2 is a specific flow chart of step S103 of the interface testing method shown in an exemplary embodiment of the present application;

[0043] Figure 3 is a specific flow chart of step S103 of the interface testing method shown in another exemplary embodiment of the present application;

[0044] Figure 4 is a schematic flow chart of an interface testing method provided in another embodiment of the present application;

[0045] Figure 5 is a schematic diagram of an interface testing device provided by an embodiment of the present application;

[0046] Figure 6 It is a schematic diagram of an interface testing device provided in another embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0048] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0049] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0050] An interface is a shared boundary between two independent components in a computer system for information exchange. Interface testing is mainly used to detect the interaction points between external systems and between internal sub-modules. This test can be used to detect data exchange, transmission and control management processes, as well as the mutual logical dependencies between systems. It is a type of functional testing. Interface testing is crucial in ensuring product quality.

[0051] Current interface testing is usually designed based on the tester's understanding of the business being tested. In this case, it is easy to be inconsiderate, and the design ideas are narrow and one-sided, resulting in the designed test scenarios being highly limited and not rich and comprehensive enough, which in turn leads to inaccurate interface test results, low test efficiency, and incomplete test functions.

[0052] In view of this, the present application provides an interface testing method, by obtaining test data corresponding to the interface to be tested, the test data including an interface identifier, attribute parameters and return parameters corresponding to the interface to be tested; inputting the test data into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data; determining a test scenario use case corresponding to the interface to be tested based on the test keyword and the test data; and testing the interface to be tested based on the test scenario use case. In the above scheme, the test data is processed based on the test keyword extraction model, so that comprehensive, rich and diverse test keywords can be extracted quickly and accurately, and then the test scenario use cases generated according to these test keywords and test data are rich, comprehensive, and have a wide coverage, avoiding missing test scenarios, and testing the interface to be tested based on these test scenario use cases, so that the results of the interface test are more accurate, the test functions are more complete, and the test efficiency is improved.

[0053] Figure 1 It is a schematic flow chart of an interface testing method provided by an embodiment of the present application. It should be understood that the execution subject of the interface testing method provided by the present application is an interface testing device, including but not limited to mobile terminals such as smart phones, tablet computers, computers, personal digital assistants (PDAs), and various types of servers. Figure 1 The interface testing method shown may include: S101 to S104, which are specifically as follows:

[0054] S101: Acquire test data corresponding to the interface to be tested, where the test data includes an interface identifier, attribute parameters, and return parameters corresponding to the interface to be tested.

[0055] An interface is a shared boundary between two independent components in a computer system for information exchange. Interface testing is mainly used to detect the interaction points between external systems and between internal sub-modules. This interface test can be used to detect data exchange, transmission and control management processes, as well as the mutual logical dependencies between systems, etc. It is a type of functional testing.

[0056] The interface to be tested is the interface that needs to be tested for the normal exchange, transmission and control management process of data, as well as the mutual logical dependencies between systems. It can also be understood that the interface to be tested is the interface that needs to be tested for the normal function of each function.

[0057] The test data corresponding to the interface to be tested is data used to detect whether the interface to be tested can work normally or whether its functions are complete. The test data may include an interface identifier corresponding to the interface to be tested, attribute parameters corresponding to the interface to be tested, and return parameters corresponding to the interface to be tested.

[0058] The method for obtaining the test data may be to first perform an initial interface test on the interface to be tested by means of a test interface in the prior art, and obtain the test data corresponding to the interface to be tested. Exemplarily, a test request initiated by the interface to be tested is obtained, and the attribute parameters corresponding to the preset interface to be tested are passed into the interface to be tested, and the data returned by the interface to be tested for the attribute parameters is obtained. Among them, the test request includes an interface identifier corresponding to the interface to be tested. According to the test request, the attribute parameters corresponding to the preset interface to be tested, and the returned data, the test data corresponding to the interface to be tested is generated. This is only an exemplary description and is not limited to this.

[0059] Optionally, the test data corresponding to each interface to be tested may be pre-stored in a database, and when the test data corresponding to a certain interface to be tested needs to be obtained, the test data corresponding to the interface to be tested is searched in the database according to the interface identifier corresponding to the interface to be tested. This is only an exemplary description and is not limited to this.

[0060] S102: The test data is input into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data.

[0061] The test keyword corresponding to the test data is the test keyword corresponding to the interface to be tested. The number of test keywords can be one or more. In order to make the test scenario cases generated based on the test keywords rich, comprehensive, and have a wide coverage, usually there are multiple test keywords corresponding to each interface to be tested.

[0062] The test keyword is used to indicate the function that the interface to be tested wants to test. For example, if the function that a certain interface to be tested wants to test is normal login, the test keyword corresponding to the interface to be tested can be unauthorized access, brute force cracking, security verification, secure login, etc. This is only an example description and is not limited to this.

[0063] In this embodiment, a pre-trained test keyword extraction model is pre-stored in the interface test device. The test keyword extraction model is obtained by training an initial test keyword extraction network based on a first sample training set using a machine learning algorithm. It is understandable that the test keyword extraction model can be pre-trained by the interface test device, or it can be pre-trained by other devices and then the file corresponding to the test keyword extraction model can be transplanted to the interface test device. In other words, the execution subject of training the test keyword extraction model and the execution subject of using the test keyword extraction model can be the same or different.

[0064] The test data is input into a trained test keyword extraction model for processing, and the test keyword extraction model outputs a test keyword corresponding to the test data. Exemplarily, the test data is segmented based on the test keyword extraction model to obtain a plurality of segmented words; the plurality of segmented words are deduplicated to obtain a plurality of initial keywords; the association degree value between each initial keyword and the test data is calculated; and the test keyword corresponding to the test data is determined based on the association degree value corresponding to each initial keyword.

[0065] Specifically, the vector features corresponding to each initial keyword and the vector features corresponding to the test data are obtained, and the cosine similarity between the vector features corresponding to each initial keyword and the vector features corresponding to the test data is determined. Each cosine similarity is normalized to obtain the correlation degree value between each initial keyword and the test data.

[0066] Exemplarily, a preset formula may be used to calculate the cosine similarity between each word vector and the semantic vector, and the preset formula is as follows:

[0067]

[0068] In the above formula (1), R(Q, D) represents the cosine similarity of the correlation between the vector feature corresponding to a certain initial keyword and the vector feature corresponding to the test data, and y Q Represents the vector feature corresponding to the initial keyword, y D Represents the vector features corresponding to the test data.

[0069] Each cosine similarity is normalized to obtain the correlation value between each initial keyword and the test data. For example, softmax logistic regression is performed on each cosine similarity so that the value of the cosine similarity falls into [0, 1], and the correlation value between each initial keyword and the test data is obtained. The larger the correlation value, the higher the correlation between the initial keyword and the test data; the smaller the correlation value, the lower the correlation between the initial keyword and the test data.

[0070] All initial keywords are sorted based on the magnitude of the relevance value corresponding to each initial keyword, and several initial keywords are selected from them as test keywords corresponding to the test data based on the sorting result. For example, based on the relevance value corresponding to each initial keyword, all initial keywords are sorted from large to small, and several initial keywords with a high ranking position are selected as test keywords corresponding to the test data. Alternatively, based on the relevance value corresponding to each initial keyword, all initial keywords are sorted from small to large, and several initial keywords with a low ranking position are selected as test keywords corresponding to the test data. There is no limit on the number of test keywords, which can be adjusted according to actual conditions.

[0071] Optionally, in a possible implementation, the test data corresponding to the interface to be tested is obtained. The test data includes interface identifiers, attribute parameters, and return parameters, all of which are expressed in the form of codes. The codes have corresponding Chinese comments, and the test keywords corresponding to the test data can be extracted from the Chinese comments corresponding to these codes. Usually, only key words are annotated in the comments corresponding to the code, so the extracted Chinese comments can be used as the test keywords corresponding to the test data. This is only an illustrative description and is not limited to this.

[0072] Optionally, in a possible implementation, the test keyword can also be expressed in English. In this case, the test keyword can be directly extracted from the interface identifier, attribute parameter, and return parameter codes. Exemplarily, a regular code list is prepared in advance, and regular codes in the code corresponding to the test data are determined based on the regular code list, and these regular codes are removed, and the remaining codes are used as the test keywords corresponding to the test data. This is only an exemplary description and is not limited to this.

[0073] S103: Based on the test keyword and the test data, determine the test scenario use case corresponding to the interface to be tested.

[0074] The test scenario case is used to test the interface to be tested. Different test scenario cases can test different functions of the interface to be tested. It can be understood that the richer, more comprehensive and more comprehensive the test scenario cases are, the more accurate the test results and the more complete the test functions can be when testing the interface to be tested based on these test scenario cases. Based on the test keywords and test data, multiple test scenario cases corresponding to the interface to be tested can be generated.

[0075] Figure 2 is a specific flow chart of step S103 of the interface testing method shown in an exemplary embodiment of the present application; in some possible implementations of the present application, the above S103 may include S1031 to S1032, which are as follows:

[0076] S1031: Input the test keyword into the trained test scenario generation model for processing to obtain a test scenario template corresponding to the interface to be tested.

[0077] In this embodiment, a pre-trained test scenario generation model is pre-stored in the interface test device. The test scenario generation model is obtained by training an initial test scenario generation network based on a second sample training set using a machine learning algorithm. It is understandable that the test scenario generation model can be pre-trained by the interface test device, or it can be pre-trained by other devices and then the file corresponding to the test scenario generation model is transplanted to the interface test device. In other words, the execution subject of training the test scenario generation model and the execution subject of using the test scenario generation model can be the same or different.

[0078] By processing the test keywords through the test scenario generation model, multiple test scenario templates corresponding to the interface to be tested can be obtained. Exemplarily, the vector features corresponding to each test keyword and the vector features of each preset test scenario template are determined based on the test scenario generation model, and the cosine similarity between the vector features corresponding to each test keyword and the vector features of each preset test scenario template is determined. Each cosine similarity is normalized to obtain the matching degree between each test keyword and each preset test scenario template. The test scenario generation model outputs the preset test scenario template corresponding to the matching degree greater than the matching threshold as the test scenario template corresponding to the interface to be tested. Among them, the matching threshold is pre-set by the user and is not limited to this.

[0079] S1032: Fill the interface identifier and return parameters into the test scenario template to generate a test scenario case corresponding to the interface to be tested.

[0080] The data corresponding to the test scenario use case needs to include the interface identifier, attribute parameters, and return parameters corresponding to the interface under test. In order to better match more interfaces to be tested, the data corresponding to the test scenario template contains attribute parameters, but does not include interface identifiers and return parameters. After the test scenario template is determined, the interface identifier corresponding to the interface to be tested and the return parameters corresponding to the interface to be tested are filled into the test scenario template to generate a test scenario use case corresponding to the interface to be tested. Accordingly, when there are multiple test scenario templates, multiple test scenario use cases are generated in the same way.

[0081] For example, the code corresponding to a test scenario template is:

[0082]

[0083] The interface identifier corresponding to the interface to be tested is this.$url.queryPageConsulting, and the return parameter corresponding to the interface to be tested is this.yxVideos=data.data. These two data are filled in the corresponding positions in the test scenario template to obtain the test scenario case corresponding to the interface to be tested. This is only an exemplary description and is not limited to this.

[0084] In this embodiment, the test data is processed based on the test keyword extraction model, so that comprehensive, rich and diverse test keywords can be extracted quickly and accurately. Then, the test scenario use cases generated based on these test keywords and test data are rich, comprehensive, and have a wide coverage, avoiding missing test scenarios. The interface to be tested is tested based on these test scenario use cases, which makes the interface test results more accurate, the test functions more complete, and the test efficiency improved.

[0085] Figure 3 This is a specific flow chart of step S103 of the interface testing method shown in another exemplary embodiment of the present application; in some possible implementations of the present application, the above S103 may include S1033-S1034. It is worth noting that S1031-S1032 are parallel to S1033-S1034, and S1033-S1034 are not executed after S1032. The specific implementation method is subject to the actual situation and is not limited to this. S1033-S1034 are as follows:

[0086] S1033: Searching for a target test scenario that matches the test keyword in a preset strategy library, wherein the preset strategy library stores a plurality of test scenarios and a scenario label corresponding to each test scenario.

[0087] The preset strategy library stores a variety of test scenarios and scenario tags corresponding to each test scenario. The test scenarios are stored in the form of codes, and each test scenario is stored in association with the scenario tag corresponding to the test scenario. Optionally, each test scenario may correspond to one or more scenario tags. The scenario tag is used to indicate the function corresponding to an interface when the corresponding test scenario tests the interface.

[0088] Scenario tags are similar to test keywords. For example, a scenario tag corresponding to a test scenario is security verification, brute force password cracking, etc. This test scenario can be used to test the normal login function corresponding to a certain interface to be tested. This is only an example and is not limited to this.

[0089] After obtaining the test keyword corresponding to the interface to be tested, the target scenario label that matches the test keyword can be searched in the preset policy library, and then the target test scene associated with the target scenario label can be searched to obtain the target test scene that matches the test keyword. Among them, the target scenario label that matches the test keyword does not necessarily have to be completely consistent with the text. Text that is similar or related to the test keyword can also be used as the target scenario label that matches the test keyword. And the target scenario label that matches the test keyword can be one or more. For example, the test keyword is security verification, and the target scenario label that matches the test keyword can be security verification or security login.

[0090] For example, the test keyword corresponding to the interface to be tested is security login, and the target scenario tag matching the test keyword: security login is found in the preset policy library as security verification. Obtain the target test scenario associated with the target scenario tag: security verification. Use the found target test scenario as the target test scenario matching the test keyword.

[0091] S1034: Generate a test scenario use case corresponding to the interface to be tested based on the target test scenario and test data.

[0092] Generate test scenario use cases based on one or more acquired target test scenarios combined with test data. The data corresponding to the test scenario use case needs to include the interface identifier, attribute parameters, and return parameters corresponding to the interface under test. In order to better match more interfaces to be tested, the target test scenario contains attribute parameters and return parameters in the data corresponding to the target test scenario, but does not include interface identifiers. After the target test scenario is determined, the interface identifier corresponding to the interface to be tested is filled into the target test scenario, and a test scenario use case corresponding to the interface to be tested is generated. Accordingly, when there are multiple target test scenarios, multiple test scenario use cases are generated in the same way.

[0093] Optionally, the data corresponding to the target test scenario may also include an interface identifier, attribute parameters, and return parameters. When the target test scenario is determined, the interface identifier corresponding to the interface to be tested is used to replace the original interface identifier of the target test scenario to generate a test scenario case corresponding to the interface to be tested. This is only an exemplary description and is not limited to this.

[0094] Exemplarily, the function of testing the normal login of the interface to be tested is taken as an example for explanation. The existing test scenario is to enter the correct username and password, and the login is successful, otherwise the login fails. It can be understood that when the normal login function of the interface to be tested is tested, the verification code is not thought of, so the security of the interface to be tested is not guaranteed. At this time, the target test scenario may include entering the correct username and the correct password, and the correct verification code will result in a successful login, otherwise the login fails; it may also include entering an incorrect username or password five times in a row, then restricting the login, and allowing login again after 15 minutes, etc. Since the target test scenario and test data are both stored in the form of code, the interface identifier of the interface to be tested is extracted from the test data, and the original interface identifier in the target test scenario is replaced with the interface identifier to generate a test scenario use case corresponding to the interface to be tested.

[0095] Optionally, in a possible implementation, the test data corresponding to the interface to be tested may include an interface identifier, a test scenario in which login is restricted if login fails for 5 consecutive times and the user can log in again after 15 minutes, etc. However, this test scenario does not set how to judge login failure. At this time, the target test scenario may include only entering the user name, login failure; only entering the password, login failure; entering the user name and password, but not the verification code, login failure; entering the correct user name, password and the wrong verification code, login failure, etc. Extract the interface identifier of the interface to be tested and the data returned by the interface to be tested from the test data, and replace the original interface identifier and returned data in each target test scenario to generate multiple test scenario use cases. This is only an exemplary description and is not limited to this.

[0096] Optionally, in a possible implementation, before executing S1033, a preset strategy library may be constructed based on a plurality of preset basic test strategies, a plurality of preset test scenarios, and test questions corresponding to each preset test scenario.

[0097] Exemplarily, multiple basic test strategies, multiple preset test scenarios, and questions corresponding to each preset test scenario are collected in advance, wherein the questions corresponding to each preset test scenario can be used as the scenario label corresponding to each preset test scenario. Multiple basic test strategies and multiple preset test scenarios can be collected in the network, and can also be designed by testers, without limitation. For example, basic test strategies may include: interface mandatory parameter verification strategy, enumeration parameter empty strategy, etc., and can also automatically generate mandatory coverage of all interface parameters based on positive examples of interface library data, thereby obtaining multiple preset test scenarios. For example, if you need to test the normal login function of a certain interface, you need to enter the correct user name, password, and verification code to achieve normal login. Taking this test scenario as a positive example, based on the web debugging tool (postman, jmeter, etc.), you can get the test scenario of only entering the username and returning the request to enter the password; only entering the password and returning the request to enter the username; entering the username and password and returning the request to enter the verification code; entering the username, password and an incorrect verification code and returning the request to enter the correct verification code; entering an incorrect username, a correct password and a correct verification code and returning the request to enter the correct username, etc. It can be understood that for ease of understanding, it is expressed in Chinese here, and the actual test scenario is usually expressed in code form.

[0098] For example, a test scenario is:

[0099]

[0100] Among them, page:1, limit:4 represent attribute parameters, and this.yxVideos=data.data represents the return parameter (i.e., the data that needs to be returned by the interface to be tested). This test scenario needs to fill in the interface identifier corresponding to the interface to be tested to obtain the test scenario case corresponding to the interface to be tested. This is only an exemplary description and is not limited to this.

[0101] Or, a test scenario is:

[0102]

[0103] Among them, this.$url.queryPageConsulting represents the interface identifier corresponding to the interface to be tested, page:1,limit:4 represents the attribute parameters, and this.yxVideos=data.data represents the return parameter (i.e., the data that needs to be returned by the interface to be tested). This test scenario requires replacing the interface identifier in the test scenario with the interface identifier corresponding to the interface to be tested to obtain the test scenario use case corresponding to the interface to be tested. This is only an exemplary description and is not limited to this.

[0104] Optionally, in an achievable manner, if the test keyword is set in Chinese, when the preset policy library is constructed, the scene label in the preset policy library is also set in Chinese; if the test keyword is set in English, when the preset policy library is constructed, the scene label in the preset policy library is also set in English. This is only an exemplary description and is not limited to this.

[0105] In this embodiment, a target test scenario matching the test keyword is searched in the preset policy library, and a test scenario case corresponding to the interface to be tested is generated based on the target test scenario and the test data. The interface to be tested is tested based on these test scenario cases, so that the obtained test results are more accurate, the test quality of the interface test is improved, the security and stability of the interface to be tested are improved, and various bugs existing in the interface to be tested and problems existing in the design of the interface to be tested are easily found, so that the functional evaluation of the interface to be tested is more complete.

[0106] S104: Testing the interface to be tested based on the test scenario use case.

[0107] Test the interface to be tested based on each generated test scenario case. For example, a test scenario case is:

[0108]

[0109] Among them, this.$url.queryPageConsulting represents the interface identifier corresponding to the interface to be tested, page:1,limit:4 represents the attribute parameters, and this.yxVideos=data.data represents the return parameter.

[0110] Pass the attribute parameters into the interface to be tested, obtain the data returned by the interface to be tested for the attribute parameters, and compare whether the returned data is the same as the return parameters in the test scenario case. If the data returned during the test is the same as the return parameters in the test scenario case, it proves that the function of the interface to be tested is normal; if the data returned during the test is different from the return parameters in the test scenario case, it proves that the function of the interface to be tested is abnormal. In order to ensure the accuracy of the test, the interface to be tested can be repeatedly tested with the same test scenario case. When the test result shows that a function of the interface to be tested is abnormal, a prompt message can be generated, which is used to prompt the developer to adjust the code corresponding to the function of the interface to be tested.

[0111] Optionally, in a possible implementation, a log report can be generated when the interface to be tested is tested based on a test scenario use case. The log report may include information such as which databases, test results, test times, and test processes are called by the interface to be tested during the test. The log report is sent to the tester, who can quickly and intuitively understand the call link and DB operation (pseudo-operation command in assembly language) corresponding to the interface to be tested through the log report, and can also accelerate the tester's familiarity with the business.

[0112] Optionally, in a possible implementation, in order to improve test efficiency and speed up testing. The preset policy library also stores test tools corresponding to each test scenario. After searching the preset policy library for a target test scenario that matches the test keyword, the interface testing method provided by the present application also includes: obtaining a target test tool associated with the target test scenario; recommending the target test tool to the user, and the target test tool is used to test the interface to be tested.

[0113] Exemplarily, test scenario A in the preset strategy library is more suitable for using the MQ test tool. When test scenario A is the target test scenario, the MQ test tool is recommended to the user. The user can test the interface to be tested through the MQ test tool. Alternatively, a variety of different test tools can be pre-set on the interface test platform. When test scenario A is the target test scenario, it is detected whether the test tool used by the current interface test platform is the MQ test tool. If not, the test tool used by the current interface test platform is switched to the MQ test tool.

[0114] It is worth noting that when the MQ test tool is used to test the interface to be tested, the test is performed based on the test scenario A and the test scenario case generated by the test data, rather than testing the interface to be tested based on the test scenario A. The MQ test tool is only used when the test scenario A is selected. This is only an exemplary description and is not limited to this.

[0115] Figure 4 is a schematic flow chart of an interface testing method provided by another embodiment of the present application. For example, in some possible implementations of the present application, Figure 4 The interface testing method shown may include: S201 to S207, wherein: Figure 4 The steps S204 to S207 shown can refer to the above description of S101 to S104, and for the sake of brevity, they will not be described here in detail. The steps S201 to S203 will be described in detail below.

[0116] S201: Obtain a first sample training set, where the first sample training set includes a plurality of sample test data, wherein each sample test data corresponds to at least one label.

[0117] The first sample training set includes a plurality of sample test data, wherein each sample test data corresponds to at least one label, and the label is represented by a matrix. The label is equivalent to a test keyword. Exemplarily, 800 sample test data with labels are selected, and a part of these sample test data is used as a training set, and the other part is used as a test set. For example, 600 sample test data with labels are used as a training set, and the remaining 200 sample test data and the labels corresponding to the 200 sample test data are used as a test set.

[0118] S202: Training an initial test keyword extraction network based on the first sample training set, and updating parameters of the initial test keyword extraction network based on the training result.

[0119] The prototype of the initial test keyword extraction network can be an XGBOOST machine learning model. Multiple sample test data in the training set and the labels corresponding to each sample test data are input into the initial test keyword extraction network for training. The gradient descent method can be selected for training. The hidden layer in the initial test keyword extraction network learns the vector features of the labels corresponding to each sample test data.

[0120] S203: When it is detected that the first loss function corresponding to the initial test keyword extraction network converges, a trained test keyword extraction model is obtained.

[0121] When the preset number of training times is reached, the initial test keyword extraction network at this time is tested based on the test set. Exemplarily, the sample test data in the test set is input into the initial test keyword extraction network at this time for processing, and the initial test keyword extraction network at this time outputs the test keyword corresponding to the sample test data. The first loss value between the test keyword corresponding to the sample test data and the label corresponding to the sample test data is calculated based on the first loss function. The first loss function can be a cross entropy loss function.

[0122] When the first loss value does not meet the first preset condition, adjust the parameters of the initial test keyword extraction network (for example, adjust the weight value corresponding to the hidden layer of the initial test keyword extraction network), and continue to train the initial test keyword extraction network. When the first loss value meets the first preset condition, stop training the initial test keyword extraction network, and use the trained initial test keyword extraction network as a trained test keyword extraction model. For example, assume that the first preset condition is that the first loss value is less than or equal to the preset first loss value threshold. Then, when the first loss value is greater than the first loss value threshold, adjust the parameters of the initial test keyword extraction network, and continue to train the initial test keyword extraction network. When the first loss value is less than or equal to the first loss value threshold, stop training the initial test keyword extraction network, and use the trained initial test keyword extraction network as a trained test keyword extraction model. This is only an exemplary description and is not limited to this.

[0123] Optionally, during the training of the initial test keyword extraction network, the convergence of the first loss function corresponding to the initial test keyword extraction network can be observed. When the first loss function converges, the training of the initial test keyword extraction network is stopped, and the trained initial test keyword extraction network is used as the trained test keyword extraction model. The convergence of the first loss function means that the value of the first loss function tends to be stable. This is only an exemplary description and is not limited to this.

[0124] In this embodiment, the initial test keyword extraction network is trained based on the first sample training set to obtain a test keyword extraction model, which is convenient for subsequent processing of test data based on the test keyword extraction model, with fast extraction speed and high accuracy, and the extracted test keywords are comprehensive and rich.

[0125] Optionally, in one possible implementation, before the test keyword is input into the trained test scenario generation model for processing to obtain the test scenario template corresponding to the interface to be tested, the interface testing method provided by the present application also includes: obtaining a second sample training set, the second sample training set including multiple sample test scenario templates and sample test keywords corresponding to each sample test scenario template; training the initial test scenario generation network based on the second sample training set, and updating the parameters of the initial test scenario generation network based on the training results; when it is detected that the second loss function corresponding to the initial test scenario generation network converges, the trained test scenario generation model is obtained.

[0126] The test scenario generation model is obtained by training the initial test scenario generation network based on the second sample training set using a machine learning algorithm. The initial test scenario generation network can be built based on the TensorFlow framework. The second sample training set includes multiple sample test scenario templates and sample test keywords corresponding to each sample test scenario template.

[0127] Exemplarily, 600 sample test scene templates are selected, and the relationship between each sample test keyword and its corresponding test data is taken into consideration, and the sample test keywords are manually labeled for the 600 sample test scene templates. A portion of the data in the second sample training set is used as a training set, and another portion of the data is used as a test set. For example, 500 sample test scene templates are used as a training set, and the remaining 100 sample test scene templates and the sample test keywords corresponding to the 100 sample test scene templates are used as a test set.

[0128] The training set is input into the initial test scenario generation network for training. The initial test scenario generation network extracts the feature vectors corresponding to the sample test scenario template and its corresponding sample test keyword, and learns the correlation between these feature vectors. When the preset number of training times is reached, the initial test scenario generation network at this time is tested based on the test set. Exemplarily, the sample test keyword is input into the initial test scenario generation network at this time for processing to obtain the actual test scenario template corresponding to the sample test keyword. The second loss value between the actual test scenario template and the sample test scenario template corresponding to the sample test keyword is calculated based on the second loss function.

[0129] When the second loss value does not meet the second preset condition, adjust the parameters of the initial test scenario generation network, and continue to train the initial test scenario generation network. When the second loss value meets the second preset condition, stop training the initial test scenario generation network, and use the trained initial test scenario generation network as the trained test scenario generation model. For example, assume that the second preset condition is that the second loss value is less than or equal to the preset second loss value threshold. Then, when the second loss value is greater than the second loss value threshold, adjust the parameters of the initial test scenario generation network, and continue to train the initial test scenario generation network. When the second loss value is less than or equal to the second loss value threshold, stop training the initial test scenario generation network, and use the trained initial test scenario generation network as the trained test scenario generation model. This is only an exemplary description and is not limited to this.

[0130] In this embodiment, the second loss function can be a cross entropy loss function, which is calculated based on softmax. Softmax converts the value finally output by the network into a probability form through an exponential, and softmax serves as the output layer of the classification task. In this embodiment, the processing of the test scenario generation model can be understood as a classification process. That is, during the processing, it is determined which sample test scenario template has the highest probability of matching the sample test keyword, and finally the sample test scenario template with the highest probability is output. This is only an exemplary description and is not limited to this.

[0131] In this embodiment, the initial test scenario generation network is trained based on the second sample training set to obtain a test scenario generation model. This facilitates the subsequent determination of a test scenario template based on the test scenario generation model, and then generates a test scenario use case. This method improves the speed of generating test scenario use cases, and the determined test scenario templates are rich, comprehensive, and have a wide coverage, thereby making the generated test scenario use cases rich, comprehensive, and have a wide coverage.

[0132] See also Figure 5 , Figure 5 is a schematic diagram of an interface testing device provided in an embodiment of the present application. The device includes units for performing Figure 1 to Figure 4 For details, please refer to the steps in the corresponding embodiment. Figure 1 to Figure 4 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 5 ,include:

[0133] The acquisition unit 310 is used to acquire test data corresponding to the interface to be tested, wherein the test data includes an interface identifier, attribute parameters and return parameters corresponding to the interface to be tested;

[0134] The processing unit 320 is used to input the test data into the trained test keyword extraction model for processing to obtain the test keyword corresponding to the test data;

[0135] A determination unit 330, configured to determine a test scenario case corresponding to the interface to be tested based on the test keyword and the test data;

[0136] The testing unit 340 is used to test the interface to be tested based on the test scenario use case.

[0137] Optionally, the determining unit 330 is specifically configured to:

[0138] Input the test keyword into the trained test scenario generation model for processing to obtain a test scenario template corresponding to the interface to be tested;

[0139] Fill the interface identifier and the return parameter into the test scenario template to generate a test scenario case corresponding to the interface to be tested.

[0140] Optionally, the determining unit 330 is further configured to:

[0141] Searching for a target test scenario that matches the test keyword in a preset strategy library, wherein the preset strategy library stores a plurality of test scenarios and a scenario label corresponding to each test scenario;

[0142] Based on the target test scenario and the test data, a test scenario use case corresponding to the interface to be tested is generated.

[0143] Optionally, the interface testing device further includes:

[0144] The construction unit is used to construct the preset strategy library based on multiple preset basic test strategies, multiple preset test scenarios and test questions corresponding to each preset test scenario.

[0145] Optionally, the preset strategy library further stores a test tool corresponding to each test scenario, and the interface testing device further includes:

[0146] A test tool acquisition unit, used to acquire a target test tool associated with the target test scenario;

[0147] The recommendation unit is used to recommend the target testing tool to the user, where the target testing tool is used to test the interface to be tested.

[0148] Optionally, the interface testing device further includes:

[0149] A first acquisition unit is used to acquire a first sample training set, wherein the first sample training set includes a plurality of sample test data, wherein each sample test data corresponds to at least one label;

[0150] A first training unit, configured to train an initial test keyword extraction network based on the first sample training set, and update parameters of the initial test keyword extraction network based on the training result;

[0151] The first detection unit is used to obtain the trained test keyword extraction model when it is detected that the first loss function corresponding to the initial test keyword extraction network converges.

[0152] Optionally, the interface testing device further includes:

[0153] A second acquisition unit, configured to acquire a second sample training set, wherein the second sample training set includes a plurality of sample test scene templates and a sample test keyword corresponding to each sample test scene template;

[0154] A second training unit, configured to train an initial test scenario generation network based on the second sample training set, and update parameters of the initial test scenario generation network based on the training result;

[0155] The second detection unit is used to obtain the trained test scenario generation model when it is detected that the second loss function corresponding to the initial test scenario generation network converges.

[0156] See also Figure 6 , Figure 6 FIG. 1 is a schematic diagram of an interface testing device provided by another embodiment of the present application. Figure 6 As shown, the interface test device 4 of this embodiment includes: a processor 40, a memory 41, and a computer instruction 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer instruction 42, the steps in the above-mentioned various interface test method embodiments are implemented, for example Figure 1 Alternatively, when the processor 40 executes the computer instruction 42, the functions of each unit in the above embodiments are realized, for example, Figure 5 The functions of units 310 to 340 are shown.

[0157] Exemplarily, the computer instruction 42 may be divided into one or more units, which are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more units may be a series of computer instruction segments capable of completing specific functions, which are used to describe the execution process of the computer instruction 42 in the interface test device 4. For example, the computer instruction 42 may be divided into an acquisition unit, a processing unit, a determination unit, and a test unit, and the specific functions of each unit are as described above.

[0158] The interface test device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 6 It is only an example of the interface test device 4 and does not constitute a limitation on the device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the device may also include input and output devices, network access devices, buses, etc.

[0159] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0160] The memory 41 may be an internal storage unit of the device, such as a hard disk or memory of the device. The memory 41 may also be an external storage terminal of the device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the device. Further, the memory 41 may also include both an internal storage unit of the device and an external storage terminal. The memory 41 is used to store the computer instructions and other programs and data required by the terminal. The memory 41 may also be used to temporarily store data that has been output or is to be output.

[0161] The embodiment of the present application also provides a computer storage medium, which can be non-volatile or volatile. The computer storage medium stores a computer program, which implements the steps in the above-mentioned various interface testing method embodiments when executed by a processor.

[0162] The present application also provides a computer program product. When the computer program product runs on a device, the device executes the steps in the above-mentioned various interface testing method embodiments.

[0163] An embodiment of the present application also provides a chip or integrated circuit, which includes: a processor, which is used to call and run a computer program from a memory, so that a device equipped with the chip or integrated circuit executes the steps in the above-mentioned various interface testing method embodiments.

[0164] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0165] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0166] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0167] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. An interface testing method, characterized in that: include: Acquire test data corresponding to the interface to be tested, wherein the test data includes an interface identifier, attribute parameters, and return parameters corresponding to the interface to be tested; The obtaining of the test data corresponding to the interface to be tested comprises: performing a first interface test on the interface to be tested in a preset manner to obtain the test data; The test data is input into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data; the test keyword is used to indicate the function of the interface to be tested that needs to be tested; Based on the test keyword and the test data, determine the test scenario use case corresponding to the interface to be tested; The interface to be tested is tested based on the test scenario use case.

2. The interface testing method according to claim 1, characterized in that: The determining, based on the test keyword and the test data, a test scenario use case corresponding to the interface to be tested includes: Input the test keyword into the trained test scenario generation model for processing to obtain a test scenario template corresponding to the interface to be tested; Fill the interface identifier and the return parameter into the test scenario template to generate a test scenario case corresponding to the interface to be tested.

3. The interface testing method according to claim 1, characterized in that: The determining, based on the test keyword and the test data, a test scenario use case corresponding to the interface to be tested includes: Searching for a target test scenario that matches the test keyword in a preset strategy library, wherein the preset strategy library stores a plurality of test scenarios and a scenario label corresponding to each test scenario; Based on the target test scenario and the test data, a test scenario use case corresponding to the interface to be tested is generated.

4. The interface testing method according to claim 3, characterized in that: Before searching the preset strategy library for a target test scenario that matches the test keyword, the interface testing method further includes: The preset strategy library is constructed based on a plurality of preset basic test strategies, a plurality of preset test scenarios and test questions corresponding to each preset test scenario.

5. The interface testing method according to any one of claims 3 or 4, characterized in that: The preset strategy library also stores a test tool corresponding to each test scenario. After searching the preset strategy library for a target test scenario matching the test keyword, the interface testing method further includes: Acquire a target test tool associated with the target test scenario; The target testing tool is recommended to the user, and the target testing tool is used to test the interface to be tested.

6. The method according to any one of claims 1 to 4, characterized in that: Before the test data is input into the trained test keyword extraction model for processing to obtain the test keyword corresponding to the test data, the interface testing method further includes: Obtain a first sample training set, wherein the first sample training set includes a plurality of sample test data, wherein each sample test data corresponds to at least one label; Training an initial test keyword extraction network based on the first sample training set, and updating parameters of the initial test keyword extraction network based on the training result; When it is detected that the first loss function corresponding to the initial test keyword extraction network converges, the trained test keyword extraction model is obtained.

7. The method according to claim 2, characterized in that Before inputting the test keyword into the trained test scenario generation model for processing to obtain the test scenario template corresponding to the interface to be tested, the interface testing method further includes: Acquire a second sample training set, where the second sample training set includes a plurality of sample test scenario templates and a sample test keyword corresponding to each sample test scenario template; Training an initial test scenario generation network based on the second sample training set, and updating parameters of the initial test scenario generation network based on the training result; When it is detected that the second loss function corresponding to the initial test scenario generation network converges, the trained test scenario generation model is obtained.

8. An interface testing device, characterized in that: include: An acquisition unit, used to acquire test data corresponding to the interface to be tested, wherein the test data includes an interface identifier, attribute parameters and return parameters corresponding to the interface to be tested; The obtaining of the test data corresponding to the interface to be tested comprises: performing a first interface test on the interface to be tested in a preset manner to obtain the test data; A processing unit, used for inputting the test data into a trained test keyword extraction model for processing to obtain a test keyword corresponding to the test data; the test keyword is used to indicate a function to be tested of the interface to be tested; A determination unit, configured to determine a test scenario case corresponding to the interface to be tested based on the test keyword and the test data; The testing unit is used to test the interface to be tested based on the test scenario use case.

9. An interface testing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.