File interface automation implementation method
By introducing basic configuration interface, running server, uploading file template processing module, downloading file expectation verification module and above processing module in interface automation, the problem of the inability to automatically realize the preparation and verification of file upload and download interfaces in the existing technology is solved, and efficient interface automation testing is achieved.
Patent Information
- Application Number
- CN202510080707.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-23
AI Technical Summary
The existing interface automation methods cannot universally implement file preparation for different file upload interfaces, and cannot provide common means to determine whether the file content returned by the file download interface meets expectations, resulting in testers having to manually intervene in the process of preparing and verifying the interface.
A file interface automation implementation method is proposed, including basic configuration interface, running server, uploading file template processing module, downloading file expectation verification module and above processing module. This method frees the tester's hands and reduces manual intervention by providing common interface configuration capabilities, file upload templates and file expected verification template configuration capabilities, dynamically processes file content, and provides file storage and verification capabilities.
It realizes automatic file preparation and download file interface of the file upload interface, improves testing efficiency, reduces manual intervention, and ensures efficient automation of the interface.
Smart Images

Figure CN120029685A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of file interface, and in particular to a method for automatically realizing a file interface. Background Art
[0002] With the rapid development and frequent use of Internet technology and software application technology, the software iteration cycle is also constantly shortening. What this brings to software technicians is how to efficiently ensure the reliability and stability of the software in a shorter time. For the field of software testing, interface automation is an efficient technical means to ensure software quality. Testers can improve the efficiency of testing and ensure the interface quality of the tested software by implementing interface-level testing;
[0003] However, current interface automation methods cannot universally implement file preparation for different file upload interfaces, and must rely on manual preparation by testers. At the same time, they cannot provide a universal means to determine whether the file content returned by the file download interface meets expectations. For testers, this problem will result in manual intervention in the process of interface automation to prepare and verify the interface, which will also result in the interface automation being unable to exert its efficient capabilities when facing file-related interfaces, and may even cause testers to spend more time on file data preparation and file download verification.
[0004] In order to solve the above problems, this application proposes a method for automatically implementing a file interface. Summary of the invention
[0005] Based on the technical problems existing in the background technology, the present invention proposes a method for realizing automatic file interface.
[0006] The present invention provides a method for realizing automatic file interface, comprising the following steps:
[0007] Step 1: Basic configuration interface: provides general interface configuration capabilities, as well as the configuration capabilities of file upload templates and file expectation verification templates during interface configuration;
[0008] Step 2: Run the server: used to carry the operation, calculation, communication and storage capabilities of each module in the file interface automation implementation method;
[0009] Step 3: Upload file template processing module: Provides the ability to prepare files required by the upload interface;
[0010] Step 4: Download file expectation verification module: provides the file storage and verification capabilities required by the download interface;
[0011] Step 5: The above processing module provides the ability to obtain the values of some fields in the response information returned by the above interface.
[0012] As a further optimization solution of the present invention, the basic configuration interface includes the following steps:
[0013] Step 1: Provide a user interface that allows users to enter and manage basic information about the interface;
[0014] Step 2: Allow users to upload and select file upload templates, supporting multiple file formats, including xlsx, xls, csv, txt, json, config, doc, docx;
[0015] Step 3: Provide the editing function of the file upload template. Users can edit and save the template content as needed;
[0016] Step 4: Allow users to configure the expected file verification template, including expected file content and verification rules;
[0017] Step 5: Provide interface parameter configuration function, users can configure the parameters required by the interface, including path parameters, query parameters and request body parameters;
[0018] Step 6: Provide interface authentication configuration function, users can configure the authentication information required by the interface, including API key and OAuth token;
[0019] Step 7: Save the configuration information for use in the automated testing process.
[0020] As a further optimization solution of the present invention, the operation server includes the following steps:
[0021] Step 1: Start the server and ensure that it has an environment that can support the operation of the automated test module;
[0022] Step 2: Configure server resources, including CPU, memory, and storage, to meet the needs of automated testing;
[0023] Step 3: Deploy each module in the file interface automation implementation method to the server;
[0024] Step 4: Ensure that the server has the ability to process data and perform logical operations;
[0025] Step 5: Configure the server's network communication capabilities to ensure data exchange between modules and with external systems;
[0026] Step 6: Set up the server's storage system to store file templates, expected verification templates, and data and results generated during the test.
[0027] As a further optimization solution of the present invention, the uploaded file template processing module includes the following steps:
[0028] Step 1: Analyze the file upload template configured by the user, and identify the context-related variables and dynamic macro variables in the template;
[0029] Step 2: Dynamically obtain the response information after the execution of the pre-interface according to the context-related variables, and replace the variables in the template;
[0030] Step 3: Generate the text content in the required format according to the dynamic macro variable template, and replace the macro variables in the template;
[0031] Step 4: Perform pre-processing on the template file to ensure that the file content meets the business correctness and content format correctness of the interface;
[0032] Step 5: Save the processed file as a new file and prepare to upload it to the target interface;
[0033] Step 6: Call the target interface, upload the processed file, and record the interface response.
[0034] As a further optimized solution of the present invention, the downloaded file expected verification module includes the following steps:
[0035] Step 1: Receive and save the downloaded file returned by the interface;
[0036] Step 2: Analyze the file expected verification template configured by the user, and identify the context-related variables and dynamic macro variables in the template;
[0037] Step 3: Dynamically obtain the above context response information according to the context-related variables, and replace the variables in the expected verification template;
[0038] Step 4: Generate the expected content value according to the dynamic macro variable template, and replace the macro variables in the expected verification template;
[0039] Step 5: Compare the content of the expected verification template and the actual downloaded file to verify whether the interface return meets the expectations;
[0040] Step 6: Record the verification result. If all verification items pass, output the flag of successful verification; if any verification item fails, output the flag of failed verification.
[0041] As a further optimized solution of the present invention, the above context processing module includes the following steps:
[0042] Step 1: Capture the response information after the execution of the pre-interface;
[0043] Step 2: Analyze the response information and extract the required field values;
[0044] Step 3: Save the extracted field values as the above associated variables for use in subsequent modules;
[0045] Step 4: In the upload file template processing module and the download file expectation verification module, dynamically replace the above-mentioned associated variables in the file template with actual values;
[0046] Step 5: In the download file expectation verification module, use the above associated variables to match and verify the content;
[0047] Step 6: Provide management and query functions for the above associated variables to facilitate debugging and verification during the automated testing process.
[0048] As a further optimization scheme of the present invention, the uploaded file template processing module supports file processing in the formats of xlsx, xls, csv, txt, json, config, doc, and docx, and the downloaded file expected verification module supports the saving and verification of files in the formats of xlsx, xls, csv, txt, json, config, doc, and docx.
[0049] The above technical solution of the present invention has the following beneficial technical effects:
[0050] 1. Aiming at the repetitive work of preparing data files for the file upload interface, the implementation method uses two variable templates to automatically generate data based on the rules preset by the tester. On the basis of ensuring the correctness of the business and the correctness of the content format, the tester's hands are freed, so that the tester does not need to repeatedly maintain the uploaded file data;
[0051] 2. Regarding the expected verification of the download file interface, the implementation also uses two variable templates. When there is dynamically changing data in the downloaded file content, the verification work becomes simpler;
[0052] 3. At the same time, it provides the ability to match the context of a specified number of characters, making the match more accurate during expected verification and avoiding the problem of unsuccessful full-text verification due to unpredictable changes in the downloaded file. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A flowchart of a method for realizing automatic file interface proposed by the present invention;
[0054] Figure 2 A schematic diagram of the process flow of the upload file template processing module in the file interface automation implementation method proposed by the present invention;
[0055] Figure 3The present invention provides a flowchart of the implementation of the expected verification module for downloading files in the method for realizing the automatic implementation of the file interface. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concept of the present invention.
[0057] like Figure 1-3 As shown, a method for realizing automatic file interface proposed by the present invention comprises the following steps:
[0058] Step 1: Basic configuration interface: provides general interface configuration capabilities, as well as the configuration capabilities of file upload templates and file expectation verification templates during interface configuration;
[0059] Step 2: Run the server: used to carry the operation, calculation, communication and storage capabilities of each module in the file interface automation implementation method;
[0060] Step 3: Upload file template processing module: Provides the ability to prepare files required by the upload interface;
[0061] Step 4: Download file expectation verification module: provides the file storage and verification capabilities required by the download interface;
[0062] Step 5: The above processing module provides the ability to obtain the values of some fields in the response information returned by the above interface.
[0063] In this embodiment, the basic configuration interface includes the following steps:
[0064] Step 1: Provide a user interface that allows users to enter and manage basic information about the interface;
[0065] Step 2: Allow users to upload and select file upload templates, supporting multiple file formats, including xlsx, xls, csv, txt, json, config, doc, docx;
[0066] Step 3: Provide the editing function of the file upload template. Users can edit and save the template content as needed;
[0067] Step 4: Allow users to configure the expected file verification template, including expected file content and verification rules;
[0068] Step 5: Provide interface parameter configuration function, users can configure the parameters required by the interface, including path parameters, query parameters and request body parameters;
[0069] Step 6: Provide interface authentication configuration function, users can configure the authentication information required by the interface, including API key and OAuth token;
[0070] Step 7: Save the configuration information for use in the automated testing process.
[0071] In this embodiment, running the server includes the following steps:
[0072] Step 1: Start the server and ensure that it has an environment that can support the operation of the automated test module;
[0073] Step 2: Configure server resources, including CPU, memory, and storage, to meet the needs of automated testing;
[0074] Step 3: Deploy each module in the file interface automation implementation method to the server;
[0075] Step 4: Ensure that the server has the ability to process data and perform logical operations;
[0076] Step 5: Configure the server's network communication capabilities to ensure data exchange between modules and with external systems;
[0077] Step 6: Set up the server's storage system to store file templates, expected verification templates, and data and results generated during the test.
[0078] In this embodiment, the upload file template processing module includes the following steps:
[0079] Step 1: Parse the file upload template configured by the user and identify the context-related variables and dynamic macro variables in the template;
[0080] Step 2: According to the associated variables above, dynamically obtain the response information after the front-end interface is executed, and replace the variables in the template;
[0081] Step 3: Generate text content in the required format according to the dynamic macro variable template, and replace the macro variables in the template;
[0082] Step 4: Pre-process the template file to ensure that the file content complies with the business correctness of the interface and the correctness of the content format;
[0083] Step 5: Save the processed file as a new file and prepare to upload it to the target interface;
[0084] Step 6: Call the target interface, upload the processed file, and record the interface response.
[0085] It should be noted that the upload file template processing module provides the ability to prepare files required by the upload interface. The module supports file processing in the formats of xlsx, xls, csv, text files (including all text files such as txt, json, config, etc.), doc, and docx. Testers only need to edit and fill in the content of different files required by any interface according to the upload format specified by the implementation method. The implementation method can pre-process the filled-in file to ensure that the file has the business correctness and content format correctness of the corresponding interface;
[0086] The upload format specified by the implementation method is that the above-mentioned associated variables are wrapped with the symbols "${" and the symbol "}". During the execution of the file interface, the response information after the execution of the previous interface is dynamically obtained, so that the current file interface has business correctness in the automation link, and the dynamic macro variables are wrapped with the symbols "#{" and the symbol "}". During the execution of the file interface, the text of different formats corresponding to the required file is dynamically generated. The content format of the current file interface is correct in the automation link.
[0087] In this embodiment, the download file expectation verification module includes the following steps:
[0088] Step 1: Receive and save the downloaded file returned by the interface;
[0089] Step 2: Parse the expected verification template of the file configured by the user, and identify the context-related variables and dynamic macro variables in the template;
[0090] Step 3: According to the associated variables above, dynamically obtain the above response information and replace the variables in the expected verification template;
[0091] Step 4: Generate expected content values according to the dynamic macro variable template and replace the macro variables in the expected verification template;
[0092] Step 5: Compare the expected verification template with the content of the actual downloaded file to verify whether the interface return meets expectations;
[0093] Step 6: Record the verification results. If all verification items pass, output a verification success flag; if any verification item fails, output a verification failure flag.
[0094] It should be noted that the download file expected verification module provides the file saving and verification capabilities required by the download interface. The module supports the saving and verification of files in the formats of xlsx, xls, csv, text files (including all text files such as txt, json, config, etc.), doc, and docx. The tester only needs to edit and fill in the corresponding expected files for different files downloaded by any interface according to the expected format specified by the implementation method. After the interface is executed, the implementation method can dynamically process and compare the completed expected files;
[0095] The expected format specified in the implementation method is that the above-mentioned associated variables are wrapped with the symbols "${" and the symbol "}", and after the file interface is executed and the file is downloaded, the ability to dynamically obtain the above-mentioned response information and compare the content of the corresponding position of the result file is provided; the dynamic macro variables are wrapped with the symbols "#{" and the symbol "}", and after the file interface is executed and the file is downloaded, the ability to dynamically generate the current expected content value and compare the content of the corresponding position of the result file is provided; and the number of matching characters configured in the above-mentioned associated variables and dynamic macro variables in the form of an integer wrapped with the symbols "@" and the symbol "@" (hereinafter replaced by the symbol "N"). During the expected verification process, the N characters before and after the above-mentioned associated variable or dynamic macro variable in the current expected file are extracted as the position information of the current above-mentioned associated variable or dynamic macro variable, and matched in the result file. Only after the match is successful will the replacement work and the expected verification work of the above-mentioned associated variable or dynamic macro variable be executed.
[0096] In this embodiment, the above processing module includes the following steps:
[0097] Step 1: Capture the response information after the front-end interface is executed;
[0098] Step 2: Analyze the response information and extract the required field values;
[0099] Step 3: Save the extracted field values as the above associated variables for use in subsequent modules;
[0100] Step 4: In the upload file template processing module and the download file expectation verification module, dynamically replace the above-mentioned associated variables in the file template with actual values;
[0101] Step 5: In the download file expectation verification module, use the above associated variables to match and verify the content;
[0102] Step 6: Provide management and query functions for the above associated variables to facilitate debugging and verification during the automated testing process.
[0103] It should be noted that the above processing module provides the ability to obtain some field values in the response information returned by the above interface in the implementation method, and serves as a predecessor module of the upload file template processing module and the download file expectation verification module, and is called by these two modules during the execution process.
[0104] In this embodiment, the upload file template processing module supports file processing in the formats of xlsx, xls, csv, txt, json, config, doc, and docx, and the download file expectation verification module supports the saving and verification of files in the formats of xlsx, xls, csv, txt, json, config, doc, and docx.
[0105] It should be noted that: further, based on the capabilities provided by the upload file template processing module, before writing automated test cases, testers can fill in all the required files in accordance with the upload format specified by the implementation method at one time, and can execute automated test cases repeatedly and without modification.
[0106] Furthermore, the context-associated variables wrapped in the symbols "${" and "}" provided by the upload file template processing module are used to dynamically obtain the context-associated data and replace it with the text content currently to be uploaded. The tester only needs to save the required field values in the response information to a context-associated variable after the front-end interface is executed. The implementation method can perform dynamic replacement before the upload file interface is executed. For example, if the front-end interface has saved the response value "2000" to the variable ${money}, the tester only needs to fill in the symbol "${money}" in the corresponding position when preparing the file template corresponding to the current interface. The implementation method will automatically replace the corresponding "${money}" in the file template with "2000" and generate a real uploaded file after all replacements.
[0107] Furthermore, the uploaded file template processing module provides a dynamic macro variable wrapped with the symbol "#{" and the symbol "}" to generate text in a specified format. The dynamic macro variable wrapped with the symbol "#{" and the symbol "}" is a capability provided as an implementation method, and there are many different variable templates as follows:
[0108] "#{(yyyy-MM-dd)-X}", this macro variable template is used to dynamically obtain the current date, and add or subtract days according to the postfix X value, and finally generate the specified dynamic date. Similarly, according to different date formats, this macro variable can also be written as "#{(yyyy / MM / dd)-X}", "#{(yyyyyearMMmonthdd)-X}";
[0109] "#{uuid_X}", this macro variable template is used to dynamically generate a unique identification code of a specified X digits;
[0110] “#{random(min,max,X)}”, this macro variable template is used to dynamically generate X-digit random decimals ranging from min to max;
[0111] “#{uscc_random}”, this macro variable template is used to dynamically generate a random virtual unified social credit code;
[0112] “#{tel_random}”, this macro variable template is used to dynamically generate random virtual telephone numbers;
[0113] “#{phone_random}”, this macro variable template is used to dynamically generate a random virtual phone number;
[0114] “#{idno_random}”, this macro variable template is used to dynamically generate a random virtual ID number;
[0115] “#{random(zh,X)}”, this macro variable template is used to dynamically generate a random Chinese string of specified X characters;
[0116] “#{random(en,X)}”, this macro variable template is used to dynamically generate a random English string of specified X characters;
[0117] "#{random(str,X)}", this macro variable template is used to dynamically generate a random string of specified X characters;
[0118] Based on the various macro variable templates provided above, testers only need to fill in the corresponding positions in the upload file template as needed. The implementation method can dynamically generate and replace before the upload file interface is executed. For example, when the tester prepares the file template corresponding to the current interface, he fills in the symbol "#{random(en,6)}" in the corresponding position. The implementation method will automatically replace the corresponding "#{random(en,6)}" in the file template with a random 6-digit English string such as "eifjgf" in the future; after all variables are replaced, the real upload file after all replacements will be generated.
[0119] Furthermore, when dynamic macro variables wrapped with the symbols "#{" and "}" are dynamically generated during actual runtime, the generated values will be automatically saved to the corresponding associated variables above for subsequent use.
[0120] Furthermore, the dynamic macro variables wrapped with the symbols "#{" and "}" are easy to expand in the implementation. Each macro variable template is read and run by the uploaded file template processing module in the form of a plug-in. Therefore, when the tester has a new format requirement, the corresponding macro variable template can be written according to the same process so that the uploaded file template processing module can read and run it.
[0121] Furthermore, the context-associated variables and dynamic macro variables provided by the download file expectation verification module are basically consistent with those provided by the upload file template processing module. The difference is that the download file expectation verification module will specify the number of characters that need to be matched before and after in the variable. For example, "${@12@money@40@}" means that after the variable is dynamically replaced, the 12 characters above the interface and the 40 characters below the interface are required to match and verify the file content downloaded by the interface. "#{@7@(yyyy-MM-dd)-2@18@}" means that after the variable is dynamically replaced, the 7 characters above the interface and the 18 characters below the interface are required to match and verify the file content downloaded by the interface.
[0122] Furthermore, when the context corresponding to the result file is less than the specified number of characters, full text matching will be used for verification. When all variables in the expected file template are replaced and matched, the expected verification module will output a flag to the outside to indicate whether the expected verification has passed. When a matching item fails to be verified, the output flag indicates that the expected verification has failed, otherwise the expected verification is successful.
[0123] The following is a comparison table based on postman and yapi:
[0124]
[0125]
[0126] It should be further explained that the file interface automation implementation will run on the server, and the tester will configure the interface through the basic configuration interface. When configuring the file interface, the tester needs to configure additional file upload templates and file expectation verification templates.
[0127] Before configuring the file upload template and the file expectation verification template, the tester needs to maintain the template content according to the rules specified by the implementation method.
[0128] The following is explained through specific examples:
[0129] There is a system under test, which is mainly used to manage the personal files of enterprise employees;
[0130] The tested system has interface A, the input parameter is the employee number, and the output parameter is the employee number and employee name;
[0131] There is an interface B, the input parameter is an xlsx file, the file contains the fields employee number, employee name, employee ID number, employee mobile phone number, employee current salary, employee comments. After uploading the file to this interface, the corresponding employee information in the system will be completed;
[0132] There is an interface C, the input parameter is the employee number, and the output parameter is a doc file, which contains information such as employee number, employee name, employee ID number, employee mobile phone number, employee current salary, employee comments, etc. This interface is used to export employee information;
[0133] Testers use the implementation method to perform automated testing on the above interfaces;
[0134] For interface A, the tester passes in the specified employee number "20240102-0001", and saves the preset employee number in the variable "${usercode}", and the employee name in the variable "${username}". At this time, the above processing module of the implementation method will save the employee number "20240102-0001" to the variable "${usercode}" and the employee name "Xiao Shuai" to the variable "${username}" during the actual execution of the interface.
[0135] For interface B, the tester will maintain an xlsx file template named "employee information upload file template.xlsx". In this file template, the tester presets the employee information according to the rules provided by the implementation method:
[0136] The employee ID is "${usercode}",
[0137] The employee's name is "${username}",
[0138] The employee ID number is "#{idno_random}",
[0139] The employee's mobile phone number is "#{phone_random}",
[0140] The current salary of the employee is "#{random(10000,20000,2)}",
[0141] The employee's comment is "#{random(zh,10)}";
[0142] When interface B starts running, the upload file template processing module will start working, read the configured template file "employee information upload file template.xlsx" for parsing, find the above-mentioned associated variables wrapped with the symbols "${" and "}" and the dynamic macro variables wrapped with the symbols "#{" and "}", and perform dynamic replacement, as follows:
[0143] The employee number "${usercode}" is replaced with "20240102-0001".
[0144] The employee name "${username}" is replaced with "Xiaoshuai",
[0145] The employee ID number "#{idno_random}" is replaced with "330*****0713",
[0146] The employee's mobile phone number "#{phone_random}" is replaced with "186****4645".
[0147] The employee's current salary "#{random(10000,20000,2)}" is replaced with "12345.11",
[0148] The employee comment "#{random(zh,10)}" was replaced with "It's fixed and you have to work hard";
[0149] After all replacements are completed, the upload file template processing module saves the replaced content as a new file "Employee Information Upload File-20240101.xlsx" and calls interface B to upload;
[0150] At the same time, the upload file template processing module automatically generates the following context-related variables:
[0151] The value of ${idno_random} is "330*****0713"
[0152] The value of ${phone_random} is "186****4645"
[0153] The value of ${random(10000,20000,2)} is "12345.11";
[0154] The value of ${random(zh,10)} is "fixed and you have to work hard";
[0155] After interface B is completed, the tester verifies whether the upload of interface B is successful by calling interface C. When maintaining the automation use case of interface C, the tester presets the expected verification file template as "employee information export template.doc". The content of the template file is as follows:
[0156] ID: ${@3@usercode};
[0157] Name: ${@3@username};
[0158] ID number: ${@6@idno_random};
[0159] Phone number: ${@5@phone_random};
[0160] Current salary: ${@5@random(10000,20000,2)};
[0161] Comment: ${@3@random(zh,10)};
[0162] When interface C is finished running, the download file expectation verification module will save the file returned by interface C to "employee information export.doc", and read the preset expectation verification file template as "employee information export template.doc" and parse it, and search according to the above-mentioned associated variables wrapped with the symbols "${" and "}" and the dynamic macro variables wrapped with the symbols "#{" and "}", and replace the dynamic values in sequence, such as:
[0163] When "${@3@usercode}" is found, "@3@" is extracted and temporarily saved;
[0164] Dynamically replace the extracted "${usercode}" with "20240102-0001";
[0165] Then, the first three characters of “${@3@usercode}” are intercepted according to “@3@”:
[0166] Assemble the two into "No.: 20240102-0001";
[0167] Search and match the result file "employee information export.doc" according to the assembly value;
[0168] If the match is successful, the ${@3@usercode} verification passes, and the next verification is continued until all verifications are completed. During the matching verification process, the verification successes and verification failures will be counted. If the final failure count is 0, the output is verification passed, otherwise the output is verification failed.
[0169] Of course, the above example is only one example, and there are also different examples as follows:
[0170] Combination Figure 2As shown in the figure, there is a situation where there are no associated variables and dynamic macro variables in the configured file upload template. The upload file template processing module will skip processing for this situation and directly use the template file for interface call;
[0171] Combination Figure 2 As shown in the figure, there are multiple identical dynamic macro variables "#{(yyyy-MM-dd)-1}". The uploaded file template processing module will replace all "#{(yyyy-MM-dd)-1}" at once instead of replacing them one by one.
[0172] Combination Figure 2 As shown, if there are context-related variables that cannot be found to save values or dynamic macro variables that cannot be identified, the file template processing module will terminate the program and output an error message.
[0173] Combination Figure 3 As shown, there is a situation where the configured expected verification file template does not have the above-mentioned associated variables and dynamic macro variables. The downloaded file expected verification module will perform a one-time verification match on the entire file;
[0174] Combination Figure 3 As shown, when the download file expectation verification module searches for a matching item in the result file returned by the interface and finds that there are multiple return values, the download file expectation verification module will return the expected verification file template to count the number of matching items. If the number of the expected verification file template and the number of the result file are equal, the matching items will be matched in sequence. If the number is not equal, the program will be terminated and an error message of "the expected verification file template is set incorrectly" will be output.
[0175] It should be understood that the above specific embodiments of the present invention are only used to illustrate or explain the principles of the present invention, and do not constitute a limitation of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. In addition, the appended claims of the present invention are intended to cover all changes and modifications that fall within the scope and boundaries of the appended claims, or the equivalent forms of such scope and boundaries.
Claims
1. A method for realizing automatic file interface, characterized in that: The following steps are involved: Step 1: Basic configuration interface: provides general interface configuration capabilities, as well as the configuration capabilities of file upload templates and file expectation verification templates during interface configuration; Step 2: Run the server: used to carry the operation, calculation, communication and storage capabilities of each module in the file interface automation implementation method; Step 3: Upload file template processing module: Provides the ability to prepare files required by the upload interface; Step 4: Download file expectation verification module: provides the file saving and verification capabilities required by the download interface; Step 5: The above processing module provides the ability to obtain the values of some fields in the response information returned by the above interface.
2. A method for realizing automatic file interface according to claim 1, characterized in that: The basic configuration interface includes the following steps: Step 1: Provide a user interface that allows users to enter and manage basic information about the interface; Step 2: Allow users to upload and select file upload templates, supporting multiple file formats, including xlsx, xls, csv, txt, json, config, doc, docx; Step 3: Provide the editing function of the file upload template. Users can edit and save the template content as needed; Step 4: Allow users to configure the expected file verification template, including expected file content and verification rules; Step 5: Provide interface parameter configuration function, users can configure the parameters required by the interface, including path parameters, query parameters and request body parameters; Step 6: Provide interface authentication configuration function, users can configure the authentication information required by the interface, including API key and OAuth token; Step 7: Save the configuration information for use in the automated testing process.
3. A method for realizing automatic file interface according to claim 2, characterized in that: The running server comprises the following steps: Step 1: Start the server and ensure that it has an environment that can support the operation of the automated test module; Step 2: Configure server resources, including CPU, memory, and storage, to meet the needs of automated testing; Step 3: Deploy each module in the file interface automation implementation method to the server; Step 4: Ensure that the server has the ability to process data and perform logical operations; Step 5: Configure the server's network communication capabilities to ensure data exchange between modules and with external systems; Step 6: Set up the server's storage system to store file templates, expected verification templates, and data and results generated during the test.
4. A method for realizing automatic file interface according to claim 3, characterized in that: The uploaded file template processing module includes the following steps: Step 1: Parse the file upload template configured by the user and identify the context-related variables and dynamic macro variables in the template; Step 2: According to the associated variables above, dynamically obtain the response information after the front-end interface is executed, and replace the variables in the template; Step 3: Generate text content in the required format according to the dynamic macro variable template, and replace the macro variables in the template; Step 4: Pre-process the template file to ensure that the file content complies with the business correctness of the interface and the correctness of the content format; Step 5: Save the processed file as a new file and prepare to upload it to the target interface; Step 6: Call the target interface, upload the processed file, and record the interface response.
5. A method for realizing automatic file interface according to claim 4, characterized in that: The download file expectation verification module includes the following steps: Step 1: Receive and save the downloaded file returned by the interface; Step 2: Parse the expected verification template of the file configured by the user, and identify the context-related variables and dynamic macro variables in the template; Step 3: According to the associated variables above, dynamically obtain the above response information and replace the variables in the expected verification template; Step 4: Generate expected content values according to the dynamic macro variable template and replace the macro variables in the expected verification template; Step 5: Compare the expected verification template with the content of the actual downloaded file to verify whether the interface return meets expectations; Step 6: Record the verification results. If all verification items pass, output a verification success flag; if any verification item fails, output a verification failure flag.
6. A method for realizing automatic file interface according to claim 5, characterized in that: The above processing module includes the following steps: Step 1: Capture the response information after the front-end interface is executed; Step 2: Analyze the response information and extract the required field values; Step 3: Save the extracted field values as the above associated variables for use in subsequent modules; Step 4: In the upload file template processing module and the download file expectation verification module, dynamically replace the above-mentioned associated variables in the file template with actual values; Step 5: In the download file expectation verification module, use the above associated variables to match and verify the content; Step 6: Provide management and query functions for the above associated variables to facilitate debugging and verification during the automated testing process.
7. A method for realizing automatic file interface according to claim 6, characterized in that: The upload file template processing module supports file processing in the formats of xlsx, xls, csv, txt, json, config, doc, and docx, and the download file expectation verification module supports the saving and verification of files in the formats of xlsx, xls, csv, txt, json, config, doc, and docx.