Interface test method, device, equipment and storage medium
By acquiring the input parameter data and test rules of the interface, generating intermediate files using historical test data, and performing matching processing based on the input-output parameter mapping relationship, the problem of repetitive work in interface testing is solved, the efficiency of test case generation is improved, and the efficiency of interface testing is enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-18
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, interface testing involves a large amount of repetitive work, resulting in low testing efficiency. Improving the efficiency of test case generation has become a research hotspot.
By acquiring the input parameter data and test rules of the interface, generating intermediate files using historical test data, and performing matching processing based on the input and output parameter mapping relationship, target files are generated, reducing repetitive calculation work and improving the efficiency of test case generation.
By making full use of historical test data during interface testing, repetitive calculations were reduced, test case generation efficiency was improved, and the overall efficiency of interface testing was enhanced.
Smart Images

Figure CN116126672B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of testing, in particular to an interface testing method and device, equipment and a storage medium. BACKGROUND
[0002] Interface testing is a kind of test for testing the interface between system components, mainly used for testing the interface between the system and other external systems, and the interface between various sub-modules in the system. Test cases are indispensable for interface testing. Test Case refers to the description of a specific software product testing task, embodying testing schemes, methods, techniques and strategies. In practical applications, a large amount of repetitive work needs to be performed by staff to generate test cases for interface testing, which not only consumes a lot of time and energy of the testing staff, but also leads to low testing efficiency. Therefore, how to realize efficient interface testing has become one of the hot issues in current research. SUMMARY
[0003] The embodiments of the present application provide an interface testing method, device, equipment and storage medium, which can improve the generation efficiency of test cases, so as to realize efficient interface testing.
[0004] In a first aspect, the embodiments of the present application provide an interface testing method, comprising:
[0005] Obtaining a plurality of input parameter data through an interface to be tested, and obtaining an interface testing rule corresponding to the interface to be tested; the interface testing rule comprises an input-output parameter mapping relationship formula;
[0006] Based on the plurality of input parameter data, performing first filling processing on a test sample template file to obtain an intermediate file; the intermediate file comprises test input parameter data of each test case in a plurality of test cases;
[0007] According to the test input parameter data of each test case and the input-output parameter mapping relationship formula, performing matching processing on historical test data to obtain a matching result corresponding to each test case;
[0008] Based on the matching result of each test case, performing second filling processing on the intermediate file to obtain a target file; the target file comprises test input parameter data and simulated output parameter data of each test case in a plurality of test cases;
[0009] Based on the target file, testing the interface to be tested.
[0010] In a second aspect, the embodiments of the present application provide an interface testing device, comprising:
[0011] The data acquisition unit is configured to acquire a plurality of input parameter data through the interface to be tested and acquire an interface test rule corresponding to the interface to be tested; the interface test rule comprises an input-output parameter mapping relationship.
[0012] The first file filling unit is configured to perform first filling processing on the test sample template file based on the plurality of input parameter data, to obtain an intermediate file; the intermediate file comprises test input parameter data of each test case in the plurality of test cases.
[0013] The historical data matching unit is configured to perform matching processing on historical test data according to the test input parameter data of each test case and the input-output parameter mapping relationship, to obtain a matching result corresponding to each test case.
[0014] The second file filling unit is configured to perform second filling processing on the intermediate file based on the matching result of each test case, to obtain a target file; the target file comprises test input parameter data and simulated output parameter data of each test case in the plurality of test cases.
[0015] The interface test unit is configured to test the interface to be tested based on the target file.
[0016] In a third aspect, an interface test device is provided, comprising a processor and a memory configured to store computer executable instructions, which, when executed, cause the processor to perform the interface test method of the first aspect.
[0017] In a fourth aspect, a computer readable storage medium is provided, configured to store computer executable instructions, which, when executed by a processor, implement the interface test method of the first aspect.
[0018] It can be seen that in the embodiment of the application, first, a plurality of parameter input data are acquired through the interface to be tested, and an interface test rule corresponding to the interface is acquired; the interface test rule comprises an input / output parameter mapping relationship formula; secondly, based on the plurality of parameter input data, first filling processing is performed on a test sample template file to obtain an intermediate file; the intermediate file comprises test parameter input data of each test case in a plurality of test cases; then, according to the test parameter input data of each test case and the input / output parameter mapping relationship formula, matching processing is performed on historical test data to obtain a matching result corresponding to each test case; then, based on the matching result of each test case, second filling processing is performed on the intermediate file to obtain a target file; the target file comprises test parameter input data and simulated output parameter data of each test case in a plurality of test cases; finally, the interface to be tested is tested based on the target file. In this way, the historical test data can be fully utilized in the process of generating simulated output parameter data, a large amount of repetitive calculation work in the interface test process is reduced, and the generation efficiency of test cases is improved. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments described in the specification, and other drawings can also be obtained according to these drawings without creative labor for those skilled in the art.
[0020] Figure 1 A processing flowchart of an interface test method provided by the embodiment of the present application;
[0021] Figure 2 A processing flowchart of another interface test method provided by the embodiment of the present application;
[0022] Figure 3 A processing flowchart of another interface test method provided by the embodiment of the present application;
[0023] Figure 4 A schematic diagram of an interface test device provided by the embodiment of the present application;
[0024] Figure 5 A structural schematic diagram of an interface test device provided by the embodiment of the present application. DETAILED DESCRIPTION
[0025] In order for 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 in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present specification, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor should fall within the protection scope of the present application.
[0026] Interface testing can be a test of testing the interface between system components, mainly used for testing the interface between the system and other external systems, and the interface between various sub-modules in the system, focusing on checking the exchange, transmission and control management process of data, and the mutual logical dependence between systems.
[0027] Test Case refers to the description of a test task for a specific software product, embodying test plans, methods, techniques and strategies. Its content includes test objectives, test environments, input data, test steps, expected results, testing scripts, etc., ultimately forming a document. Simply put, a test case is a set of test inputs, execution conditions and expected results prepared for a specific goal, used to verify whether a specific software requirement is met. A test case can contain the following four contents: case title, preconditions, test steps and expected results. The case title mainly describes the testing of a certain function; the preconditions refer to the conditions that the case title needs to meet; the test steps mainly describe the operation steps of the case; the expected results refer to the expected (development specification, requirement document, user requirement, etc.) requirements. The test case does not contain the actual results, and the test case is generated before testing, and only when the execution file corresponding to the test case is executed, the actual results will be generated.
[0028] The execution file can be a test script, which generally refers to a series of instructions for a specific test, which can be executed by an automated test tool.
[0029] In actual application, it is very common to test the same interface multiple times, and it is very likely that the variation of the data used in each test is not large. Therefore, in the process of generating the execution file of the test case for each interface test, there is a lot of repetitive work, which consumes a lot of time and energy of the test personnel, and the efficiency is low. In order to overcome this problem, the present application provides an interface testing method, which can fully utilize historical test data in the process of generating simulation input data corresponding to the test case, reduce a large amount of repetitive calculation work in the interface testing process, improve the generation efficiency of the test case, and thus improve the interface testing efficiency.
[0030] Reference Figure 1A flowchart of an interface test method provided by an embodiment of the present application is shown in FIG. 1. Figure 1 The interface test method can be executed by an interface test device, which can be a terminal device such as a mobile phone, a notebook computer, a smart interactive device, etc., or a server such as a standalone physical server, a server cluster, or a cloud server capable of cloud computing. Figure 1 The interface test method shown in FIG. 1 specifically includes the following steps:
[0031] In step S102, a plurality of input parameter data is obtained through the interface to be tested, and an interface test rule corresponding to the interface to be tested is obtained. The interface test rule includes an input-output parameter mapping relationship.
[0032] The interface to be tested can be an interface between a system and other external systems, or an interface between internal sub-modules of a system.
[0033] The interface to be tested can be pre-configured with a corresponding interface test rule. The interface test rule is configured with one or more test parameters. The test parameters include, but are not limited to, the number of preset input parameter fields, the name of each preset input parameter field, the number of preset output parameter fields, the name of each preset output parameter field, an input-output parameter mapping relationship, etc. The above-mentioned several test parameters are only exemplary and do not constitute a special limitation on the test parameters.
[0034] The number of preset input parameter fields can be one or multiple. The number of preset output parameter fields can be one or multiple.
[0035] The preset input parameter field is a pre-configured test parameter, while the input parameter field is an input parameter obtained through the interface to be tested and used for interface testing, and the two are not the same concept.
[0036] The input-output parameter mapping relationship is used to represent the association between the preset input parameter field and the preset output parameter field. In the case that the plurality of input parameter data obtained through the interface matches the input-output parameter mapping relationship in the interface test rule corresponding to the interface, the input-output parameter mapping relationship can also be used to represent the association between the input parameter field obtained through the interface and the preset output parameter field. The number of input-output parameter mapping relationships can be equal to the number of preset output parameter fields.
[0037] Each preset input parameter field can correspond to one or more field values. For example, the preset input parameter field "whether to perform A operation" can have the field value "yes" or "no"; the preset input parameter field "date" can have the field value "April 1st", "April 2nd", "April 3rd", etc. The same preset input parameter field can include multiple field values of different value types. For example, part of the field values of the preset input parameter field 1 are of the Boolean type, and the other part of the field values are of the string type.
[0038] Each preset output parameter field can correspond to one or more field values, and the field values of each preset output parameter field can be determined according to the input-output parameter mapping relationship and the field values of each input parameter field.
[0039] Each input parameter data in the plurality of input parameter data includes an input parameter field and a corresponding field value. The number of field values corresponding to each input parameter field can be one or more.
[0040] For example, the plurality of input parameter data includes input parameter data 1, input parameter data 2, and input parameter data 3, wherein the input parameter data 1 includes an input parameter field A and the field values a1, a2 corresponding to the input parameter field A, the input parameter data 2 includes an input parameter field B and the field value b1 corresponding to the input parameter field B, and the input parameter data 3 includes an input parameter field C and the field values c1, c2, c3 corresponding to the input parameter field C.
[0041] The input parameter data can be data in the form of a string. One input parameter data can correspond to one input parameter string, the field name of one input parameter field can correspond to one first substring, and one field value of one input parameter field can correspond to one second substring. For example, one input parameter string can include one first substring and one second substring in one-to-one correspondence, or one first substring and multiple second substrings in one-to-many correspondence.
[0042] For example, the preset input parameter fields are X1, X2, and X3, the preset output parameter fields are Y1, Y2, and Y3, and the input-output parameter mapping relationship is Y1 = X1, Y2 = X1 + X2, and Y3 = X3 / 2. The field value of Y1 is determined according to the field value of X1 and the input-output parameter mapping relationship Y1 = X1; the field value of Y2 is determined according to the field values of X1 and X2 and the input-output parameter mapping relationship Y2 = X1 + X2; and the field value of Y3 is determined according to the field values of X2 and X3 and the input-output parameter mapping relationship Y3 = X3 / 2.
[0043] The above three input-output parameter mapping relationships are only a few simple examples listed for ease of understanding.
[0044] In an embodiment, the independent variable of the input-output parameter mapping relationship formula can also not include the preset input parameter field. For example, the preset output parameter field Y1=t, where t is used to represent the time point at which the interface to be tested acquires multiple input parameter data.
[0045] In an embodiment, the input-output parameter mapping relationship formula can also be generated in the following manner: the preset input parameter field corresponds to N field values, the preset output parameter field corresponds to M field values, each of the N field values of the preset input parameter field can correspond to one of the M field values of the preset output parameter field, and each of the M field values of the preset output parameter field can correspond to one or more of the N field values of the preset input parameter field. M and N are natural numbers greater than 0. M and N can be the same or different in value.
[0046] For example, in the input-output parameter mapping relationship formula: the field value a1 of the preset input parameter field A corresponds to the field value b1 of the preset output parameter field B; the field value a2 of the preset input parameter field A corresponds to the field value b1 of the preset output parameter field B; and the field value a3 of the preset input parameter field A corresponds to the field value b2 of the preset output parameter field B.
[0047] In an embodiment, the input-output parameter mapping relationship formula can also be generated in the following manner: the field values of the preset input parameter field are filled into the preset condition template to generate an input parameter condition, and whether the input parameter condition is satisfied corresponds to one field value of the preset output parameter field.
[0048] For example, in the interface test rule, the preset input parameter field can be configured as input parameter field 1, input parameter field 2, and input parameter field 3, the preset output parameter field can be configured as output parameter field 1 and output parameter field 2, the input-output parameter mapping relationship formula corresponding to the output parameter field 1 can be configured as: if the field value of the input parameter field 1 is a1, the field value of the output parameter field 1 is x1, and if the field value of the input parameter field 1 is not a1, the field value of the output parameter field 1 is x2, and the input-output parameter mapping relationship formula corresponding to the output parameter field 2 can be configured as: the field value of the output parameter field 2 is the sum of the field values of the input parameter field 1, the input parameter field 2, and the input parameter field 3.
[0049] In step S104, based on the multiple input parameter data, the first filling processing is performed on the test sample template file to obtain an intermediate file. The intermediate file includes the test input parameter data of each test case in the multiple test cases.
[0050] Optionally, the number of field values of each input parameter field is at least one; based on the plurality of input parameter data, the test sample template file is subjected to first filling processing to obtain an intermediate file, including: generating a plurality of input parameter field value combinations according to each input parameter field and at least one field value of each input parameter field, and determining each input parameter field value combination as the test input parameter data of one test case; the number of field values included in each input parameter field value combination is the same as the number of the plurality of input parameter data, and the field values included in each input parameter field value combination correspond to each input parameter field one by one; and the test sample template file is subjected to first filling processing according to the test input parameter data of each test case to obtain the intermediate file.
[0051] The number of field values of each input parameter field can be one or multiple.
[0052] According to each input parameter field and at least one field value of each input parameter field, a plurality of input parameter field value combinations are generated, and each input parameter field value combination is determined as the test input parameter data of one test case. The number of field values included in each input parameter field value combination is the same as the number of the plurality of input parameter fields, and the field values included in each input parameter field value combination correspond to the plurality of input parameter fields one by one.
[0053] For example, the number of obtained input parameter fields is 3, which are input parameter 1, input parameter 2 and input parameter 3. Input parameter 1 has two field values a1 and a2; input parameter 2 has three field values b1, b2 and b3; and input parameter 3 has three field values c1, c2 and c3. Then, the 2 field values of input parameter 1, the 3 field values of input parameter 2 and the 3 field values of input parameter 3 are freely combined to generate 2*3*3=18 input parameter field value combinations: (a1, b1, c1), (a1, b1, c2), (a1, b1, c3)…(a2, b3, c3). Each input parameter field value combination includes one field value of input parameter 1, one field value of input parameter 2 and one field value of input parameter 3.
[0054] In another embodiment, the number of obtained input parameter fields can be one or multiple. According to each input parameter field and at least one field value of each input parameter field, the test input parameter data of a test case is generated, and there are the following cases:
[0055] (1) If only one input parameter field A is obtained through the interface, and the input parameter field A has only one field value a1, only one test case can be generated based on a1, and the test input parameter data of the test case is "a1".
[0056] (2) If only one input parameter field B is obtained through the interface, and the input parameter field B has multiple field values b1, b2, b3, based on b1, b2, and b3, three test cases can be generated, the test input data of test case 1 is "b1", the test input data of test case 2 is "b2", and the test input data of test case 3 is "b3".
[0057] (3) If multiple input parameter fields: input parameter field A and input parameter field B are obtained through the interface, and the input parameter field A has only one field value a1, and the input parameter field B has only one field value b1, based on a1 and b1, only one test case can be generated, and the input parameter field value combination corresponding to the test case is "a1b1".
[0058] (4) If multiple input parameter fields: input parameter field A and input parameter field B are obtained through the interface, and at least one input parameter field has more than one field value, for example, the input parameter field A has only one field value a1, and the input parameter field B has multiple field values b1, b2, multiple input parameter field value combinations "a1b1" and "a1b2" can be generated, the test input data of test case 1 is "a1b1", the test input data of test case 2 is "a1b2", and the input parameter field value combination "a1b1" includes one field value a1 of the input parameter field A and one field value b1 of the input parameter field B, and the input parameter field value combination "a1b2" includes one field value a1 of the input parameter field A and one field value b2 of the input parameter field B.
[0059] In specific implementation, the number of input parameter field value combinations can be determined as the number of test cases, and each test case corresponds to an input parameter field value combination. In addition, in the case of pre-configuring to discard at least one input parameter field value combination, the number of test cases can also be less than the number of input parameter field value combinations. For example, the test worker determines that (a1, b1, c3) is impossible to occur according to experience, and it is not necessary to generate the test case corresponding to (a1, b1, c3), so the input parameter field value combination can be pre-configured to be discarded.
[0060] According to the test input data of each test case, the test sample template file is preliminarily filled. In specific implementation, the test sample template file can be an Excel file, and in each row corresponding to each test case in the Excel file, the to-be-filled area of each input parameter field can be preliminarily filled based on the field values included in the input parameter field value combination. The preliminary filling is automatically performed by the interface test device executing the interface test method, rather than manually performed.
[0061] For example, the test case 1 corresponds to the input parameter field value combination (a1, b1, c1, d1), the interface test device automatically fills a1 into the cell intersected by the input parameter 1 and the test case 1, fills b1 into the cell intersected by the input parameter 2 and the test case 1, fills c1 into the cell intersected by the input parameter 3 and the test case 1, and fills d1 into the cell intersected by the input parameter 4 and the test case 1.
[0062] In step S106, the historical test data is matched according to the test input parameter data of each test case and the input-output parameter mapping relationship, to obtain a matching result corresponding to each test case.
[0063] One preset output parameter field corresponds to one output parameter field in the simulation output parameter data. The input-output parameter mapping relationship can be used to represent the association between the input parameter field obtained through the interface and the output parameter field in the simulation output parameter data.
[0064] The simulation output parameter data can be the simulation field value of each output parameter field used for comparison with the real interface test result.
[0065] Optionally, the historical test data includes a plurality of historical relationship formulas and calculation data of each historical relationship formula; the historical test data is matched according to the test input parameter data of each test case and the input-output parameter mapping relationship, to obtain a matching result corresponding to each test case, including: substituting the test input parameter data of each test case into the input-output parameter mapping relationship to generate a target relationship formula corresponding to each test case; calculating the matching degree of the target relationship formula corresponding to each test case and each historical relationship formula in the historical test data to obtain a matching degree set corresponding to each test case; and determining the matching result corresponding to each test case according to the matching degree set corresponding to each test case.
[0066] In specific implementation, the historical test data of the interface to be tested can be obtained. The historical test data includes a plurality of generation records of historical test cases. Each generation record of the historical test case includes a historical relationship formula and calculation data of the historical relationship formula. Each historical test case corresponds to a historical relationship formula, and the historical relationship formula is used to represent the association between the input parameter field and the output parameter field of the corresponding historical test case.
[0067] The test input parameter data of each test case is substituted into the input-output parameter mapping relationship to generate a corresponding target relationship formula. For example, the test input parameter data of the test case 1 includes the field value a1 of the input parameter field A and the field value b2 of the input parameter field B, a1 and b1 are substituted into the input-output parameter mapping relationship C=1 / 2(A+B) to obtain the target relationship formula: C=1 / 2*(a1+b1).
[0068] The matching degree can be reflected by the similarity between the target relational expression and the historical relational expression.
[0069] The matching degree of each test case corresponding to the target relational expression and each historical relational expression in the historical test data is calculated to obtain a matching degree set corresponding to each test case. The similarity between the calculation formula part of the target relational expression corresponding to each test case and the calculation formula part in each historical relational expression can be calculated to obtain a similarity set.
[0070] For example, the historical relational expression 1 is C = 1 / 2*(a1+b2); the historical relational expression 2 is C = a1; and the historical relational expression 3 is C = 1 / 2*(a1+b1). The similarity between the formula part 1 / 2*(a1+b1) of the target relational expression and the formula part 1 / 2*(a1+b2) of the historical relational expression 1 is k1; the similarity between the formula part 1 / 2*(a1+b1) of the target relational expression and the formula part a1 of the historical relational expression 2 is k2; and the similarity between the formula part 1 / 2*(a1+b1) of the target relational expression and the formula part 1 / 2*(a1+b1) of the historical relational expression 3 is k3, and k3>k1>k2. The similarity set includes k1, k2, and k3.
[0071] The matching degree set and the matching result have a preconfigured mapping relationship. Accordingly, the matching result corresponding to each test case can be determined according to the matching degree set corresponding to each test case.
[0072] Optionally, the matching result corresponding to each test case is determined according to the matching degree set corresponding to each test case, including: for any one test case, the matching degrees in the matching degree set corresponding to the any one test case are sorted; based on the sorting result, the historical relational expression with the highest matching degree is determined as the target historical relational expression corresponding to the any one test case; in the preset multiple matching degree threshold intervals, the matching degree threshold interval to which the matching degree of the target historical relational expression belongs is determined as the target threshold interval, and the matching result corresponding to the target threshold interval is determined as the matching result corresponding to the any one test case.
[0073] For any one test case, each matching degree in the matching degree set corresponding to the test case can be sorted; based on the sorting result, the historical relational expression with the highest matching degree is determined as the target historical relational expression corresponding to the test case. For example, the historical test data includes N historical relational expressions, some of which may have nothing to do with the target relational expression, some of which may be partially similar to the target relational expression, and some of which may be completely identical to the target relational expression. The higher the matching degree, the less the workload of simulation calculation for generating simulation parameter data. If the matching degree is 100%, simulation calculation can be directly called without simulation calculation. The historical relational expression with the highest matching degree is obtained from the historical test data, and the matching result is determined based on the historical relational expression with the highest matching degree, which can maximize the use of historical test data and reduce the workload of simulation calculation.
[0074] For example, the matching degree set corresponding to the test case includes: the matching degree of historical relational expression 1 is 88%, the matching degree of historical relational expression 2 is 39%, the matching degree of historical relational expression 3 is 0%, and the matching degree of historical relational expression 4 is 100%. According to the matching degree from high to low: the matching degree of historical relational expression 4 is 100%> the matching degree of historical relational expression 1 is 88%> the matching degree of historical relational expression 2 is 39%> the matching degree of historical relational expression 3 is 0%. The historical relational expression 4 with the highest matching degree is determined as the target historical relational expression corresponding to the test case.
[0075] For any one test case, in the preset multiple matching degree threshold intervals, the matching degree threshold interval to which the matching degree of the target historical relational expression corresponding to the test case belongs is determined as the target threshold interval, and the matching result corresponding to the target threshold interval is determined as the matching result corresponding to the test case.
[0076] Step S108, based on the matching result of each test case, the intermediate file is subjected to a second filling process to obtain a target file; the target file includes test input data and simulation output data of each test case in the multiple test cases.
[0077] Optionally, based on the matching result of each test case, the intermediate file is subjected to a second filling process to obtain a target file, including: determining the data generation mode of the simulation output data corresponding to each test case according to the matching result corresponding to each test case; generating simulation output data of each test case according to the data generation mode of the simulation output data corresponding to each test case; and performing a second filling process on the intermediate file according to the simulation output data of each test case to obtain a target file.
[0078] The data generation mode includes but is not limited to:
[0079] Data generation mode 1: read the calculation result of the target historical relational expression from the historical test data, and determine the calculation result as the simulation parameter data.
[0080] Data generation mode 2: read the calculation flow data of the target historical relational expression from the historical test data, modify the calculation flow data in combination with the target relational expression, and perform simulation calculation to obtain the simulation parameter data.
[0081] Data generation mode 3: perform simulation calculation according to the target relational expression to obtain the simulation parameter data.
[0082] Among the above three data generation modes, the calculation workload of data generation mode 1 is the smallest, the calculation workload of data generation mode 2 is moderate, and the calculation workload of data generation mode 3 is the largest.
[0083] In actual application, in the process of performing multiple tests on the interface to be tested, adjacent two tests may only change a small amount of parameters, so that in the latter one of the adjacent two tests, most of the test cases can read the calculation result of the target historical relational expression from the historical test data, and determine the calculation result as the simulation parameter data; a small amount of test cases can read the calculation flow data of the target historical relational expression from the historical test data, modify the calculation flow data in combination with the target relational expression, and perform simulation calculation to obtain the simulation parameter data; and a very small amount of test cases can perform simulation calculation according to the target relational expression to obtain the simulation parameter data.
[0084] Therefore, in combination with multiple different data generation modes, the historical test data can be reused, the repeated calculation of the same data can be reduced, the calculation workload in the generation process of the test cases can be reduced, and the interface test efficiency can be improved.
[0085] Optionally, according to the matching result corresponding to each test case, a data generation manner of the simulation out-parameter data corresponding to each test case is determined, including: if the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is greater than a first threshold, the data generation manner corresponding to any test case is determined as: reading result data from the calculation data of the target historical relational expression, and determining the result data as the simulation out-parameter data of any test case; if the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is less than or equal to the first threshold and greater than a second threshold, the data generation manner corresponding to any test case is determined as: reading calculation flow data from the calculation data of the target historical relational expression, and performing first simulation calculation processing according to the calculation flow data and the target relational expression to obtain first simulation result, and determining the first simulation result as the simulation out-parameter data of any test case; if the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is less than or equal to the second threshold and greater than a third threshold, the data generation manner corresponding to any test case is determined as: performing second simulation calculation processing according to the target relational expression to obtain second simulation result, and determining the second simulation result as the simulation out-parameter data of any test case.
[0086] For example, the first matching result can correspond to a matching degree of 100%, in which case the calculation result in the historical test data can be directly read and filled into the table. The second matching result can correspond to a matching degree less than 100% and greater than 50%, in which case the calculation flow data in the historical test data is read, and simulation calculation is performed in combination with the calculation flow data and the target relational expression, which can reduce the workload of part of the simulation calculation, and a small amount of modification is made on the basis of the existing calculation flow data and simulation calculation is performed, so that the simulation out-parameter data can be obtained. The third matching result can correspond to a matching degree less than 50%, in which case it is difficult to reduce the calculation workload even in combination with the historical data, and simulation calculation needs to be performed independently according to the target relational expression.
[0087] Table 1 shows a target file provided by an embodiment of the present application.
[0088] Table 1
[0089] A B C D E / 1 TRUE [0,1,0] 0 0 0 TURE [] 0 9 1 FLASE [1,1,1] 1 4 1 TURE [1,0,1] 1 2 1 FLASE [0,0,0] 1
[0090] As shown in Table 1, each row corresponds to a test case. The test case template file is subjected to first filling processing according to the test input parameter data of each test case, so that an intermediate file is obtained.
[0091] For example, the multiple test input parameter data of the test case 1 includes the field value “ / ” of the input field A, the field value “1” of the input field B and the field value “TRUE” of the input field C, the multiple test input parameter data of the test case 2 includes the field value “0” of the input field A, the field value “0” of the input field B and the field value “TRUE” of the input field C, and the like, which are not listed one by one here.
[0092] After the multiple simulation output parameter data of each test case are generated, the multiple simulation output parameter data can be filled in the intermediate file, as shown in Table 1. For example, the multiple simulation output parameter data of the test case 1 includes the field value “[0, 1, 1]” of the input field D and the field value “0” of the input field B, the multiple simulation output parameter data of the test case 2 includes the field value “[]” of the input field D and the field value “0” of the input field B, and the like, which are not listed one by one here.
[0093] In step S110, the interface to be tested is tested based on the target file.
[0094] The target file can be used to generate the execution file of the multiple test cases, and then the execution file of each test case is executed through the interface to implement the interface test.
[0095] Optionally, the testing of the interface to be tested based on the target file comprises: converting the target file into the execution file of each test case according to a preset file conversion rule; executing the execution file of each test case to obtain the actual output parameter data of each test case fed back by the interface to be tested; and generating the test result of the interface to be tested according to the simulation output parameter data of each test case and the actual output parameter data of each test case.
[0096] Taking one sheet of the excel file as an example, the preset file conversion rule can be that, according to the number of input fields and the number of output fields configured in advance, it is determined in the sheet of the excel file which columns are the input fields and which columns are the output fields, and the number of first sub-code templates corresponding to each input field and the number of second sub-code templates corresponding to each output field included in the preset code template of the execution file are determined according to the number of input fields and the number of output fields.
[0097] Each row in the sheet corresponds to a test case, and for any test case, the field value of each input field and the field value of each output field in the row are read. The field value of each input field is filled into the corresponding first sub-code template, and the field value of each output field and the relational expression code used to represent the association between the output field and the multiple input fields are filled into the corresponding second sub-code template to generate the execution file of each test case.
[0098] The execution file of the test case can be a json message execution file.
[0099] In an embodiment, the preset file conversion rule can include a preset configuration rule; and converting the target file into the execution file of each test case according to the preset file conversion rule includes: performing configuration processing on the preset configuration file according to the preset configuration rule and the test input parameter data and the simulation output parameter data of each test case; and generating the execution file of each test case according to the preset configuration file after the configuration processing.
[0100] The preset configuration file can be a YAML (YAML Ain't a Markup Language, another markup language) configuration file, or a configuration file in other languages. YAML language is a language specially used for writing configuration files, which is convenient for human reading and writing, and has the following characteristics: case sensitive; using indentation to represent hierarchical relationship; not allowing to use Tab key when indenting, only allowing to use spaces; the number of spaces for indentation is not important, as long as the elements of the same level are aligned on the left, and the like.
[0101] In a specific implementation, the preset YAML configuration file can be configured and processed according to the preset configuration rule and the test input parameter data and the simulation output parameter data of each test case.
[0102] The preset configuration rule is used to represent how to configure and process the YAML configuration file according to the target file.
[0103] In an embodiment, the target file is an Excel table after filling processing, and the preset configuration rule can specify how to configure and process the YAML configuration file based on the number of rows, the number of columns, the input parameter field, the output parameter field and the values of each field in the Excel table.
[0104] For example, the preset configuration rule specifies that based on the number of rows in the Excel table, the number of test cases included in the Excel table is determined, and then based on the number of test cases, the number of YAML configuration files used to generate the execution file of each test case is determined. One test case corresponds to one YAML configuration file used to generate the execution file of the corresponding test case.
[0105] For another example, the preset configuration rule specifies that based on the field value of the input parameter field, the preset area of the YAML configuration file is filled and processed.
[0106] After obtaining the YAML configuration file after configuration processing corresponding to each test case, the YAML configuration file can be called to generate the execution file of each test case based on the preset code template.
[0107] The YAML configuration file can be used to fill in the preset code template to obtain code text, and the code text is determined as the code text of the execution file of the test case. Further, running the code text can be regarded as executing the execution file of the test case.
[0108] By presetting the configuration rules and the preset YAML configuration file, the code of the execution file can be decoupled from the Excel table, and the data in the filled Excel table can be reflected in the converted execution file without manual programming or modification of the code by the programmer, thereby reducing the dependence on the programming skills of the test staff in the interface test process. The test staff does not need to master the programming skills and can automatically generate the execution file of each test case through the target file.
[0109] In specific implementation, the Jenkins can be used to schedule tasks to execute the execution file of each test case.
[0110] The execution file of each test case is executed to obtain actual parameter-out data of the test case fed back by the interface to be tested.
[0111] The actual parameter-out data can be data fed back by the interface after executing the execution file of each test case through the interface. The actual parameter-out data can be real parameter-out data obtained after the interface test on the input parameter data. The actual parameter-out data can be the same as or different from the simulated parameter-out data.
[0112] In one embodiment, the target file can be converted into the execution file of the first test case according to the preset file conversion rule, the execution file of the first test case is executed, the target file is converted into the execution file of the second test case, the execution file of the second test case is executed, and so on. The target file is converted into the execution file of the Kth test case, and the execution file of the Kth test case is executed. K is the number of test cases corresponding to the target file, which can be a natural number greater than 0.
[0113] In another embodiment, the target file can be converted into K test case execution files according to the preset file conversion rule, and each of the K test case execution files is executed. That is, the conversion is unified, and after the conversion of each test case file is completed, the execution file of each test case is executed.
[0114] According to the simulated parameter-out data and the actual parameter-out data, a test result of the interface is generated.
[0115] For any one test case, if the simulation output parameter data and the actual output parameter data are exactly the same, it means that the interface test is correct, and there is no parameter that needs special attention and adjustment. If the simulation output parameter data and the actual output parameter data are different, it means that at least one of the input parameter data, the test scene environment data, and the configured test strategy has a problem, and the error parameter needs to be checked and corrected.
[0116] In a specific implementation, in the decision-making scene, an assertion rule can be configured, and the actual output parameter data is processed according to the assertion rule to obtain the assertion result of the interface to be tested. The assertion result is analyzed and processed to generate a test report. The test report can be in the form of a log, and the test report can carry the actual output parameter data inconsistent with the simulation output parameter data and the related information of the corresponding test case.
[0117] The assertion processing can be a "judgment" work, for example, the actual output parameter data that the test worker wants to get is 200, but the actual output parameter data obtained is 404. The cumbersome operation is to manually open the interface feedback data and use the eyes to see if it is 200. If the assertion is used, the program can automatically judge whether the actual output parameter data is 200, and manual operation and viewing are not needed. The convenience of assertion is particularly obvious when a large number of requests need to be tested, and a lot of time can be saved.
[0118] The pre-configured assertion rule, for example, judges the age region of the field value of the output parameter field "age" in the actual output parameter data, for example, between 0-18 years old, between 18-50 years old, and greater than 50 years old. If the field value of the output parameter field "age" in the obtained actual output parameter data is between 0-18 years old, the test result of the test case is returned as test result 1. If the field value of "age" is between 18-50 years old, the test result of the test case is returned as test result 1. If the field value of "age" is greater than 50 years old, the test result of the test case is returned as test result 3. The test results of various test cases are counted to obtain the test result of the interface.
[0119] In one embodiment, according to the simulation output parameter data and the actual output parameter data, the assertion processing can be performed to determine whether the simulation output parameter data and the actual output parameter data are the same.
[0120] Optionally, according to the simulation output parameter data of each test case and the actual output parameter data of each test case, the test result of the interface to be tested is generated, including: if the simulation output parameter data and the actual output parameter data of the plurality of test cases are not completely consistent, determining the test case in which the simulation output parameter data and the actual output parameter data are not matched as a target test case, and determining the test case in which the simulation output parameter data and the actual output parameter data are matched as a non-target test case; according to the pre-configured assertion rule, performing assertion processing on the target test case to obtain the assertion result of the target test case; and statistically processing the assertion result of the target test case and the test result of the non-target test case to obtain the test result of the interface to be tested.
[0121] After step S108 is executed, the simulation output parameter data of each test case in the plurality of test cases can be obtained, and after the steps of "converting the target file into an execution file of each test case according to a preset file conversion rule" and "executing the execution file of each test case to obtain the actual output parameter data of each test case fed back by the interface to be tested" are executed, the actual output parameter data of each test case in the plurality of test cases can be obtained.
[0122] The plurality of test cases may exist a case in which the simulation output parameter data and the actual output parameter data are not completely consistent, that is, the simulation output parameter data of at least one test case in the plurality of test cases is different from the corresponding actual output parameter data.
[0123] In the case that the simulation output parameter data and the actual output parameter data are completely consistent, the assertion processing is not triggered.
[0124] In the implementation, the assertion rule can be configured in the decision scenario. In the case that the simulation output parameter data and the actual output parameter data are not completely consistent, the actual output parameter data of the target test case is processed according to the assertion rule to obtain the assertion result of the interface to be tested. The assertion result is analyzed and processed to generate a test report. The test report can be in the form of a log, and the test report can carry the actual output parameter data inconsistent with the simulation output parameter data and the related information of the corresponding test case.
[0125] The assertion processing can be a "judgment" work, for example, the test worker expects the actual output parameter data to be 200, but the actual output parameter data obtained is 404. The cumbersome operation is to manually open the data fed back by the interface and use the eyes to see whether it is 200. If the assertion is used, the program can automatically judge whether the actual output parameter data is 200, and manual operation and viewing are not needed. The convenience of the assertion is particularly obvious when a large number of requests need to be tested, and a lot of time can be saved.
[0126] The pre-configured assertion rule, for example, judges the age region of the field value of the actual out-parameter data in the out-parameter field "age", for example, between 0-18 years old, between 18-50 years old, and greater than 50 years old. If the field value of the actual out-parameter data in the out-parameter field "age" obtained is between 0-18 years old, the test result of the test case is returned as test result 1. If the field value of "age" obtained is between 18-50 years old, the test result of the test case is returned as test result 1. If the field value of "age" obtained is greater than 50 years old, the test result of the test case is returned as test result 3. In addition, the test result of the non-target test case can be determined as test result 4 in advance. The test results of each test case are counted to obtain the test result of the interface.
[0127] In another embodiment, according to the simulation out-parameter data and the actual out-parameter data, the test result of the interface is generated, including: counting the number of test cases in which the simulation out-parameter data matches the actual out-parameter data as a first number; counting the number of test cases in which the simulation out-parameter data does not match the actual out-parameter data as a second number; determining the prediction accuracy of the interface according to the first number and the second number; determining the probability threshold partition in which the prediction accuracy is located as the target partition in a plurality of pre-divided probability threshold partitions, and determining the test result corresponding to the target partition as the test result of the interface.
[0128] The prediction accuracy can be the ratio of the second number to the first number.
[0129] For each out-parameter field, a plurality of probability threshold partitions can be pre-divided, for example, the probability threshold partitions corresponding to the out-parameter field 1 include: [0, 0.8), and [0.8, 1]. If the prediction accuracy of test case 1 for the out-parameter field 1 is within [0, 0.8), the test result 1 corresponding to [0, 0.8) is determined as the test result of the out-parameter field 1 in test case 1. The test results of each test case in the out-parameter field 1 are counted as the test result of the out-parameter field 1. The test results of each out-parameter field are counted to obtain the interface test result.
[0130] Optionally, after generating the test result of the interface to be tested according to the simulation out-parameter data of each test case and the actual out-parameter data of each test case, the interface test method further includes: judging whether the test result triggers a pre-configured alarm rule; if yes, generating an alarm information based on the assertion result of the target test case.
[0131] The interface can be pre-configured with an alarm rule. The alarm rule includes, but is not limited to, one or more of the following sub-rules: a first sub-rule for indicating under what circumstances alarm information needs to be sent, a second sub-rule for indicating to whom the alarm information is sent, a third sub-rule for indicating in what form the alarm information is sent, and a fourth sub-rule for indicating how the alarm information is generated.
[0132] The alarm information sending form can be a mail, a log, or other forms.
[0133] Exemplarily, the alarm rule can be configured as follows: during the process of performing an interface test, if the proportion of the target test case in the number of all test cases is greater than or equal to a first proportion threshold, it is determined that the first alarm information needs to be sent to the rule writing staff of the interface test rule, and the first alarm information is generated based on the assertion result of the target test case.
[0134] If it is determined that the test result triggers the alarm rule, alarm information carrying the comparison result of the simulation out-parameter data and the actual out-parameter data of the target test case can be generated based on the assertion result of the target test case. Further, the alarm information can be sent to the designated test staff in the form of a log and a mail.
[0135] In the embodiment of the interface test method as shown in Figure 1 , first, a plurality of parameter data are obtained through the interface to be tested, and an interface test rule corresponding to the interface is obtained; the interface test rule includes an in-out parameter mapping relationship formula; second, based on the plurality of parameter data, a first filling processing is performed on a test sample template file to obtain an intermediate file; the intermediate file includes test parameter data of each test case in the plurality of test cases; third, according to the test parameter data of each test case and the in-out parameter mapping relationship formula, a matching processing is performed on historical test data to obtain a matching result corresponding to each test case; fourth, based on the matching result of each test case, a second filling processing is performed on the intermediate file to obtain a target file; the target file includes test parameter data and simulation out-parameter data of each test case in the plurality of test cases; and finally, the interface to be tested is tested based on the target file. In this way, the historical test data can be fully utilized in the process of generating simulation out-parameter data, the amount of repetitive calculation work in the interface test process is reduced, and the generation efficiency of test cases is improved.
[0136] Based on the same technical concept as the foregoing method embodiments, the embodiments of the present application also provide another embodiment of an interface test method. Figure 2 The processing flowchart of another embodiment of an interface test method provided by the embodiments of the present application is shown in
[0137] Referring to Figure 2 , the interface test method specifically includes steps S202 to S208.
[0138] Step S202, data preparation.
[0139] Corresponding to the foregoing Figure 1 In step S102 of the embodiment, the data to be prepared includes: a plurality of input parameter data obtained through the interface to be tested. In addition, since the interface to be tested is pre-configured with a corresponding interface test rule, the input parameter mapping relationship can be read from the interface test rule when the data preparation step is executed.
[0140] Step S204, complete the test data.
[0141] Corresponding to the foregoing Figure 1 Steps S104-S108 in the embodiment.
[0142] After obtaining a plurality of input parameter data, a first filling processing can be performed on the test case template file based on the plurality of input parameter data to obtain an intermediate file; a matching processing is performed on the historical test data according to the test input parameter data of each test case and the input / output parameter mapping relationship to obtain a matching result corresponding to each test case; and a second filling processing is performed on the intermediate file based on the matching result of each test case to obtain a target file. The target file includes test input parameter data and simulated output parameter data of each test case in the plurality of test cases.
[0143] The completed test data obtained after step S204 is performed can be a target file.
[0144] The simulated output parameter data in the target file can be simulated and calculated based on the historical test data. Specifically, the data field source of the test input parameter data, i.e., the interface from which the test input parameter data is obtained, can be determined to obtain a strategy result corresponding to the strategy of the interface. Further, the historical test data of the strategy is obtained according to the strategy result. Further, the historical test data is matched based on the test input parameter data to obtain a corresponding matching result, so as to simulate and calculate the simulated output parameter data according to the matching result.
[0145] Step S206, test execution.
[0146] The test execution can be generating an execution file of each test case in a plurality of test cases corresponding to the target file according to the target file obtained after step S204 is executed, and executing the execution file of each test case.
[0147] Step S208, test completion.
[0148] After executing the executable file for each test case, the actual output parameter data of that test case can be obtained from the interface under test. Based on the simulated output parameter data of each test case and the actual output parameter data of each test case, the test results of the interface under test can be generated, thus completing the interface testing.
[0149] Since the technical concept is the same, the description in this embodiment is relatively simple. For the relevant parts, please refer to the corresponding descriptions of the method embodiments provided above.
[0150] Based on the same technical concept as the aforementioned method embodiments, Figure 1 The interface testing method in the embodiment can be simply described as follows: Figure 3 As shown, Figure 3 A flowchart illustrating another interface testing method provided in this application embodiment. Figure 3 The interface testing method described herein can be summarized in the following steps:
[0151] S302, Data Preparation. Equivalent to the aforementioned... Figure 1 In step S102 of this embodiment, the data to be prepared includes multiple input parameter data obtained through the interface to be tested. Furthermore, since the interface to be tested is pre-configured with corresponding interface testing rules, the input parameter mapping relationship can be read from these interface testing rules when executing the data preparation step.
[0152] S304 generates test input parameter data for test cases based on the combination of input parameter field values.
[0153] Equivalent to the aforementioned Figure 1 Step S104 in the embodiment can be found in the following details. Figure 1 The step in the embodiment is: "Based on each input parameter field and at least one field value of each input parameter field, generate multiple input parameter field value combinations, and determine each input parameter field value combination as test input parameter data for a test case; the number of field values included in each input parameter field value combination is the same as the number of the multiple input parameter data, and the field values included in each input parameter field value combination correspond one-to-one with each input parameter field."
[0154] After obtaining the test input parameter data for each test case, the test sample template file can be filled in for the first time to obtain the intermediate file.
[0155] S306 simulates and calculates output parameters based on the test input data and interface test rules.
[0156] Equivalent to the aforementioned Figure 1 Steps S106-S108 in the embodiment.
[0157] The interface test rule includes an input-output parameter mapping relationship formula, which can be obtained in the foregoing step S302.
[0158] According to the test input parameter data and the interface test rule, simulation calculation is performed to simulate the simulation output parameter data. The simulation output parameter data can be obtained by matching the historical test data according to the test input parameter data of each test case and the input-output parameter mapping relationship formula. The matching result corresponding to each test case is obtained. Based on the matching result of each test case, the intermediate file is subjected to a second filling processing to obtain the target file. The target file includes the test input parameter data and the simulation output parameter data of each test case in the plurality of test cases.
[0159] Different matching results correspond to different data generation methods. If the data generation method is the foregoing data generation method 1, the calculation result of the target historical relationship formula is read from the historical test data, and no simulation calculation is required. Figure 1 The data generation method 1 in the embodiment only needs to read the calculation result of the target historical relationship formula from the historical test data, and no simulation calculation is required. If the data generation method is the foregoing data generation method 2, a small amount of simulation calculation is required on the basis of the historical test data. Figure 1 The data generation method 2 in the embodiment requires a small amount of simulation calculation on the basis of the historical test data. If the data generation method is the foregoing data generation method 3, simulation calculation is performed according to the target relationship formula. Figure 1 The data generation method 3 in the embodiment performs simulation calculation according to the target relationship formula.
[0160] S308, performing interface test.
[0161] The test interface execution can be to generate an execution file corresponding to each test case in the plurality of test cases according to the target file obtained after the step S306 is performed, and to execute the execution file of each test case.
[0162] After the execution file of each test case is executed, the actual output parameter data of the test case fed back by the interface to be tested can be obtained. The steps S308-S312 are equivalent to the step S110 in the embodiment. Figure 1
[0163] S310, comparing the actual output parameter data and the simulation output parameter data.
[0164] After the simulation output parameter data of each test case is calculated through the step S306, and the actual output parameter data of each test case is obtained through the step S308, the actual output parameter data and the simulation output parameter data of each test case can be compared to generate a test result of the interface to be tested.
[0165] S312, outputting the difference result.
[0166] The test result of the interface to be tested is outputted, and the test result can reflect the difference between the actual output parameter data and the simulation output parameter data.
[0167] Since the technical concepts are the same, the embodiments described in this embodiment are relatively simple, and the relevant parts can be seen from the corresponding description of the method embodiments provided above.
[0168] In the above embodiments, an interface test method is provided, and a corresponding interface test device is also provided, which will be described below with reference to the accompanying drawings.
[0169] Figure 4 A schematic diagram of an interface test device provided in the embodiments of the present application is shown.
[0170] The embodiments of the present application provide an interface test device 400, which comprises:
[0171] The data acquisition unit 401 is configured to acquire a plurality of input parameter data through the interface to be tested, and acquire an interface test rule corresponding to the interface to be tested; the interface test rule comprises an input / output parameter mapping relationship formula;
[0172] The first file filling unit 402 is configured to perform first filling processing on the test sample template file based on the plurality of input parameter data, to obtain an intermediate file; the intermediate file comprises test input parameter data of each test case in the plurality of test cases;
[0173] The historical data matching unit 403 is configured to perform matching processing on historical test data according to the test input parameter data of each test case and the input / output parameter mapping relationship formula, to obtain a matching result corresponding to each test case;
[0174] The second file filling unit 404 is configured to perform second filling processing on the intermediate file based on the matching result of each test case, to obtain a target file; the target file comprises test input parameter data and simulated output parameter data of each test case in the plurality of test cases;
[0175] The interface test unit 405 is configured to test the interface to be tested based on the target file.
[0176] Optionally, the historical test data comprises a plurality of historical relationship formulas and calculation data of each historical relationship formula; the historical data matching unit 403 comprises:
[0177] The substitution subunit is configured to substitute the test input parameter data of each test case into the input / output parameter mapping relationship formula, to generate a target relationship formula corresponding to each test case;
[0178] The calculation subunit is configured to calculate a matching degree of the target relationship formula corresponding to each test case and each historical relationship formula in the historical test data, to obtain a matching degree set corresponding to each test case;
[0179] The first determination subunit is configured to determine the matching result corresponding to each test case according to the matching degree set corresponding to each test case.
[0180] Optionally, the first determining subunit is specifically configured to:
[0181] For any one test case, sort each matching degree in the matching degree set corresponding to the any one test case;
[0182] Based on the sorting result, determine the historical relational expression with the highest matching degree as the target historical relational expression corresponding to the any one test case;
[0183] In the preset plurality of matching degree threshold intervals, determine the matching degree threshold interval to which the matching degree of the target historical relational expression belongs as a target threshold interval, and determine the matching result corresponding to the target threshold interval as the matching result corresponding to the any one test case.
[0184] Optionally, the second file filling unit 404 comprises:
[0185] The second determining subunit is configured to determine, according to the matching result corresponding to each test case, a data generation manner of the simulation output parameter data corresponding to each test case;
[0186] The generating subunit is configured to generate the simulation output parameter data of each test case according to the data generation manner of the simulation output parameter data corresponding to each test case;
[0187] The filling subunit is configured to perform a second filling processing on the intermediate file according to the simulation output parameter data of each test case to obtain a target file.
[0188] Optionally, the second determining subunit is specifically configured to:
[0189] If the matching result corresponding to any one test case represents that the matching degree of the target historical relational expression is greater than a first threshold value, it is determined that the data generation manner corresponding to the any one test case is to read result data from the calculation data of the target historical relational expression, and the result data is determined as the simulation output parameter data of the any one test case;
[0190] If the matching result corresponding to any one test case represents that the matching degree of the target historical relational expression is less than or equal to a first threshold value and greater than a second threshold value, it is determined that the data generation manner corresponding to the any one test case is to read calculation flow data from the calculation data of the target historical relational expression, and perform a first simulation calculation processing according to the calculation flow data and the target relational expression to obtain a first simulation result, and the first simulation result is determined as the simulation output parameter data of the any one test case;
[0191] If the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is less than or equal to the second threshold value and greater than the third threshold value, it is determined that the data generation mode corresponding to any test case is: performing second simulation calculation processing according to the target relational expression to obtain a second simulation result, and determining the second simulation result as the simulation output parameter data of any test case.
[0192] Optionally, each input parameter data includes an input parameter field and a field value corresponding to the input parameter field; the number of field values corresponding to each input parameter field is at least one; and the first file filling unit 402 is specifically configured to:
[0193] generate a plurality of input parameter field value combinations according to each input parameter field and at least one field value of each input parameter field, determine each input parameter field value combination as test input parameter data of a test case, the number of field values included in each input parameter field value combination is the same as the number of the plurality of input parameter data, and the field values included in each input parameter field value combination correspond to each input parameter field one by one; and perform first filling processing on the test sample template file according to the test input parameter data of each test case to obtain an intermediate file.
[0194] Optionally, the interface test unit 405 includes:
[0195] The conversion subunit is configured to convert the target file into an execution file of each test case according to a preset file conversion rule.
[0196] The execution subunit is configured to execute the execution file of each test case to obtain actual output parameter data of each test case of the interface feedback to be tested.
[0197] The test subunit is configured to generate a test result of the interface to be tested according to the simulation output parameter data of each test case and the actual output parameter data of each test case.
[0198] Optionally, the test subunit is specifically configured to:
[0199] If the simulation output parameter data and the actual output parameter data of the plurality of test cases are not completely consistent, the test subunit determines a test case in which the simulation output parameter data and the actual output parameter data are not matched as a target test case, and determines a test case in which the simulation output parameter data and the actual output parameter data are matched as a non-target test case.
[0200] The test subunit is configured to perform assertion processing on the target test case according to a preconfigured assertion rule to obtain an assertion result of the target test case.
[0201] The test subunit is configured to count the assertion result of the target test case and the test result of the non-target test case to obtain a test result of the interface to be tested.
[0202] Optionally, the interface test device 400 further comprises:
[0203] The alarm rule judging unit 406 is configured to judge whether the test result triggers a pre-configured alarm rule.
[0204] If yes, the alarm information generating unit 407 is executed, and the alarm information generating unit is configured to generate alarm information based on the assertion result of the target test case.
[0205] The interface test device provided by the embodiment of the present application comprises a data acquisition unit, a first file filling unit, a historical data matching unit, a second file filling unit and an interface test unit. The data acquisition unit is configured to acquire a plurality of input parameter data through an interface to be tested, and acquire an interface test rule corresponding to the interface to be tested. The interface test rule comprises an input / output parameter mapping relationship. The first file filling unit is configured to perform first filling processing on a test sample template file based on the plurality of input parameter data, to obtain an intermediate file. The intermediate file comprises test input parameter data of each test case in the plurality of test cases. The historical data matching unit is configured to perform matching processing on historical test data according to the test input parameter data of each test case and the input / output parameter mapping relationship, to obtain a matching result corresponding to each test case. The second file filling unit is configured to perform second filling processing on the intermediate file based on the matching result of each test case, to obtain a target file. The target file comprises test input parameter data and simulated output parameter data of each test case in the plurality of test cases. The interface test unit is configured to test the interface to be tested based on the target file. In this way, the historical test data can be fully utilized in the process of generating the simulated output parameter data, a large amount of repetitive calculation work in the interface test process is reduced, and the generation efficiency of the test case is improved.
[0206] Corresponding to the interface test method described above, based on the same technical concept, the embodiment of the present application further provides an interface test device for executing the interface test method provided above, Figure 5 A structural schematic diagram of an interface test device provided by the embodiment of the present application.
[0207] As Figure 5As shown, the interface testing device can vary greatly in configuration or performance and can include one or more processors 501 and one or more memories 502, which can store one or more stored applications or data. The memory 502 can be volatile or non-volatile. The stored applications in the memory 502 can include one or more modules (not shown in the figure), each of which can include a series of computer-executable instructions in the interface testing device. Further, the processor 501 can be configured to communicate with the memory 502 to execute the series of computer-executable instructions in the memory 502 on the interface testing device. The interface testing device can also include one or more power supplies 503, one or more wired or wireless network interfaces 504, one or more input / output interfaces 505, one or more keyboards 506, and the like.
[0208] In one specific embodiment, the interface testing device includes a memory and one or more programs, wherein one or more programs are stored in the memory and the one or more programs can include one or more modules, and each module can include a series of computer-executable instructions in the interface testing device, and the one or more processors configured to execute the one or more programs include computer-executable instructions for:
[0209] Obtaining a plurality of input parameter data through the interface to be tested, and obtaining an interface testing rule corresponding to the interface to be tested; the interface testing rule includes an input / output parameter mapping relationship;
[0210] Based on the plurality of input parameter data, performing first filling processing on the test sample template file to obtain an intermediate file; the intermediate file includes test input parameter data of each test case in the plurality of test cases;
[0211] According to the test input parameter data of each test case and the input / output parameter mapping relationship, performing matching processing on historical test data to obtain a matching result corresponding to each test case;
[0212] Based on the matching result of each test case, performing second filling processing on the intermediate file to obtain a target file; the target file includes test input parameter data and simulated output parameter data of each test case in the plurality of test cases;
[0213] Based on the target file, testing the interface to be tested.
[0214] According to the above-described interface testing method, based on the same technical concept, the embodiments of the present application also provide a computer-readable storage medium.
[0215] The computer readable storage medium provided by the embodiment is used for storing computer executable instructions, and the computer executable instructions realize the following process when executed by a processor.
[0216] Obtain a plurality of input parameter data through the interface to be tested, and obtain an interface test rule corresponding to the interface to be tested; the interface test rule comprises an input / output parameter mapping relationship formula;
[0217] Based on the plurality of input parameter data, perform first filling processing on the test sample template file to obtain an intermediate file; the intermediate file comprises test input parameter data of each test case in the plurality of test cases;
[0218] According to the test input parameter data of each test case and the input / output parameter mapping relationship formula, perform matching processing on the historical test data to obtain a matching result corresponding to each test case;
[0219] Based on the matching result of each test case, perform second filling processing on the intermediate file to obtain a target file; the target file comprises test input parameter data and simulated output parameter data of each test case in the plurality of test cases;
[0220] Test the interface to be tested based on the target file.
[0221] It should be noted that the embodiments of the computer readable storage medium in the specification and the embodiments of the interface test method in the specification are based on the same inventive concept, so the specific implementation of the embodiments can be referred to the implementation of the corresponding method described above, and the repeated parts will not be described here.
[0222] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different than the order in the embodiments and still achieve the desired result. In addition, the processes depicted in the figures do not necessarily require the particular order shown or sequential order to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous or possible.
[0223] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the embodiments of the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the specification can adopt the form of a computer program product implemented on one or more computer readable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program code.
[0224] The specification is presented with reference to flow diagrams and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing system or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks.
[0225] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks.
[0226] The computer program instructions can also be loaded into a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks.
[0227] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0228] The memory can include non-persistent memory and / or volatile memory, such as a random access memory (RAM) including a cache area for the temporary storage of data. The memory can also include non-volatile memory, such as read only memory (ROM) for storing structural information and / or instruction sets. The memory can additionally or alternatively include mass storage for the non-volatile storage of data. The mass storage can include, without limitation, devices such as magnetic disks, optical disks, forms of RAM, form of flash memory, or tape. The memory is an example of computer readable media.
[0229] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The 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 technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.
[0230] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, methods, articles or devices that include a series of elements not only include those elements, but also include other elements not explicitly listed or inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0231] Embodiments of the present application can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like, which perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification can also be practiced in a distributed computing environment, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0232] Each embodiment in the specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other, and each embodiment focuses on the difference from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0233] The above merely provides the example of the present document and is not intended to limit the present document. For those skilled in the art, the present document can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present document shall be included in the scope of claims of the present document.
Claims
1. An interface test method characterized by, The method comprises the following steps: obtaining a plurality of input parameter data through an interface to be tested, and obtaining an interface test rule corresponding to the interface to be tested; the interface test rule comprises an input-output parameter mapping relationship formula; based on the plurality of input parameter data, performing first filling processing on a test sample template file to obtain an intermediate file; the intermediate file comprises test input parameter data of each test case in a plurality of test cases; based on the test input parameter data of each test case and the input-output parameter mapping relationship formula, performing matching processing on historical test data to obtain a matching result corresponding to each test case; based on the matching result of each test case, performing second filling processing on the intermediate file to obtain a target file; the target file comprises test input parameter data and simulated output parameter data of each test case in the plurality of test cases; based on the target file, testing the interface to be tested.
2. The method of claim 1, wherein, The historical test data comprises a plurality of historical relationship formulas and calculation data of each historical relationship formula; the matching processing of the historical test data based on the test input parameter data of each test case and the input-output parameter mapping relationship formula to obtain the matching result corresponding to each test case comprises: substituting the test input parameter data of each test case into the input-output parameter mapping relationship formula to generate a target relationship formula corresponding to each test case; calculating the matching degree of the target relationship formula corresponding to each test case and each historical relationship formula in the historical test data to obtain a matching degree set corresponding to each test case; determining the matching result corresponding to each test case according to the matching degree set corresponding to each test case.
3. The method of claim 2, wherein, The determination of the matching result corresponding to each test case according to the matching degree set corresponding to each test case comprises: for any one test case, sorting each matching degree in the matching degree set corresponding to the any one test case; based on the sorting result, determining the historical relationship formula with the highest matching degree as the target historical relationship formula corresponding to the any one test case; in a plurality of preset matching degree threshold intervals, determining the matching degree threshold interval to which the matching degree of the target historical relationship formula belongs as a target threshold interval, and determining the matching result corresponding to the target threshold interval as the matching result corresponding to the any one test case.
4. The method of claim 3, wherein, The second filling processing of the intermediate file based on the matching result of each test case to obtain the target file comprises: determining a data generation mode of the simulated output parameter data corresponding to each test case according to the matching result corresponding to each test case; generating the simulated output parameter data of each test case according to the data generation mode of the simulated output parameter data corresponding to each test case; performing second filling processing on the intermediate file according to the simulated output parameter data of each test case to obtain the target file.
5. The method of claim 4, wherein, The determination of the data generation mode of the simulated output parameter data corresponding to each test case according to the matching result corresponding to each test case comprises: If the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is greater than the first threshold value, it is determined that the data generation manner corresponding to the any test case is: reading result data from the calculation data of the target historical relational expression, and determining the result data as the simulation output parameter data of the any test case; If the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is less than or equal to the first threshold value and greater than the second threshold value, it is determined that the data generation manner corresponding to the any test case is: reading calculation flow data from the calculation data of the target historical relational expression, performing first simulation calculation processing according to the calculation flow data and the target relational expression, obtaining first simulation result, and determining the first simulation result as the simulation output parameter data of the any test case; If the matching result corresponding to any test case represents that the matching degree of the target historical relational expression is less than or equal to the second threshold value and greater than the third threshold value, it is determined that the data generation manner corresponding to the any test case is: performing second simulation calculation processing according to the target relational expression to obtain second simulation result, and determining the second simulation result as the simulation output parameter data of the any test case.
6. The method of claim 1, wherein, Each input parameter data includes an input parameter field and a field value corresponding to the input parameter field; the number of field values corresponding to each input parameter field is at least one; the first filling processing of the test sample template file based on the plurality of input parameter data to obtain an intermediate file includes: According to each input parameter field and at least one field value of each input parameter field, a plurality of input parameter field value combinations are generated, and each input parameter field value combination is determined as the test input parameter data of a test case; the number of field values included in each input parameter field value combination is the same as the number of the plurality of input parameter data, and the field values included in each input parameter field value combination correspond to each input parameter field one by one; According to the test input parameter data of each test case, the first filling processing of the test sample template file is performed to obtain an intermediate file.
7. The method of claim 1, wherein, The test of the interface to be tested based on the target file includes: According to a preset file conversion rule, the target file is converted into an execution file of each test case; The execution file of each test case is executed to obtain actual output parameter data of each test case fed back by the interface to be tested; According to the simulation output parameter data of each test case and the actual output parameter data of each test case, a test result of the interface to be tested is generated.
8. The method of claim 7, wherein, The generation of the test result of the interface to be tested according to the simulation output parameter data of each test case and the actual output parameter data of each test case includes: If the simulation output parameter data and the actual output parameter data of a plurality of test cases are not completely consistent, the test cases in which the simulation output parameter data and the actual output parameter data are not matched are determined as target test cases, and the test cases in which the simulation output parameter data and the actual output parameter data are matched are determined as non-target test cases; According to a pre-configured assertion rule, the target test case is subjected to assertion processing, and an assertion result of the target test case is obtained; The assertion result of the target test case and a test result of the non-target test case are counted, and a test result of the interface to be tested is obtained.
9. The method of claim 8, wherein, After the simulation output parameter data of each test case and the actual output parameter data of each test case are used to generate the test result of the interface to be tested, the method further includes: It is judged whether the test result triggers a pre-configured alarm rule; If yes, alarm information is generated based on the assertion result of the target test case.
10. An interface testing device, characterized by The apparatus includes: A data acquisition unit is configured to acquire a plurality of input parameter data through an interface to be tested, and acquire an interface test rule corresponding to the interface to be tested; the interface test rule includes an input / output parameter mapping relationship; A first file filling unit is configured to perform first filling processing on a test sample template file based on the plurality of input parameter data, and obtain an intermediate file; the intermediate file includes test input parameter data of each test case in a plurality of test cases; A historical data matching unit is configured to perform matching processing on historical test data according to the test input parameter data of each test case and the input / output parameter mapping relationship, and obtain a matching result corresponding to each test case; A second file filling unit is configured to perform second filling processing on the intermediate file based on the matching result of each test case, and obtain a target file; the target file includes test input parameter data and simulation output parameter data of each test case in a plurality of test cases; An interface test unit is configured to test the interface to be tested based on the target file.
11. An interface test apparatus, characterized by The device includes: A processor; and a memory configured to store computer executable instructions, which, when executed, cause the processor to perform the interface test method of any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer readable storage medium is configured to store computer executable instructions, which, when executed by a processor, implement the interface test method of any one of claims 1-9.
Citation Information
Patent Citations
Interface test method and apparatus and computer device
CN109189666A
Test case generation method and device, equipment, storage medium and program
CN113238939A
Logic generation method and device for interface automatic assertion and storage medium
CN113836045A