An autonomous API data interaction trust establishment and verification method
By using an autonomous API data interaction trust establishment method, interface information is automatically parsed and test cases are generated, solving the problem of time-consuming API interface testing and improving testing efficiency.
Patent Information
- Application Number
- CN202211464430.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-22
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-11-22
AI Technical Summary
In existing technologies, API interface testing consumes a significant amount of functional testing time, especially as business development leads to an increase in interfaces and field parameters, requiring testers to spend a considerable amount of time verifying the interface testing process.
This paper provides an autonomous method for establishing and verifying trust in API data interaction. It converts interface information into a JSON file, parses test case information, generates correct or incorrect parameter values, uses control variables to generate request parameters, automatically executes test cases, and generates a visual report.
Automated interface testing processes reduce test case design time, improve test execution efficiency, and save testing manpower.
Smart Images

Figure CN116126679B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of data processing, in particular to an autonomous API data interaction trust establishment and verification method. BACKGROUND
[0002] The interface test process comprises three links of interface test case design, interface test case execution, and interface test case result verification and report output. In the daily test process, interface test occupies a lot of function test time.
[0003] In particular, with the continuous development of the company business, the API interface and the corresponding field parameters of the interface will be more and more. Therefore, each time when a new interface or a new field is generated, the tester needs to spend a long time to verify the above-mentioned three link processes. SUMMARY
[0004] The application aims to provide an autonomous API data interaction trust establishment and verification method, which is used for improving the interface test efficiency and releasing more test manpower.
[0005] In order to achieve the above-mentioned purpose, the application provides the following technical scheme: an autonomous API data interaction trust establishment and verification method, comprising the following operation processes.
[0006] S001, converting imported interface information text into a json file;
[0007] S002, reading and analyzing the core information in the exported json file to obtain test case information;
[0008] S003, judging whether the obtained test case information needs to be designed into a new case, and after the judgment program is determined, substituting each field of the test case information into the parameter generation rule of the scheme design, the corresponding correct or incorrect parameter value can be generated;
[0009] S004, after the parameter value of the interface is generated, different request parameters are generated by using the control variable, the exceptCode is set according to whether the field parameter value is correct or incorrect, and a plurality of records generated by the exceptCode are stored in excel;
[0010] S005, when the test case is executed, each designed test case is read and sequentially requested, and after the request is completed, the actual result returned is backfilled into the actualCode sequence in excel;
[0011] S006、Test case execution is completed, will be compared to statistics each case exceptCode and actualCode, and make a judgment: if consistent, indicates that actualCode and exceptCode consistent, this test case execution pass; otherwise, the case does not pass and needs to be marked as failure.
[0012] S007, the judgment information in step 6 is generated into a visual execution result report.
[0013] As preferred, the interface information text is imported into the information modification YApi data, and the interface information file is exported as json information in YApi, which includes two information, specifically:
[0014] Paths: identify the request address of the interface;
[0015] Parameters: all field information corresponding to the interface.
[0016] As preferred, the judgment program refers to the Paths and Parameters information in the json file, and judges whether the interface has been designed for case:
[0017] If the interface is a new interface, the field in the Parameters information is applied;
[0018] If the interface is an existing interface and the interface information has not been modified, it means that the interface has no changes and the test case already exists, and there is no need to redesign;
[0019] If the interface is an existing interface but the interface information has changed, a new case needs to be designed.
[0020] As preferred, the judgment step of the parameter generation is as follows:
[0021] If field A is a required parameter when defined and the maximum value is 10, according to the test case design boundary value rule, field A generates: parameter value that meets the requirements: 0, 5, 10; parameter value that does not meet the requirements: NULL.
[0022] As preferred, the judgment of the corresponding exceptCode in step 4 is as follows:
[0023] All field request parameters are in line with requirements, and the interface request returns code 200;
[0024] There are field request parameters that do not meet the requirements, and the interface request returns code 400;
[0025] Wherein, the judgment of exceptCode generates at least two test cases, and the request path of the interface is: the url parameter in xcel: "task / user / task / receive".
[0026] As preferred, the step 1 further comprises running configuration switch mode selection, the running configuration switch comprises switch=1, switch=2 and switch=3, wherein:
[0027] Switch=1 is equal to the sum of switch=2 and switch=3, that is
[0028] Switch=2, steps 1 to 4 are executed to perform interface establishment;
[0029] Switch=3, steps 5 to 7 are executed to perform interface verification.
[0030] An autonomous API data interaction trust establishment and verification system for executing the autonomous API data interaction trust establishment and verification method described in the technical solution, comprising:
[0031] An interface file conversion module for converting imported interface information into a json file;
[0032] An inner core running module for executing a test channel of interface information based on running selection, wherein the test channel comprises two execution channels of interface establishment and interface verification;
[0033] A channel establishment module for verifying the test channel based on the field in the interface information carrying parameters into a parameter production rule and judging the establishment of the test channel.
[0034] A verification module for parsing information in Paths and Parameters in the json file based on the determination of the execution channel, and performing parameter value judgment through algorithm execution, and returning and storing the execution result.
[0035] As preferred, a conclusion report module is further included, which is automatically updated to a local address based on the test result data of the channel establishment module and the verification module, and the channel is excel / url / task / user / task / receive.
[0036] In the above technical solution, the autonomous API data interaction trust establishment and verification method provided by the application has the following beneficial effects: interface requests are automatically executed, imported files are parsed, case file is automatically produced, corresponding case rules are matched through field type matching, corresponding field values and expected results are automatically designed, test case design time is saved, and test execution efficiency is improved. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0038] Figure 1 This is a schematic diagram of the process structure provided in an embodiment of the present invention;
[0039] Figure 2 This is a schematic diagram of the module structure provided in an embodiment of the present invention;
[0040] Figure 3 This is a schematic diagram of the user interface for exporting JSON files using YApi, provided in an embodiment of the present invention.
[0041] Figure 4 This is a schematic diagram of the test report display state 1 interface provided in an embodiment of the present invention;
[0042] Figure 5 This is a schematic diagram of the test report display state 2 interface provided in an embodiment of the present invention;
[0043] Figure 6 This invention provides a schematic diagram of example code for converting JSON files to their equivalents.
[0044] Figure 7 A schematic diagram of the executable interface for a test example generated in an embodiment of the present invention. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] Example 1
[0047] like Figure 1 , Figure 3 , Figure 4 , Figure 5 Figure 6 as well as Figure 7 As shown, a method for establishing and verifying trust in autonomous API data interaction includes the following steps:
[0048] S001. Convert the imported interface information text into a JSON file;
[0049] S002, read and parse the core information in the derived json file to obtain test case information;
[0050] S003, judge whether the obtained test case information needs to be designed new case, after the judgment program is determined, each field of the test case information is substituted into the parameter generation rule of the scheme design, and the corresponding correct or incorrect parameter value can be generated;
[0051] S004, after the parameter value of the interface is generated, different request parameters are generated by using the control variable, the corresponding exceptCode is set according to whether the field parameter value is correct or incorrect, and the multiple records generated by exceptCode are stored in excel;
[0052] S005, when executing the test case, each designed test case is read and requested in turn, and after the request is completed, the actual result returned is filled back to the actualCode sequence in excel;
[0053] S006, after the test case is executed, the exceptCode and actualCode of each case are compared and counted, and the judgment is made: if they are consistent, it means that actualCode and exceptCode are consistent, and this case is executed; otherwise, the case fails and needs to be marked as failed.
[0054] S007, the judgment information in step 6 is generated to generate a visual execution result report.
[0055] In the above embodiment, the interface information text is imported to modify the information to YApi data, and the interface information file is exported as json information in YApi, and the json information includes two information, which are:
[0056] Paths: identify the request address of the interface;
[0057] Parameters: all field information corresponding to the interface.
[0058] Further, the judgment program refers to the Paths and Parameters information in the json file is parsed and judged whether the interface has designed a case:
[0059] If the interface is a new interface, the field in the Parameters information is applied;
[0060] If the interface is an existing interface and the interface information has not been modified, it means that the interface has no change, and the test case already exists and does not need to be redesigned;
[0061] If the interface is an existing interface but the interface information changes, a new use case needs to be designed.
[0062] Furthermore, the parameter generation judgment steps are as follows:
[0063] If field A is a required parameter with a maximum value of 10 when defined, according to the boundary value rules of the test case design, field A generates: compliant parameter values: 0, 5, 10; non-compliant parameter values: NULL.
[0064] Furthermore, the `exceptCode` condition in step 4 is as follows:
[0065] All field request parameters meet the requirements, and the interface request returns a code of 200.
[0066] There are fields in the request parameters that do not meet the requirements, and the interface request returns a code of 400;
[0067] Specifically, the above judgment on exceptCode generates at least two test cases, and the request path of the interface is: the url parameter in xcel: "task / user / task / receive".
[0068] In the above technical solution, interface requests are executed automatically, imported files are parsed, test case files are generated automatically, and corresponding field values and expected results are designed automatically by matching field types with corresponding test case rules, saving test case design time and improving test execution efficiency.
[0069] Example 2
[0070] like Figure 1 As shown, to implement step 1 in the above embodiment 1, it is necessary to rotate the operation configuration switches including switch=1, switch=2 and switch=3, wherein:
[0071] switch=1 is equal to the sum of switch=2 and switch=3, that is
[0072] If switch=2, execute steps 1 to 4 to establish the interface.
[0073] If switch=3, execute steps 5 to 7 to perform interface verification.
[0074] That is, when switch = 1,
[0075] The process for processing interface files is as follows:
[0076] S001. Convert the imported interface information text into a JSON file;
[0077] S002, read and parse the core information in the exported json file to obtain test case information;
[0078] S003, judge whether a new case needs to be designed according to the obtained test case information, and after the judgment program is determined, each field of the test case information is substituted into the parameter generation rule of the scheme design, so that the corresponding correct or incorrect parameter value can be generated;
[0079] S004, after the parameter value of the interface is generated, different request parameters are generated by using the control variable, the exceptCode is set according to whether the parameter value of the field is correct or incorrect, and multiple records generated by the exceptCode are stored in excel;
[0080] S005, when executing the test case, each designed test case is read and requested in turn, and after the request is completed, the actual result returned is backfilled into the actualCode sequence in excel;
[0081] S006, after the test case is executed, the exceptCode and the actualCode of each case are compared and counted, and it is judged: if they are consistent, it means that the actualCode and the exceptCode are consistent, and the case is executed; otherwise, the case fails and needs to be marked.
[0082] S007, the judgment information in step 6 is generated to generate a visual execution result report.
[0083] That is, when switch = 2,
[0084] The process of processing the interface file is as follows:
[0085] S001, the imported interface information text is converted into a json file;
[0086] S002, read and parse the core information in the exported json file to obtain test case information;
[0087] S003, judge whether a new case needs to be designed according to the obtained test case information, and after the judgment program is determined, each field of the test case information is substituted into the parameter generation rule of the scheme design, so that the corresponding correct or incorrect parameter value can be generated;
[0088] S004, after the parameter value of the interface is generated, different request parameters are generated by using the control variable, the exceptCode is set according to whether the parameter value of the field is correct or incorrect, and multiple records generated by the exceptCode are stored in excel.
[0089] i.e., when switch = 3,
[0090] The flow of processing the interface file is as follows:
[0091] S001, converting the imported interface information text into a json file;
[0092] S002, reading and parsing the core information in the exported json file to obtain test case information;
[0093] S005, when executing the test case, each designed test case is read and requested in turn, and after the request is completed, the actual result returned is filled back into the actualCode sequence in the excel;
[0094] S006, after the test case is executed, the exceptCode and actualCode of each case are compared and counted, and a judgment is made: if they are consistent, it means that the actualCode and exceptCode are consistent, and this case is executed through; otherwise, the case fails and needs to be marked as failed.
[0095] Embodiment 3
[0096] As shown in Figure 2 An autonomous API data interaction trust establishment and verification system for executing the autonomous API data interaction trust establishment and verification method described in Embodiment 1 and Embodiment 2, comprising:
[0097] An interface file conversion module that converts imported interface information into a json file;
[0098] An inner core running module that, based on running selection, executes a test channel for interface information, the test channel including an interface establishment and an interface verification execution channel;
[0099] A channel establishment module that, based on the fields in the interface information, brings in parameters in the production rule for verification and determines the establishment of the test channel.
[0100] A verification module that, based on the determination of the execution channel, parses the information in Paths and Parameters in the json file, and performs parameter value judgment through algorithm execution, and returns and stores the calculation result.
[0101] Further, it further includes a conclusion report module that, based on the test result data of the channel establishment module and the verification module, automatically updates to the local address, and the channel is excel / url / task / user / task / receive.
[0102] Further, the channel establishment module in the above embodiment acquires the request address, interface request method and attribute of each parameter field corresponding to the interface, and reads out the information of each parameter in the interface in a loop for subsequent test case generation and execution.
[0103] After the interface information is parsed, it is necessary to determine whether the interface has been designed for a case: if the interface is a new interface, a new case must be designed; if the interface is an existing interface and the interface information has not been modified, it is indicated that the interface has no change, and the test case already exists and does not need to be redesigned; if the interface is an existing interface but the interface information has changed, a new case needs to be designed. After the interface field value is generated, different request parameters are generated in a control variable manner, and the corresponding expected results are set according to whether the field parameter value is correct or incorrect.
[0104] Further, in the verification module, when the test case is started to be executed, each designed test case is read and requested in turn. After the request is completed, the actual result code returned is filled back to the actualCode column in the excel. After all the interface test cases are executed, the exceptCode and actualCode of each case are compared and counted. If they are consistent, it indicates that the actual result and the expected result are consistent, and the case is executed. Otherwise, the case fails and needs to be marked. Finally, a visual execution result report is generated.
[0105] Those skilled in the art will understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0106] The present application is described with reference to flowcharts and / or block diagrams according to the method, device (system) and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks.
[0107] 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 Figure 1 The functions specified in the flow or flows and / or blocks Figure 1 The functions specified in the flow or flows and / or blocks
[0108] These computer program instructions can also be loaded onto 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 functions specified in the flow Figure 1 The functions specified in the flow or flows and / or blocks Figure 1 The functions specified in the flow or flows and / or blocks
[0109] The principles and implementation manners of the present application are described in the specific embodiments, and the above embodiment descriptions are only used to help understand the method of the present application and its core idea; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manners and application ranges will be changed, and the above description should not be understood as the limitation of the present application.
[0110] The embodiment of the present application further provides a specific implementation manner of an electronic device capable of implementing all steps in the method in the above embodiment, and the electronic device specifically includes the following contents:
[0111] a processor, a memory, a communications interface and a bus;
[0112] The processor, the memory and the communications interface complete mutual communication through the bus;
[0113] The processor is used for calling a computer program in the memory, and the processor implements all steps in the method in the above embodiment when executing the computer program, for example, the processor implements the following steps when executing the computer program:
[0114] A user interface for exporting a json file by YApi;
[0115] A test report display state 1 interface;
[0116] A test report display state 2 interface.
[0117] The embodiments of the present application further provide a computer readable storage medium capable of implementing all steps of the method in the above-mentioned embodiments, and a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, all steps of the method in the above-mentioned embodiments are implemented, for example, when the processor executes the computer program, the following steps are implemented:
[0118] A user interface for exporting a json file by YApi;
[0119] A test report display state 1 interface;
[0120] A test report display state 2 interface.
[0121] The various embodiments described in this specification are intended to be illustrative only and in no way limit the scope of the application. Thus, changes and modifications can be made by those skilled in the art, with the scope of the application being indicated by the following claims. For example, although the various embodiments have been described above in the context of fully functional devices, the implementation is equally applicable to distributed or networked implementations where tasks are performed by remote processing devices that are linked through a communications network. In other embodiments, various operational elements of the described embodiments can be combined or eliminated, and other operational elements can be added. Various embodiments can be implemented using hardware elements, software elements, or a combination of both. Examples of hardware elements can include devices, logic devices, components, processors, microprocessors, circuits, boards, memories, storage devices, buses, wires, communication devices, transmitters, receivers, and / or the like. Examples of software elements can include software components, programs, applications, computer programs, application programs, system programs, software development programs, machine programs, operating system Figure 1 one or more functions specified by one or more blocks or one or more blocks or
[0122] Those skilled in the art will appreciate that embodiments of the present specification can be devised for a method, a system, or a computer program product. Accordingly, embodiments of the present specification can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present specification can be in the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROM, optical storage medium, etc.) embodying computer usable program code. Each of the various embodiments of the present specification is described in a progressive manner, and reference can be made to other embodiments for the same or similar parts. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and reference can be made to the description of the method embodiments. In the description of the present specification, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the embodiments of the present specification.
[0123] In the present specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. In addition, those skilled in the art can combine and combine the different embodiments or examples described in the present specification and the features of the different embodiments or examples without contradiction. The above is only an embodiment of the embodiments of the present specification and is not intended to limit the embodiments of the present specification. The embodiments of the present specification can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the embodiments of the present specification shall be included in the scope of the claims of the embodiments of the present specification.
Claims
1. An autonomous API data interaction trust establishment and verification method, characterized in that, The method comprises the following steps: S001, converting the imported interface information text into a json file; S002, reading and parsing the core information in the exported json file to obtain test case information; S003, judging whether the test case information obtained needs to be designed, and after the judgment program determines, each field of the test case information is substituted into the parameter generation rule of the scheme design, so that the corresponding correct or incorrect parameter value can be generated; S004, after the parameter value of the interface is generated, different request parameters are generated by using the control variable method, and the exceptCode is set according to whether the field parameter value is correct or incorrect, and the multiple records generated by exceptCode are stored in excel; S005, when executing the test case, each designed test case is read and requested in turn, and after the request is completed, the actual result returned is filled back to the actualCode sequence in excel; S006, after the test case is executed, the exceptCode and actualCode of each case are compared and counted, and it is judged: if they are consistent, it means that the actualCode and exceptCode are consistent, and the case is executed through; Otherwise, the case fails and needs to be marked as failed; S007, the judgment information in step 6 is generated to generate a visual execution result report.
2. The method of claim 1, wherein, After the interface information text is imported, the information is modified to YApi data, and the interface information file is exported as json information in YApi, which includes two information details: Paths: identify the request address of the interface; Parameters: all field information corresponding to the interface.
3. The method of claim 1, wherein, The judgment program refers to the Paths and Parameters information in the json file, which is parsed and judged whether the interface has designed a case: If the interface is a new interface, the field in the Parameters information is applied; If the interface is an existing interface and the interface information has not been modified, it means that the interface has no change, and the test case already exists and does not need to be redesigned; If the interface is an existing interface but the interface information has changed, a new case needs to be designed.
4. The method of claim 1, wherein, The judgment step of the parameter generation is as follows: If field A is a required parameter and the maximum value is 10, according to the test case design boundary value rule, field A generates: the parameter value that meets the requirements: 0, 5, 10; the parameter value that does not meet the requirements: NULL.
5. The method of claim 1, wherein, The judgment of the corresponding exceptCode in step 4 is as follows: All field request parameters meet the requirements, and the interface request returns code 200; There is a field request parameter that does not meet the requirements, and the interface request returns code 400; Among them, the judgment of exceptCode generates at least two test cases, and the request path of the interface is: xcel url parameter: "task / user / task / receive".
6. The method of claim 1, wherein, The step 1 further comprises running configuration switch mode selection, the running configuration switch comprises switch=1, switch=2 and switch=3, wherein: Switch=1 is equal to the sum of switch=2 and switch=3, that is Switch=2, steps 1 to 4 are executed to perform interface establishment; Switch=3, steps 5 to 7 are executed to perform interface verification.
7. An autonomous API data interaction trust establishment and verification system, characterized in that, The autonomous API data interaction trust establishment and verification method according to any one of claims 1-6 comprises: An interface file conversion module, which converts imported interface information into a json file; An inner core running module, which executes a test channel for interface information based on running selection, the test channel comprising two execution channels of interface establishment and interface verification; A channel establishment module, which verifies parameters in a parameter production rule based on fields in the interface information and determines the establishment of the test channel; A verification module, which parses information in Paths and Parameters in the json file based on the determination of the execution channel, executes calculation on the information through an algorithm to determine parameter values, returns the calculation result and stores the result.
8. The system of claim 7, wherein, A conclusion report module, which automatically updates test result data of the channel establishment module and the verification module to a local address, and the channel is excel / url / task / user / task / receive.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the steps of the autonomous API data interaction trust establishment and verification method according to any one of claims 1-6.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the autonomous API data interaction trust establishment and verification method according to any one of claims 1-6.
Citation Information
Patent Citations
Information interaction test device and method based on automatic generation of associated test cases
US20140359362A1
Conditional parameter optimization method & system
WO2022187946A1