Test case importing method, system, storage medium and program product
By loading environment configuration files and converting interface documents to generate tag files, test cases are automatically generated and imported into the testing system, solving the problem of high error rates in manual configuration and achieving efficient and automated test case generation and import.
Patent Information
- Application Number
- CN202610952196.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-29
- Publication Date
- 2026-11-06
AI Technical Summary
In existing technologies, when manually configuring test cases and importing them into the test system using semi-automatic tools, the error rate is high, and automated parallel processing cannot be achieved, resulting in low efficiency.
By loading the environment configuration file, parsing parameters, and converting unstructured interface documents into interface documents, target tag files are generated. Test cases are automatically generated and imported based on the tag files, including field mapping, logical expressions, and variable substitution strategies. Regular expressions are used to verify parameter compliance, achieving automated generation and import.
It reduced the error rate, improved the accuracy of test case generation and import, shortened configuration time, increased efficiency, reduced manual intervention, and achieved automated batch processing.
Smart Images

Figure CN123048385A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of financial technology or software testing, specifically to a test case import method, system, storage medium, and program product. Background Technology
[0002] In the field of interface testing, related technologies primarily rely on testers manually filling in the input parameters, expected outputs, and assertion rules of test cases in the test system based on their understanding, and then checking the configuration item by item to ensure its correctness. This process requires repeated verification of fields, logical expressions, and data preparation items, relying on human experience to judge the completeness and accuracy of the configuration.
[0003] Both manual configuration and semi-automatic tools are time-consuming, with configuration times for a single service case reaching several hours. Furthermore, batch imports require execution item by item, making parallel processing impossible. The level of automation is insufficient, failing to achieve a complete workflow from document conversion to case import, still requiring manual intervention in key steps (such as data preparation and assertion configuration), resulting in low processing efficiency and a high error rate.
[0004] There is currently no effective solution to the problem of high error rates when manually configuring and importing test cases into the test system using manual or semi-automatic tools in related technologies. Summary of the Invention
[0005] The main purpose of this application is to provide a test case import method, system, storage medium, and program product to solve the problem of high error rate in related technologies when using manual configuration and semi-automatic tools to configure test cases and import them into the test system.
[0006] To achieve the above objectives, according to one aspect of this application, a test case import method is provided. The method includes: in response to a command-line instruction, loading an environment configuration file of the environment to be tested, and parsing parameters in the environment configuration file to obtain environment configuration parameters; converting an unstructured interface document of the environment to be tested into an interface document to obtain a target interface document; generating a target tag file based on the environment configuration parameters and the target interface document, wherein the target tag file includes a generation strategy for test cases to be generated; generating N test cases based on the target tag file, and importing the N test cases into a test system, wherein the test system includes a system for managing test cases, and N is a positive integer.
[0007] Furthermore, the target tag file includes: field mapping relationships, logical expressions, and variable substitution strategies. The field mapping relationships define the correspondence between interface fields and fields in the test cases. The logical expressions define the conditional judgment logic in the test cases. The variable substitution strategies define the value rules for dynamic variables in the test cases. Based on the target tag file, N test cases are generated, including: obtaining a preset template format, wherein the preset template format includes a test case template format that conforms to the requirements of the testing system; generating a template file based on the preset template format and the target tag file, and generating N test cases based on the template file, wherein the template file includes a template for generating the test cases.
[0008] Further, importing the N test cases into the test system includes: uploading the N test cases to the target interface of the test system and receiving the response result returned by the test system; if the response result indicates that the N test cases have not been received by the test system, determining that the import of the N test cases into the test system has failed, and recording the information associated with the import failure; if the response result indicates that the N test cases have been received by the test system, determining that the N test cases have been successfully imported into the test system through the target interface.
[0009] Furthermore, the environment configuration parameters include: connection parameters associated with the environment to be tested. Before generating the target tag file based on the environment configuration parameters and the target interface document, the method further includes: verifying whether the connection parameters are accurate to obtain a first verification result; if the first verification result indicates that the connection parameters are inaccurate, correcting the parameters in the environment configuration file; if the first verification result indicates that the connection parameters are accurate, performing the step of generating the target tag file based on the environment configuration parameters and the target interface document.
[0010] Furthermore, the test case import method also includes: generating an operation log; if the number of lines in the operation log exceeds a preset number of lines, retaining the last M lines of the operation log in chronological order to obtain a target log; wherein the operation log includes: the generation and import records of the test cases; obtaining the version information of the environment configuration file; and recording the target log and the version information.
[0011] Further, the unstructured interface document of the test environment is converted into an interface document to obtain the target interface document, including: extracting field data from the unstructured document using a first regular expression, wherein the field data includes at least one of the following: interface identifier, request parameters of the interface in the test environment, and response fields of the interface; and converting the field data into a preset format to obtain the target interface document.
[0012] Furthermore, before loading the environment configuration file of the environment to be tested, the method further includes: extracting the parameters of the command line instruction using a second regular expression to obtain command parameters; performing compliance verification on the command parameters to obtain a second verification result; if the second verification result indicates that the command parameters are compliant, executing the step of loading the environment configuration file of the environment to be tested; if the second verification result indicates that the command parameters are non-compliant, generating an error message.
[0013] To achieve the above objectives, according to another aspect of this application, a test case import system is provided. This system, used to execute any of the test case import methods described in the application, includes: a command parsing module for receiving command-line instructions and parsing the command-line instructions; a configuration management module for loading an environment configuration file of the environment to be tested and parsing the parameters in the environment configuration file to obtain environment configuration parameters; a document conversion module for converting the unstructured interface document of the environment to be tested into an interface document to obtain a target interface document; a tag file generation module for generating a target tag file based on the environment configuration parameters and the target interface document, wherein the target tag file includes: a generation strategy for generating test cases to be generated; a test case generation module for generating N test cases based on the target tag file; and an import module for importing the N test cases into the test system, wherein the test system includes: a system for managing test cases, and N is a positive integer.
[0014] To achieve the above objectives, according to another aspect of this application, a test case import apparatus is provided. The apparatus includes: a first processing unit, configured to, in response to a command-line instruction, load an environment configuration file of the environment to be tested and parse the parameters in the environment configuration file to obtain environment configuration parameters; a conversion unit, configured to convert the unstructured interface document of the environment to be tested into an interface document to obtain a target interface document; a first generation unit, configured to, based on the environment configuration parameters and the target interface document, generate a target tag file, wherein the target tag file includes a generation strategy for the test cases to be generated; and a second processing unit, configured to, based on the target tag file, generate N test cases and import the N test cases into a test system, wherein the test system includes a system for managing test cases, and N is a positive integer.
[0015] Furthermore, the target tag file includes: field mapping relationships, logical expressions, and variable substitution strategies. The field mapping relationships define the correspondence between interface fields and fields in the test cases. The logical expressions define the conditional judgment logic in the test cases. The variable substitution strategies define the value rules for dynamic variables in the test cases. The second processing unit includes: an acquisition subunit for acquiring a preset template format, wherein the preset template format includes a test case template format that conforms to the requirements of the testing system; and a first processing subunit for generating a template file based on the preset template format and the target tag file, and generating N test cases based on the template file, wherein the template file includes a template for generating the test cases.
[0016] Further, the second processing unit includes: a second processing subunit, configured to upload N test cases to the target interface of the testing system and receive the response result returned by the testing system; a third processing subunit, configured to determine that the import of N test cases into the testing system has failed when the response result indicates that N test cases have not been received by the testing system, and to record the information associated with the import failure; and a determining subunit, configured to determine that N test cases have been successfully imported into the testing system through the target interface when the response result indicates that N test cases have been received by the testing system.
[0017] Furthermore, the environment configuration parameters include: connection parameters associated with the environment to be tested. The test case import device further includes: a verification unit, used to verify whether the connection parameters are accurate before generating a target tag file based on the environment configuration parameters and the target interface document, and obtain a first verification result; a correction unit, used to correct the parameters in the environment configuration file when the first verification result indicates that the connection parameters are inaccurate; and an execution unit, used to execute the step of generating a target tag file based on the environment configuration parameters and the target interface document when the first verification result indicates that the connection parameters are accurate.
[0018] Furthermore, the test case import device also includes: a third processing unit, used to generate an operation log, and when the number of lines in the operation log exceeds a preset number of lines, retaining the last M lines of the operation log in chronological order to obtain a target log, wherein the operation log includes: the generation and import records of the test cases; an acquisition unit, used to acquire the version information of the environment configuration file; and a recording unit, used to record the target log and the version information.
[0019] Further, the conversion unit includes: an extraction subunit, used to extract field data from the unstructured document using a first regular expression, wherein the field data includes at least one of the following: an interface identifier, request parameters of the interface in the test environment, and response fields of the interface; and a conversion subunit, used to convert the field data into a preset format to obtain the target interface document.
[0020] Furthermore, the test case import device also includes: an extraction unit, used to extract the parameters of the command line instruction using a second regular expression before loading the environment configuration file of the environment to be tested, to obtain command parameters; a verification unit, used to perform compliance verification on the command parameters to obtain a second verification result; an execution unit, used to execute the step of loading the environment configuration file of the environment to be tested if the second verification result indicates that the command parameters are compliant; and a second generation unit, used to generate an error message if the second verification result indicates that the command parameters are non-compliant.
[0021] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is executed, it controls the device where the computer-readable storage medium is located to perform the test case import method.
[0022] According to another aspect of this application, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the test case import method during runtime.
[0023] According to another aspect of this application, a computer program product is provided, including computer instructions that, when executed by a processor, implement the steps of the test case import method.
[0024] In this application, the following method is adopted: responding to command-line instructions, the environment configuration file of the environment to be tested is loaded, and the parameters in the environment configuration file are parsed to obtain environment configuration parameters; the unstructured interface document of the environment to be tested is converted into an interface document to obtain the target interface document; based on the environment configuration parameters and the target interface document, a target tag file is generated, wherein the target tag file includes: the generation strategy of the test cases to be generated; based on the target tag file, N test cases are generated, and the N test cases are imported into the test system, wherein the test system includes: a system for managing test cases, and N is a positive integer. This solves the technical problem of high error rate in related technologies that use manual configuration and semi-automatic tools to configure test cases and import them into the test system. In this application, by converting the interface document and parsing the parameters, a tag file is generated, and test cases are automatically generated and imported into the test system based on the tag file. This avoids the high error rate of using manual configuration and semi-automatic tools to configure test cases and import them into the test system in related technologies, achieving the goal of automated test case generation, thereby realizing the technical effect of improving the accuracy of low test case generation and import. Attached Figure Description
[0025] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0026] Figure 1 A hardware structure block diagram of a computer terminal for implementing a test case import method is shown.
[0027] Figure 2 This is a flowchart of the test case import method provided in the embodiments of this application;
[0028] Figure 3 This is a schematic diagram of importing test cases into the system according to the embodiments of this application;
[0029] Figure 4 This is a schematic diagram of a test case import device provided according to an embodiment of this application;
[0030] Figure 5This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] It should be noted that the test case import method and apparatus in this application can be used in the field of fintech for test case generation and import, and can also be used in any field other than fintech for test case generation and import. This application does not limit the application field of the test case import method and apparatus.
[0034] First, some nouns or terms that appear in the description of the embodiments of this application shall be interpreted as follows:
[0035] An automated test configuration tool for batch importing and managing API test cases into the test system, improving testing efficiency and accuracy.
[0036] CSV (Comma Separated Values) tag file: A structured tag file used to identify key fields, logical expressions, variables, and other information in test cases, facilitating subsequent test case generation and import.
[0037] Structured documents: Convert unstructured interface documents into documents with clearly defined fields and formats, making them easier to parse and process.
[0038] Data preparation: Pre-test data configuration before test case execution, including database data, data pool, and pre-test cases.
[0039] Default assertion: The default expected output field after the test case is executed, used to determine whether the test passes or fails.
[0040] Environment configuration: The testing tool supports switching between multiple environments, including database connection, SFTP (Secure File Transfer Protocol) server configuration, etc.
[0041] The tiecase command is a core command in automated test configuration tools, used to automatically import test cases into the test system.
[0042] Version management: The tool supports automatic backup and version updates, making it easy to trace historical configurations.
[0043] YAML is a highly readable data serialization standard format. It allows for hierarchical structures to be represented through indentation and uses key-value pairs to store data.
[0044] It should be noted that the information collected in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with relevant laws and standards, have taken necessary security measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse. For example, this system has interfaces with relevant users or organizations, providing users with corresponding operation entry points for users to choose to agree to or refuse automated decision results; if the user chooses to refuse, the process proceeds to the expert decision-making stage.
[0045] This invention can be applied to various software products, control systems, and client-side (including but not limited to: mobile clients, PCs, etc.) control systems of financial institutions. Taking software products as an example, the invention illustrates the interface testing of software products installed on mobile clients through test cases. Software products that pass the interface test can accurately handle the business content of financial institutions (including but not limited to: transfer, wealth management, funds, payment, account inquiry, advertising, recommendation, and other business functions).
[0046] Example 1
[0047] According to an embodiment of this application, a method embodiment for importing test cases is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0048] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a test case import method is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0049] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0050] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the test case import method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the above-mentioned test case import method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0051] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0052] The display can be, for example, a touchscreen liquid crystal display (LCD), which allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0053] Under the aforementioned operating environment, this application provides the following: Figure 2 The test case import method shown. Figure 2 This is a flowchart of the test case import method according to Embodiment 1 of this application.
[0054] Step S201: In response to the command line instruction, load the environment configuration file of the environment to be tested, and parse the parameters in the environment configuration file to obtain the environment configuration parameters.
[0055] The command-line instructions mentioned above can be used to request the addition, deletion, or modification of test cases. These instructions may include tiecase (test case generation and import), import (batch import), and struct (structure / document conversion).
[0056] In this embodiment, after receiving the user's command line input, the command format can be matched using regular expressions to extract the command name and parameters, and the validity of the parameters can be verified. If the parameters are missing or the format is incorrect, a prompt message will be output. If the verification passes, the processing logic corresponding to the command type of the command line instruction (e.g., adding a test case, deleting a test case, modifying a test case, etc.) will be called.
[0057] The aforementioned test environment can refer to: the system, software, etc., to be tested for interface testing. The environment configuration parameters may include, but are not limited to: the database connection string, SFTP server address, log path, etc. of the database in the test environment. In this embodiment, the corresponding YAML configuration file can be loaded according to the environment variables of the test environment, and the parameters therein can be parsed to obtain the environment configuration parameters.
[0058] Step S202: Convert the unstructured interface document of the environment to be tested into an interface document to obtain the target interface document.
[0059] In this embodiment, unstructured interface documents can be converted into structured documents (such as JSON or XML) for easier subsequent processing. In this embodiment, interface fields in unstructured interface documents can be extracted based on regular expressions to generate structured documents (i.e., target interface documents). Unstructured interface documents include documents generated by word processing software and Markdown (lightweight markup language). Interface fields include URLs (Uniform Resource Locators), request methods, and parameters.
[0060] Step S203: Based on the environment configuration parameters and the target interface document, generate a target tag file, wherein the target tag file includes: the generation strategy of the test cases to be generated.
[0061] In this embodiment, the interface field information in the target interface document is read, and combined with the test rules configured by the user in the environment configuration parameters (such as field value range, logical conditions, and variable substitution rules), a CSV tag file (corresponding to the target tag file) containing field mapping relationships, logical expressions, variable substitution strategies, etc. is generated by calling the large model interface. The field mapping relationship can be used to define the correspondence between interface fields and test case fields, the logical expression can be used to define the condition judgment logic in the test case, and the variable substitution strategy can be used to define the value rules of dynamic variables in the test case.
[0062] Step S204: Based on the target tag file, generate N test cases and import the N test cases into the test system. The test system includes a system for managing test cases, where N is a positive integer.
[0063] In this embodiment, a test case import template can be generated based on the target tag file. The test case import template can generate and export test cases in batches. For example, the fields and logical rules in the target tag file can be parsed to generate a test case import template that meets the requirements of the test system, and N test cases can be generated based on the test case import template.
[0064] After obtaining N test cases, a parallel import method can be used to import the N test cases into the test system, thereby improving the efficiency of test case import.
[0065] Through the above steps, in this embodiment, a tag file is generated by converting the interface document and parsing parameters. Test cases are then automatically generated based on the tag file and imported into the test system. This avoids the high error rate associated with manual configuration and semi-automatic tool configuration of test cases in related technologies, achieving the goal of automated test case generation. This significantly improves the accuracy of test case generation and import. Furthermore, it solves the technical problem of high error rates associated with manual configuration and semi-automatic tool configuration of test cases in related technologies.
[0066] Optionally, in the test case import method provided in this application embodiment, the target tag file includes: field mapping relationship, logical expression, and variable substitution strategy. The field mapping relationship is used to define the correspondence between interface fields and fields in the test case. The logical expression is used to define the condition judgment logic in the test case. The variable substitution strategy is used to define the value rules of dynamic variables in the test case. Based on the target tag file, N test cases are generated, including: obtaining a preset template format, wherein the preset template format includes: a test case template format that meets the requirements of the test system; generating a template file based on the preset template format and the target tag file, and generating N test cases based on the template file, wherein the template file includes: a template used to generate the test cases.
[0067] The target tag file mentioned above includes: field mapping relationships, logical expressions, and variable substitution strategies. Field mapping relationships can be used to define the correspondence between interface fields in the test environment and fields in the test cases. Logical expressions are used to define the condition judgment logic in the test cases. Variable substitution strategies are used to define the value rules of dynamic variables in the test cases (for example, changes that can be made by substitution in the generated test cases).
[0068] In this embodiment, the field mapping relationships, logical expressions, variable substitutions, and other contents in the target tag file can be read. Combined with the predefined test system test case template format, the field mapping relationships are converted into test case field definitions, the logical expressions are converted into conditional judgment logic in the test case, and the variable substitution rules are converted into variable definitions in the test case. This generates a test case template file (corresponding to the template file) that meets the requirements of the test system. Through the template file, test cases in table or CVS format can be generated and exported in batches, thus obtaining the above-mentioned N test cases, achieving the effect of automated batch generation of test cases.
[0069] Optionally, in the test case import method provided in this application embodiment, importing N test cases into the test system includes: uploading the N test cases to the target interface of the test system and receiving the response result returned by the test system; if the response result indicates that the N test cases have not been received by the test system, determining that the import of the N test cases into the test system has failed, and recording the information associated with the import failure; if the response result indicates that the N test cases have been received by the test system, determining that the N test cases have been successfully imported into the test system through the target interface.
[0070] In this embodiment, N generated test cases can be automatically imported into the testing system, and verification and error prompts can be performed. For example, an HTTP (Hypertext Transfer Protocol) request can be constructed, and the test case files can be uploaded as attachments to a designated interface of the testing system. The response returned by the testing system can be received, and the content of the response can be parsed to determine whether the import was successful. For example, the HTTP status code (e.g., 200 for success, 4xx / 5xx for failure) and the business data in the response can be parsed. By comparing with the preset success flag, it can be determined whether the import operation has achieved the expected results. If the import fails, an error message is recorded and the user is notified; if the import succeeds, a success message is recorded and the system status is updated, thereby improving the reliability of test case import.
[0071] Optionally, in the test case import method provided in this application embodiment, the environment configuration parameters include: connection parameters associated with the environment to be tested. Before generating the target tag file based on the environment configuration parameters and the target interface document, the method further includes: verifying whether the connection parameters are accurate and obtaining a first verification result; if the first verification result indicates that the connection parameters are inaccurate, correcting the parameters in the environment configuration file; if the first verification result indicates that the connection parameters are accurate, performing the step of generating the target tag file based on the environment configuration parameters and the target interface document.
[0072] The connection parameters associated with the test environment can include, but are not limited to: connection parameters of the database in the test environment, and connection parameters of the server in the test environment. The following example illustrates this using the database connection parameters as the connection parameters for the test environment:
[0073] During the loading of the environment configuration file, the correctness of database connection parameters can be verified. If errors are found, the user is prompted to correct them. For example, the validity of the connection parameters can be verified by attempting to establish an actual physical or logical connection (such as initiating a database Ping request or connectivity test). The success or failure of the database connection can be determined based on the boolean value or status code returned by the database, thus confirming the validity of the connection parameters. If the first verification result indicates that the connection parameters are inaccurate, the environment configuration parameters can be corrected. If the first verification result indicates that the connection parameters are accurate, the step of generating a target tag file based on the environment configuration parameters and the target interface document is executed. This achieves the technical effect of improving the accuracy of test case generation.
[0074] Optionally, in the test case import method provided in the embodiments of this application, the test case import method further includes: generating an operation log; if the number of lines in the operation log exceeds a preset number of lines, retaining the last M lines of the operation log in chronological order to obtain the target log, wherein the operation log includes: test case generation and import records; obtaining the version information of the environment configuration file; and recording the target log and the version information.
[0075] For example, operation logs can be recorded in real time during the generation and import of test cases into the test system. These logs include execution records of command-line instructions, configuration file loading records, data processing records, and error messages. The log content can be stored in chronological order, and it is supported to retain only the last M lines (e.g., 100 lines) of the log to reduce redundancy. At the same time, a version backup file can be automatically generated each time the configuration file is modified. The backup file is named config_vX.XXyaml, where XXX is the version number. The version number is automatically generated by the system and increments to ensure that configuration changes are traceable.
[0076] Optionally, in the test case import method provided in this application embodiment, converting the unstructured interface document of the test environment into an interface document to obtain the target interface document includes: extracting field data from the unstructured document using a first regular expression, wherein the field data includes at least one of the following: interface identifier, request parameters of the interface in the test environment, and response fields of the interface; and converting the field data into a preset format to obtain the target interface document.
[0077] In this embodiment, the content of the original interface document (corresponding to the unstructured document) can be read, and regular expressions can be used to match field data (e.g., interface name, request method, request path, request parameters, response fields, etc.) to extract field data from the unstructured document. The extracted results can also be used to generate a structured document according to a preset format (e.g., a predefined JSON or XML) and saved to a specified path.
[0078] Optionally, in the test case import method provided in this application embodiment, before loading the environment configuration file of the environment to be tested, the method further includes: extracting the parameters of the command line instruction using a second regular expression to obtain command parameters; performing compliance verification on the command parameters to obtain a second verification result; if the second verification result indicates that the command parameters are compliant, executing the step of loading the environment configuration file of the environment to be tested; and generating an error message if the second verification result indicates that the command parameters are not compliant.
[0079] In this embodiment, after receiving command-line instructions (such as tiecase, import, struct, etc.) input by the user, the command type and parameters can be parsed. The command-line interface library (an open-source Java library for processing command-line parameters) is used for parameter parsing, which can perform command aliases, parameter validation, help information output, etc. The specific processing process can include: after receiving the command-line instruction input, matching the command format through regular expressions, extracting the command name and parameters, validating the validity of the parameters, outputting error messages if the parameters are missing or the format is incorrect, and calling the corresponding processing logic if the validation passes. This achieves the technical effect of improving the reliability of command-line instruction processing associated with test cases.
[0080] In this embodiment, by linking command parsing, document conversion, and test case generation modules, the process of converting interface documents into test cases can be automated, reducing configuration time from several hours to 5 minutes, improving efficiency by over 1000%. It can also automatically back up configuration files and generate version numbers, supporting historical rollback and reducing maintenance costs by 60%. Dynamic environment configuration switching improves deployment flexibility by 80%. CSV tag files support dynamic variables, conditional values, and outlier generation, achieving 95% test scenario coverage. The integrated `tiecase` command enables one-click completion of service configuration, test case import, and data preparation, reducing manual intervention by 90%. Only critical logs are retained, reducing troubleshooting time by 50%.
[0081] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0082] Example 2
[0083] Embodiment 2 of the present invention provides an optional test case import system, which can be used to execute the test case import method provided in Embodiment 1 of the present invention.
[0084] The test case import system includes: a command parsing module for receiving and parsing command-line instructions; a configuration management module for loading the environment configuration file of the environment to be tested and parsing the parameters in the environment configuration file to obtain the environment configuration parameters; a document conversion module for converting the unstructured interface document of the environment to be tested into an interface document to obtain the target interface document; a tag file generation module for generating a target tag file based on the environment configuration parameters and the target interface document, wherein the target tag file includes: a generation strategy for generating test cases to be generated; a test case generation module for generating N test cases based on the target tag file; and an import module for importing the N test cases into the test system, wherein the test system includes: a system for managing test cases, where N is a positive integer.
[0085] Figure 3 This is a schematic diagram of the test case import system provided in the embodiments of this application, such as... Figure 3 As shown, the system includes a command parsing module, a configuration management module, a document conversion module, a tag file generation module, a test case generation module, an automatic import module, and a log management module.
[0086] The command parsing module can receive command-line instructions (such as tiecase, import, struct, etc.) input by the user, and parse out the command type and parameters. It uses a command-line interface library for parameter parsing and can perform command aliases, parameter validation, and help information output. The specific processing steps include: after receiving the command-line instruction input, matching the command format using regular expressions, extracting the command name and parameters, validating the parameters, outputting prompt information if parameters are missing or incorrectly formatted, and calling the processing logic of the corresponding module if the validation passes.
[0087] The configuration management module can be used to manage configuration files for multiple environments, supporting dynamic switching of configurations such as database connection, SFTP server, and log path. The configuration files are stored in YAML format and support multiple environment configurations. The current environment of the system under test can be switched using the `env` command (a command-line subcommand used to switch the environment configuration of the system under test). Specifically, the system reads the environment variables under test, loads the corresponding YAML configuration file, parses the parameters such as the database connection string, SFTP server address, and log path, and injects them into the runtime context of the system to ensure that each module can obtain the correct configuration information according to the current environment.
[0088] The document conversion module can convert unstructured interface documents into structured documents (such as JSON and XML) for easier subsequent processing. It extracts interface fields (such as URL, request method, and parameters) based on regular expressions and generates structured documents. The specific processing steps include: reading the original document content, using regular expressions to match key information such as interface name, request method, request path, request parameters, and response fields, organizing the extracted results according to a predefined JSON or XML format, generating a structured document, and saving it to a specified path for use by subsequent modules.
[0089] The tag file generation module can generate a CSV tag file (corresponding to the target tag file in Example 1) based on the structured document and user configuration (corresponding to the environment configuration parameters in Example 1). This CSV file is used for subsequent test case generation. It calls the gz3-testcase tool and performs document analysis in conjunction with the large model to generate a CSV file containing field mappings, logical expressions, variable substitutions, etc. The specific processing includes: reading the interface field information in the structured document, combining it with the user-configured test rules (such as field value ranges, logical conditions, and variable substitution rules), and generating a CSV tag file containing field mapping relationships, logical expressions, variable substitutions, etc. by calling the large model interface in the test case intelligent generation engine. The field mapping relationship can be used to define the correspondence between interface fields and test case fields, the logical expression can be used to define the condition judgment logic in the test case, and the variable substitution can be used to define the value rules of dynamic variables in the test case.
[0090] The test case generation module can generate test case import templates based on CSV tag files, batch generate and export tests, parse fields and logical rules in CSV files, and generate test case template files that meet the requirements of the test system. The specific processing includes: reading field mapping relationships, logical expressions, variable substitutions, etc. in the CSV tag file, combining them with the predefined test system test case template format, converting field mapping relationships into test case field definitions, logical expressions into conditional judgment logic in test cases, and variable substitution rules into variable definitions in test cases, generating test case template files that meet the requirements of the test system, and batch generating and exporting test cases as tables or CSV formats.
[0091] The import module can automatically import the generated test cases into the test system, perform verification and error prompts, and interact with the test system via the HTTP protocol to upload test case files and verify the import results. The specific processing includes: constructing an HTTP request, uploading the test case files as attachments to the specified interface of the test system, receiving the response results returned by the test system, parsing the response content to determine whether the import was successful, recording error information and prompting the user if the import fails, and recording success information and updating the system status if the import is successful.
[0092] The log management module can record the running logs of test cases imported into the system, and can also optimize logs and back up versions, facilitating problem tracking and version management. When the configuration file is modified, a version backup (such as config_v1.0.yaml) can be automatically generated. The specific processing includes: recording the operation logs of each module in real time during the test case import and execution process, including command execution records, configuration loading records, data processing records, error messages, etc. The log content is stored in chronological order, and only the last M lines (e.g., 100 lines) of the log can be retained to reduce redundancy. At the same time, a version backup file is automatically generated every time the configuration file is modified. The backup file naming rule is config_vX.XXyaml, where XXX is the version number. The version number is automatically generated by the system and increments to ensure that configuration changes are traceable.
[0093] The test case import system workflow is as follows: Users input commands via the command line (e.g., `tiecase test1`). The command parsing module parses the command and calls the corresponding functional module. The configuration management module loads the current environment configuration file and verifies the database connection parameters. If errors are found, the user is prompted to correct them. The automatic import module checks if the service is configured in the test system. If not, the user is prompted to create the service. If not configured, the system automatically generates a basic template by defaulting to the input message or assertion. The CSV tag file generation module parses the CSV file and generates a test case import template. The automatic import module imports the test cases into the test system and records logs and version backups. Users can configure multiple test cases at once using the import table template; the system parses and imports them in batches.
[0094] In one optional example, the CSV tag file can handle dynamic variables (such as {{#datapool.XXX}}), conditional values (such as [if:trxtype=='1':1,2;]), and outlier generation (such as generating edge cases when column H is marked "Yes"). Specifically, the implementation can be as follows: extract dynamic variables, conditional expressions, and outlier tags from the CSV file using regular expressions, identify variable names, conditional logic, and outlier generation rules, and perform dynamic rendering using a template engine. Replace variables with actual values, convert conditional expressions into logical judgments, and convert outlier tags into edge test data, thereby generating test case messages that meet the testing requirements.
[0095] Regarding multi-environment adaptation, the system can specify the computer operating system. Specifically, a script startup tool runs on the first computer operating system (e.g., a general-purpose personal computer operating system based on a graphical interface). This script is encoded in UTF-8 to support Chinese characters and avoid garbled text issues. On the second computer operating system (e.g., a domestically developed and controllable operating system based on the Linux kernel), other script startup tools can run. This script uses Linux Shell syntax to call the Java runtime environment and sets environment variables and encoding parameters to ensure system compatibility and stability. For version management, a version number (e.g., v1.0.1) is automatically generated each time configuration is modified. Backup files are stored in the / backup directory. Specifically, when the system detects changes to configuration files (e.g., config / db / xxx.setting, config / env.properties, etc.), it automatically generates a version number and creates a backup file. The backup file is named config_vX.XXyaml, where XXX is the version number. The version number can be automatically generated and incremented by the system to ensure traceability of configuration changes.
[0096] Regarding the automatic update mechanism, the test case import system automatically checks for version updates upon startup. If an update is available, it pulls the latest version to ensure users always have access to the latest features. Specifically, upon startup, the system accesses a remote version server via HTTP to obtain the latest version number and update package download address. If the current version is detected to be lower than the latest version, the system automatically downloads the update package, decompresses it, and overwrites the old version files. After the update is complete, the user is prompted to restart the tool to apply the new version. For log optimization, only the last 100 lines of log output are retained to reduce redundant information and facilitate troubleshooting. Specifically, the system records the operation time, module name, operation content, and result status each time a log is written, and only the most recent 100 lines are retained in the log file, with any excess lines automatically truncated to ensure a manageable log file size. Users can also view the complete log via command line or export the log file for analysis.
[0097] The test case import system directory structure includes config / (for environment configuration files), cases / (for test case configuration directories), ext-libs / (for dependent JAR packages), logs / (for system runtime logs), bak_YYYYMMDD / (for version backup files), version.ini (for recording the current system version), and gz3-testcase-20250903 / output / (for intermediate artifacts). Command-line operation examples can include adding a test case (add test1), generating a structured document (struct test1), generating a CSV tag file (csv test1), generating a test case and importing it into the test system (tiecase test1), batch importing multiple test cases (import / path / to / batchimporttemplate.xlsx), switching environments (env dev), viewing all test case directories (ls), and deleting a test case (del test1), etc.
[0098] The test case import system operation process includes: user input command line commands → command parsing module → configuration management module (load environment configuration) → document conversion module (generate structured documents) → CSV tag file generation module (generate CSV files) → test case generation module (generate test case templates) → automatic import module (import into the test system) → log management module (record logs and version backups).
[0099] This embodiment can be implemented using the Java language, run via command line, and is compatible with multiple computer operating systems. The test case import system can rely on third-party libraries. The system runtime environment is the open-source Java Development Kit (SDK). Users can download the test case import system toolkit, extract it, and run it. Upon initial launch, users can enter basic information such as department and name. The test case import system will automatically check for version updates and retrieve the latest version when available.
[0100] In summary, this embodiment provides a complete and implementable test case import system that can effectively solve problems such as low efficiency, high error rate, and complex version management in test case configuration and import in related technologies, and has advanced technology and practicality.
[0101] Example 3
[0102] This application also provides a test case import device. It should be noted that the test case import device of this application can be used to execute the test case import method provided in this application. The test case import device provided in this application is described below.
[0103] According to embodiments of this application, an apparatus for implementing the above-described test case import method is also provided, such as... Figure 4 As shown, the device includes: a first processing unit 41, a conversion unit 42, a first generation unit 43, and a second processing unit 44.
[0104] The first processing unit 41 is used to respond to command line instructions, load the environment configuration file of the environment to be tested, and parse the parameters in the environment configuration file to obtain the environment configuration parameters.
[0105] The conversion unit 42 is used to convert the unstructured interface document of the test environment into an interface document to obtain the target interface document;
[0106] The first generation unit 43 is used to generate a target tag file based on environment configuration parameters and target interface documents. The target tag file includes: the generation strategy of the test cases to be generated;
[0107] The second processing unit 44 is used to generate N test cases based on the target tag file and import the N test cases into the test system, wherein the test system includes a system for managing test cases, and N is a positive integer.
[0108] In the test case import device provided in this embodiment, the first processing unit 41, in response to command line instructions, loads the environment configuration file of the environment to be tested and parses the parameters in the environment configuration file to obtain environment configuration parameters. The conversion unit 42 converts the unstructured interface document of the environment to be tested into an interface document to obtain the target interface document. The first generation unit 43 generates a target tag file based on the environment configuration parameters and the target interface document. The target tag file includes a generation strategy for the test cases to be generated. The second processing unit 44 generates N test cases based on the target tag file and imports the N test cases into the test system. The test system includes a system for managing test cases, where N is a positive integer. This solves the technical problem of high error rates in related technologies where test cases are configured manually or using semi-automatic tools and then imported into the test system. In this embodiment, by converting the interface document and parsing the parameters, a tag file is generated. Test cases are automatically generated and imported into the test system based on the tag file, avoiding the high error rates associated with manual configuration and semi-automatic tool configuration in related technologies. This achieves the goal of automated test case generation, thereby reducing the accuracy of low-precision test case generation and import.
[0109] Optionally, in the test case import device provided in this application embodiment, the target tag file includes: field mapping relationship, logical expression, and variable substitution strategy. The field mapping relationship is used to define the correspondence between interface fields and fields in the test case. The logical expression is used to define the condition judgment logic in the test case. The variable substitution strategy is used to define the value rules of dynamic variables in the test case. The second processing unit includes: an acquisition subunit for acquiring a preset template format, wherein the preset template format includes: a test case template format that meets the requirements of the test system; and a first processing subunit for generating a template file based on the preset template format and the target tag file, and generating N test cases based on the template file, wherein the template file includes: a template for generating test cases.
[0110] Optionally, in the test case import device provided in this application embodiment, the second processing unit includes: a second processing subunit, used to upload N test cases to the target interface of the test system and receive the response result returned by the test system; a third processing subunit, used to determine that the import of N test cases into the test system has failed when the response result indicates that N test cases have not been received by the test system, and to record the information associated with the import failure; and a determining subunit, used to determine that N test cases have been successfully imported into the test system through the target interface when the response result indicates that N test cases have been received by the test system.
[0111] Optionally, in the test case import device provided in this application embodiment, the environment configuration parameters include: connection parameters associated with the environment to be tested. The test case import device further includes: a verification unit, used to verify whether the connection parameters are accurate before generating a target tag file based on the environment configuration parameters and the target interface document, and obtain a first verification result; a correction unit, used to correct the parameters in the environment configuration file if the first verification result indicates that the connection parameters are inaccurate; and an execution unit, used to execute the step of generating a target tag file based on the environment configuration parameters and the target interface document if the first verification result indicates that the connection parameters are accurate.
[0112] Optionally, in the test case import device provided in the embodiments of this application, the test case import device further includes: a third processing unit, used to generate an operation log, and when the number of lines in the operation log exceeds a preset number of lines, retaining the last M lines of the operation log in chronological order to obtain a target log, wherein the operation log includes: test case generation and import records; an acquisition unit, used to acquire the version information of the environment configuration file; and a recording unit, used to record the target log and the version information.
[0113] Optionally, in the test case import device provided in this application embodiment, the conversion unit includes: an extraction subunit, used to extract field data from an unstructured document using a first regular expression, wherein the field data includes at least one of the following: an interface identifier, request parameters of an interface in the test environment, and response fields of the interface; and a conversion subunit, used to convert the field data into a preset format to obtain a target interface document.
[0114] Optionally, in the test case import device provided in the embodiments of this application, the test case import device further includes: an extraction unit, used to extract the parameters of the command line instruction using a second regular expression before loading the environment configuration file of the environment to be tested, to obtain command parameters; a verification unit, used to perform compliance verification on the command parameters to obtain a second verification result; an execution unit, used to execute the step of loading the environment configuration file of the environment to be tested if the second verification result indicates that the command parameters are compliant; and a second generation unit, used to generate an error message if the second verification result indicates that the command parameters are non-compliant.
[0115] It should be noted that the first processing unit 41, conversion unit 42, first generation unit 43, and second processing unit 44 mentioned above correspond to steps S201 to S204 in Embodiment 1. Each unit and its corresponding step implement the same instance and application scenario, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0116] Example 4
[0117] Embodiments of this application may provide an electronic device. Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 5 As shown, the electronic device may include: one or more ( Figure 5 (Only one is shown) processor 502, memory 504, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0118] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the above-described methods. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0119] The processor can access information and applications stored in memory via a transmission device to perform the following steps: In response to command-line instructions, load the environment configuration file of the environment to be tested and parse the parameters in the environment configuration file to obtain environment configuration parameters; convert the unstructured interface document of the environment to be tested into an interface document to obtain the target interface document; based on the environment configuration parameters and the target interface document, generate a target tag file, wherein the target tag file includes: the generation strategy for the test cases to be generated; based on the target tag file, generate N test cases and import the N test cases into the test system, wherein the test system includes: a system for managing test cases, and N is a positive integer.
[0120] The processor can also access information and applications stored in memory via a transmission device to perform the following steps: The target tag file includes: field mapping relationships, logical expressions, and variable substitution strategies. The field mapping relationships define the correspondence between interface fields and fields in test cases. The logical expressions define the conditional judgment logic in the test cases. The variable substitution strategies define the value rules for dynamic variables in the test cases. Based on the target tag file, N test cases are generated, including: obtaining a preset template format, where the preset template format includes: a test case template format that meets the requirements of the test system; generating a template file based on the preset template format and the target tag file, and generating N test cases based on the template file, where the template file includes: a template used to generate the test cases.
[0121] The processor can also access information and applications stored in the memory via the transmission device to perform the following steps: importing N test cases into the test system, including: uploading the N test cases to the target interface of the test system and receiving the response result returned by the test system; if the response result indicates that the N test cases have not been received by the test system, determining that the import of the N test cases into the test system has failed, and recording the information associated with the import failure; if the response result indicates that the N test cases have been received by the test system, determining that the N test cases have been successfully imported into the test system through the target interface.
[0122] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: The environment configuration parameters include: connection parameters associated with the environment to be tested. Before generating the target tag file based on the environment configuration parameters and the target interface document, the following steps are also included: verifying whether the connection parameters are accurate and obtaining a first verification result; if the first verification result indicates that the connection parameters are inaccurate, correcting the parameters in the environment configuration file; if the first verification result indicates that the connection parameters are accurate, performing the step of generating the target tag file based on the environment configuration parameters and the target interface document.
[0123] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: The test case import method also includes: generating an operation log, and if the number of lines in the operation log exceeds the preset number of lines, retaining the last M lines of the operation log in chronological order to obtain the target log, wherein the operation log includes: test case generation and import records; obtaining the version information of the environment configuration file; and recording the target log and version information.
[0124] The processor can also invoke information and applications stored in the memory via the transmission device to perform the following steps: converting the unstructured interface document of the test environment into an interface document to obtain the target interface document, including: extracting field data from the unstructured document using a first regular expression, wherein the field data includes at least one of the following: interface identifier, request parameters of the interface in the test environment, and response fields of the interface; converting the field data into a preset format to obtain the target interface document.
[0125] The processor can also access information and applications stored in memory via a transmission device to perform the following steps: before loading the environment configuration file of the environment to be tested, the steps include: extracting parameters of command-line instructions using a second regular expression to obtain command parameters; performing compliance verification on the command parameters to obtain a second verification result; if the second verification result indicates that the command parameters are compliant, executing the step of loading the environment configuration file of the environment to be tested; if the second verification result indicates that the command parameters are non-compliant, generating an error message.
[0126] By adopting the embodiments of this application, a tag file is generated through interface document conversion and parameter parsing. Test cases are automatically generated and imported into the test system based on the tag file. This avoids the high error rate of manual configuration and semi-automatic tool configuration of test cases and import into the test system in related technologies, and achieves the goal of automating the generation of test cases. This achieves the technical effect of reducing the accuracy of low test case generation and import.
[0127] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, handheld computers, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 5 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.
[0128] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0129] Example 5
[0130] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the test case import method provided in Embodiment 1.
[0131] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0132] This application also provides a computer program product that, when executed on a data processing device, is suitable for performing test case import method steps.
[0133] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0134] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0135] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0136] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0137] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0138] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0139] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for importing test cases, characterized in that, include: In response to command line instructions, the environment configuration file of the environment to be tested is loaded, and the parameters in the environment configuration file are parsed to obtain the environment configuration parameters; The unstructured interface document of the environment to be tested is converted into an interface document to obtain the target interface document; Based on the environment configuration parameters and the target interface document, a target tag file is generated, wherein the target tag file includes: the generation strategy of the test cases to be generated; Based on the target tag file, N test cases are generated and imported into the test system, wherein the test system includes a system for managing test cases, and N is a positive integer.
2. The test case import method according to claim 1, characterized in that, The target tag file includes: field mapping relationships, logical expressions, and variable substitution strategies. The field mapping relationships define the correspondence between interface fields and fields in the test cases. The logical expressions define the conditional judgment logic in the test cases. The variable substitution strategies define the value rules for dynamic variables in the test cases. Based on the target tag file, N test cases are generated, including: Obtain a preset template format, wherein the preset template format includes: a test case template format that conforms to the requirements of the test system; Based on the preset template format and the target tag file, a template file is generated, and N test cases are generated based on the template file. The template file includes a template for generating the test cases.
3. The test case import method according to claim 1, characterized in that, Import N test cases into the testing system, including: Upload N test cases to the target interface of the test system and receive the response results returned by the test system; If the response result indicates that N test cases were not received by the test system, it is determined that the import of N test cases into the test system failed, and the information associated with the import failure is recorded; If the response indicates that N test cases have been received by the test system, it is determined that N test cases have been successfully imported into the test system through the target interface.
4. The test case import method according to claim 1, characterized in that, The environment configuration parameters include: connection parameters associated with the environment under test. Before generating the target tag file based on the environment configuration parameters and the target interface document, the parameters also include: Verify the accuracy of the connection parameters to obtain the first verification result; If the first verification result indicates that the connection parameters are inaccurate, the parameters in the environment configuration file shall be corrected. If the first verification result indicates that the connection parameters are accurate, the step of generating a target tag file based on the environment configuration parameters and the target interface document is performed.
5. The test case import method according to claim 1, characterized in that, The method further includes: An operation log is generated. If the number of lines in the operation log exceeds a preset number, the last M lines of the operation log are retained in chronological order to obtain the target log. The operation log includes the generation and import records of the test cases. Obtain the version information of the environment configuration file; The target log and the version information are recorded.
6. The test case import method according to claim 1, characterized in that, The unstructured interface document of the environment to be tested is converted into an interface document to obtain the target interface document, including: The first regular expression is used to extract field data from the unstructured document, wherein the field data includes at least one of the following: interface identifier, request parameters of the interface in the test environment, and response fields of the interface; The field data is converted into a preset format to obtain the target interface document.
7. The test case import method according to claim 1, characterized in that, Before loading the environment configuration file for the environment to be tested, the following are also included: The parameters of the command line instruction are extracted using a second regular expression to obtain the command parameters; The command parameters are subjected to compliance verification to obtain a second verification result; If the second verification result indicates that the command parameters are compliant, the step of loading the environment configuration file of the environment to be tested is executed. If the second verification result indicates that the command parameters are non-compliant, an error message is generated.
8. A test case import system, characterized in that, The test case import system is used to execute the test case import method according to any one of claims 1 to 7, including: The command parsing module is used to receive command line instructions and parse the command line instructions; The configuration management module is used to load the environment configuration file of the environment to be tested and parse the parameters in the environment configuration file to obtain the environment configuration parameters; The document conversion module is used to convert the unstructured interface document of the test environment into an interface document to obtain the target interface document; The tag file generation module is used to generate a target tag file based on the environment configuration parameters and the target interface document, wherein the target tag file includes: a generation strategy for generating test cases to be generated; The test case generation module is used to generate N test cases based on the target tag file, where N is a positive integer; An import module is used to import N test cases into a test system, wherein the test system includes a system for managing test cases.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the test case import method according to any one of claims 1 to 7.
10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the test case import method according to any one of claims 1 to 7.
