Test data preservation method and device, equipment and storage medium
By acquiring and orchestrating preservation configuration information and components, a preservation workflow is generated, which solves the problem of the lack of universality in data preservation logic in interface automation testing, and achieves more efficient test data updates and lower development costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA MERCHANTS BANK
- Filing Date
- 2026-06-24
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, the data preservation logic for automated interface testing lacks universality, resulting in high development costs and low testing efficiency, especially in complex and ever-changing business scenarios where it is difficult to make flexible adjustments.
By obtaining the preservation configuration information of the target test case, the target preservation operation sequence is determined, and multiple target preservation components are selected and arranged from the preset component library to generate a preservation workflow, update the initial test data, and generate post-preservation test data.
It improves the versatility of data preservation logic, reduces development costs, and enhances the efficiency of automated interface testing.
Smart Images

Figure CN122489441A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of interface automation testing technology, and in particular to a method, apparatus, device, and storage medium for preserving test data. Background Technology
[0002] In the field of API automation testing, test data is typically divided into reusable static data and dynamic data that becomes invalid after each execution. For test scenarios that rely on dynamic data, the data must be prepared again before each automated test execution; this process is known as "data preservation." In existing solutions, the common approach to addressing the dynamic data preservation needs of different business scenarios is to develop a dedicated data preservation script or component for each test case.
[0003] However, the aforementioned technical solutions have significant drawbacks. First, the data preservation process is highly rigid, typically adaptable only to a few core test cases. When faced with complex and ever-changing business scenarios (such as those involving different state transitions, date dependencies, and uniqueness constraints), the existing data preservation process struggles to flexibly adapt to meet diverse data preparation needs. Second, the data preservation scripts lack universality. Even if different test cases involve similar data preservation operations (e.g., calling the same API, updating database fields, or generating data in a specific format), similar logic needs to be repeatedly developed, resulting in extremely low reusability of the data preservation components. Finally, due to the inability to flexibly combine existing data preservation operations, the development and maintenance costs of data preservation increase linearly with a large number of test cases, severely limiting the large-scale application of automated testing and consequently reducing the overall efficiency of API automated testing.
[0004] Therefore, there is an urgent need for a test data preservation method that can improve the universality of data preservation logic, thereby reducing the development cost of data preservation and improving the efficiency of interface automated testing. Summary of the Invention
[0005] The main objective of this invention is to provide a test data preservation method, apparatus, device, and storage medium, aiming to solve the technical problems of poor universality of data preservation logic in the prior art, resulting in high development costs for data preservation and low efficiency of interface automated testing.
[0006] To achieve the above objectives, the present invention provides a method for preserving test data, the method comprising the following steps: Obtain the preservation configuration information corresponding to the target test case, wherein the preservation configuration information includes a data attribute identifier and a preservation rule associated with the data attribute identifier; Based on the preservation configuration information, determine the target preservation operation sequence corresponding to the target test case; Based on the target preservation operation sequence, multiple target preservation components are selected from the preset component library, and the multiple target preservation components are arranged to obtain a preservation workflow; The preservation workflow is executed to update the data corresponding to the data attribute identifier in the initial test data and generate the post-preservation test data.
[0007] Optionally, the step of obtaining the preservation configuration information corresponding to the target test case includes: Obtain the interface business logic information of the target test case; Based on the interface business logic information, target data attributes are identified from the initial test data, and corresponding data attribute identifiers are configured for the target data attributes. Based on the data attribute identifier, configure a preservation rule corresponding to the target data attribute. The preservation rule includes a preservation strategy field and a preservation strategy value. Based on the data attribute identifier and the preservation rules, generate the preservation configuration information corresponding to the target test case.
[0008] Optionally, the step of configuring the preservation rule corresponding to the target data attribute based on the data attribute identifier includes: Based on the data attribute identifier, determine the data type of the target data attribute; Based on the data type, a corresponding preservation strategy field is determined, and a corresponding preservation strategy value is configured for the preservation strategy field. The preservation strategy value is used to indicate the data update target. Based on the preservation strategy field and the preservation strategy value, a preservation rule associated with the data attribute identifier is generated.
[0009] Optionally, the step of determining the target preservation operation sequence corresponding to the target test case based on the preservation configuration information includes: Based on the preservation rules in the preservation configuration information, determine the type of preservation operation required for the target data attribute; Based on the preservation operation type, a preservation segment sequence is configured for the target test case, the preservation segment sequence being used to indicate the calling order of the preservation components; The preservation fragment sequence is used as the target preservation operation sequence corresponding to the target test case.
[0010] Optionally, the step of selecting multiple target preservation components from a preset component library according to the target preservation operation sequence, and arranging the multiple target preservation components to obtain a preservation workflow includes: According to the preservation operation type of each step in the target preservation operation sequence, the corresponding target preservation component is matched from the preset component library respectively; Verify whether the data interface definitions between two adjacent target preservation components match; If a match is found, the multiple matched target preservation components are sequentially connected in the order indicated by the target preservation operation sequence to generate a preservation workflow with sequential execution logic.
[0011] Optionally, before the step of obtaining the preservation configuration information corresponding to the target test case, the method further includes: Construct a test data pool, which includes test case identifiers, data characteristics, interface information, and data attribute fields; The initial test data is entered into the test data pool according to a standardized format; Establish a data maintenance mechanism to perform CRUD operations on the initial test data in the test data pool.
[0012] Optionally, after executing the preservation workflow and updating the data corresponding to the data attribute identifier in the initial test data to generate the post-preservation test data, the method further includes: The validity of the post-preservation test data is verified to determine whether the post-preservation test data meets the expected requirements of the preservation rules in the preservation configuration information; If the conditions are met, the data preservation is confirmed to be successful, and the execution of the interface automated test corresponding to the target test case is triggered. If the conditions are not met, the data preservation is confirmed to have failed, and the test data after preservation is rolled back to the original state before the execution of the preservation workflow, based on the data snapshot before the execution of the preservation workflow.
[0013] Furthermore, to achieve the above objectives, the present invention also proposes a test data preservation device, the device comprising: The information acquisition module is used to acquire the preservation configuration information corresponding to the target test case. The preservation configuration information includes a data attribute identifier and a preservation rule associated with the data attribute identifier. The sequence determination module is used to determine the target preservation operation sequence corresponding to the target test case based on the preservation configuration information. The filtering and arrangement module is used to filter out multiple target preservation components from a preset component library according to the target preservation operation sequence, and arrange the multiple target preservation components to obtain a preservation workflow. The data update module is used to execute the preservation workflow, update the data corresponding to the data attribute identifier in the initial test data, and generate the post-preservation test data.
[0014] Furthermore, to achieve the above objectives, the present invention also proposes a test data preservation device, the device comprising: a memory, a processor, and a test data preservation program stored in the memory and executable on the processor, the test data preservation program being configured to implement the steps of the test data preservation method described above.
[0015] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a test data preservation program, wherein the test data preservation program, when executed by a processor, implements the steps of the test data preservation method described above.
[0016] This invention discloses a method for obtaining preservation configuration information corresponding to a target test case. The preservation configuration information includes a data attribute identifier and preservation rules associated with the data attribute identifier. Based on the preservation configuration information, a target preservation operation sequence corresponding to the target test case is determined. According to the target preservation operation sequence, multiple target preservation components are selected from a preset component library and arranged to obtain a preservation workflow. The preservation workflow is executed to update the data corresponding to the data attribute identifier in the initial test data, generating preserved test data. Because this invention determines the target preservation operation sequence corresponding to the target test case based on the preservation configuration information, and then arranges multiple target preservation components according to the target preservation operation sequence to obtain a preservation workflow, compared to existing technologies, this invention improves the universality of data preservation logic, thereby reducing the development cost of data preservation and improving the efficiency of automated interface testing. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the first embodiment of the test data preservation method of the present invention; Figure 2 This is a flowchart illustrating the second embodiment of the test data preservation method of the present invention; Figure 3 This is a flowchart illustrating the third embodiment of the test data preservation method of the present invention; Figure 4 This is a structural block diagram of the first embodiment of the test data preservation device of the present invention; Figure 5 This is a schematic diagram of the structure of a test data preservation device for the hardware operating environment involved in the embodiments of the present invention.
[0018] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0019] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0020] This invention provides a method for preserving test data, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the test data preservation method of the present invention.
[0021] In this embodiment, the test data preservation method includes steps S10 to S40: Step S10: Obtain the preservation configuration information corresponding to the target test case. The preservation configuration information includes a data attribute identifier and a preservation rule associated with the data attribute identifier.
[0022] It should be noted that the executing entity in this embodiment can be a computer server device with data processing, network communication, and program execution functions applied in data preservation scenarios, such as a server, tablet computer, or personal computer, or an electronic device capable of performing the above functions (such as a test data preservation device). The following uses a system including a test data preservation device (hereinafter referred to as the system) as an example to illustrate this embodiment and the following embodiments.
[0023] Understandably, the target test case mentioned above can refer to a specific test scenario or test case that requires interface automation testing, such as "user registration interface test" or "order creation interface test".
[0024] It should be explained that the aforementioned preservation configuration information can be a set of predefined data description information used to indicate which data attributes in the test data should be updated and in what way. The aforementioned data attribute identifiers can be tags used to uniquely identify a specific data field in the test data, such as the identifier "reg_time" for the "registration time" field, or the identifier "sms_code_status" for the "verification code status" field. The aforementioned preservation rules can be one or more logical definitions of how the data corresponding to the data attribute identifiers should be dynamically updated, such as specifying that a certain date field needs to be updated to "the current system date plus 1 day," or specifying that a certain status field needs to be updated to "valid." Preservation rules typically include specific update strategy fields and strategy values, for example, a strategy field type of "date offset" with a strategy value of "+1 day."
[0025] In its implementation, to enable effective dynamic updates to the initial test data, the system first needs to obtain the preservation configuration information corresponding to the target test case to be executed. Specifically, based on the case identifier or case name of the target test case, the system reads the corresponding configuration record from a pre-built configuration storage area (such as a database table or configuration file). This preservation configuration information must include data attribute identifiers and preservation rules associated with those identifiers. For example, for the target test case "User Registration Interface Test," the preservation configuration information read by the system includes: a data attribute identifier of "reg_date" with the associated preservation rule "Set to the current system date"; and a data attribute identifier of "verification_code" with the associated preservation rule "Randomly generate a 6-digit number." After obtaining this preservation configuration information, the system temporarily stores it in memory for use in subsequent steps.
[0026] To achieve centralized and standardized management of test data and improve data management efficiency and flexibility, before the step of obtaining the preservation configuration information corresponding to the target test case, the following steps may be included: constructing a test data pool, which includes test case identifiers, data characteristics, interface information, and data attribute fields; entering initial test data into the test data pool according to a standardized format; and establishing a data maintenance mechanism to perform CRUD operations on the initial test data in the test data pool.
[0027] It should be understood that by constructing a test data pool containing test case identifiers, data characteristics, interface information, and data attribute fields, and entering initial test data in a standardized format, centralized and standardized management of test data is achieved. Combined with the CRUD maintenance mechanism, the efficiency and flexibility of data management are improved, providing a unified and reliable data foundation for subsequent differentiated data preservation configurations.
[0028] Understandably, the aforementioned test data pool can be a logical or physical storage area used for centralized storage and management of data required for automated interface testing, such as one or more tables in a database. The aforementioned test case identifier can be a code or name used to uniquely identify each test case, such as "TC_LOGIN_001" or "User Login Test". The aforementioned data characteristics can be used to describe the business type or data attribute category to which the test data belongs, such as "User Basic Information", "Order Data", or "Product Inventory". The aforementioned interface information can include the interface name, interface address, or interface parameter definition associated with the test data, such as "POST / api / user / login". The aforementioned data attribute fields can refer to the names of specific data columns or data items in the test data, such as "user_name", "password", or "phone_number". Unlike the data attribute identifier (which focuses on the identifier), the data attribute fields focus on the field name itself.
[0029] It should be understood that the aforementioned standardized format may refer to organizing the initial test data into a standardized form that can be entered into the test data pool according to a uniform field order, data type, and encoding rules, such as using JSON format or a fixed table column order.
[0030] It should be explained that the aforementioned data maintenance mechanism can be a set of methods or processes for managing data in the test data pool, including supporting logic for operations such as adding, deleting, modifying, and querying data.
[0031] Furthermore, the aforementioned CRUD operations refer to adding new test data records, deleting existing test data records, modifying the content of existing test data records, and querying specific data records in the test data pool, respectively.
[0032] In its implementation, before executing the specific test data preservation process, the system first needs to establish a data management platform to store the initial test data. Specifically, the system designs and creates the structure of a test data pool, which includes at least the following fields: test case identifier, data features, interface information, and data attribute fields. For example, the system creates a table named "test_data_pool" in the database, with columns such as "case_id," "data_feature," "api_info," and "data_field." Next, the system inputs the pre-prepared initial test data into the test data pool according to a standardized format. The system reads each data record from the initial test data source, organizes the test case identifier, data features, interface information, and data attribute fields of each data record into a database record according to a unified format, and inserts it into the test data pool table. Finally, the system establishes a data maintenance mechanism. The system provides interfaces for adding, deleting, modifying, and querying initial test data in the test data pool. For example, through a management interface or API, users or upper-level callers can add test data, delete specified test data records, modify field values of existing records, and query data in the data pool based on conditions. This data maintenance mechanism ensures that subsequent data preservation processes can reliably read initial test data from the test data pool and maintain and update the data in the pool as needed.
[0033] Step S20: Based on the preservation configuration information, determine the target preservation operation sequence corresponding to the target test case.
[0034] It should be explained that the above-mentioned target preservation operation sequence can refer to an ordered list of multiple preservation operations that need to be performed for the target test case, arranged in chronological order.
[0035] It should be noted that the aforementioned preservation operations can be specific actions that update test data, such as "calling an interface to obtain a verification code," "generating a random value," and "updating a field in the database." Each operation in the target preservation operation sequence typically corresponds to a preservation component that will be subsequently called from the component library, and the order of the sequence determines the execution order of the preservation workflow. For example, a target preservation operation sequence could be ["obtain dynamic token," "update order status," "generate timestamp"], meaning that the operation of obtaining the dynamic token is executed first, followed by the operation of updating the order status, and finally the operation of generating the timestamp.
[0036] In its implementation, after obtaining the preservation configuration information of the target test case, the system determines the target preservation operation sequence corresponding to the target test case based on the content of the preservation configuration information in order to obtain a series of executable operation steps. Specifically, the system reads the preservation rules and data attribute identifiers contained in the preservation configuration information. Based on the data update logic described by each preservation rule, the system analyzes which types of preservation operations need to be executed sequentially to implement the update logic. For example, if a preservation rule requires "first calling the verification code generation interface to obtain the verification code, and then writing the verification code into the database," the system will break it down into two operations: "calling the verification code generation interface" and "updating the database." The system arranges the preservation operations derived from all preservation rules for the target test case into an ordered sequence according to their logical dependencies. The system stores the arranged sequence as the target preservation operation sequence in memory for later use when selecting preservation components from the component library.
[0037] To improve the automation level and scenario adaptability of the preservation process, the step of determining the target preservation operation sequence corresponding to the target test case based on the preservation configuration information may include: determining the preservation operation type required for the target data attribute according to the preservation rules in the preservation configuration information; configuring a preservation segment sequence for the target test case based on the preservation operation type, wherein the preservation segment sequence is used to indicate the calling order of the preservation components; and using the preservation segment sequence as the target preservation operation sequence corresponding to the target test case.
[0038] It should be understood that by mapping preservation rules to preservation operation types and configuring preservation segment sequences, the automatic conversion of preservation strategies into executable steps is achieved. This enables different test cases to customize differentiated preservation processes as needed, improving the flexibility and scenario adaptability of preservation operations, and avoiding the need to develop separate preservation scripts for each case.
[0039] It should be noted that the aforementioned preservation operation types can refer to specific operation categories performed when preserving test data, such as database update operations, API call operations, data generation operations, or data calculation operations. Each preservation operation type corresponds to a category of preservation actions with the same functional characteristics. For example, database update operation types include "updating the field value of a record in a database table," API call operation types include "calling an external API to obtain dynamic data," data generation operation types include "randomly generating a string that conforms to a specific format," and data calculation operation types include "performing addition and subtraction operations on numeric fields."
[0040] Understandably, the above-mentioned preservation fragment sequence can be a collection of multiple preservation fragments listed in sequence. Each preservation fragment corresponds to a specific preservation operation step, and the preservation fragment sequence is used to indicate the order in which preservation components are called from the component library. Each fragment in the preservation fragment sequence can be understood as an instantiation description of a certain preservation operation type. For example, the preservation fragment sequence can be represented as ["Call the SMS interface to obtain the verification code", "Write the verification code to the database", "Generate the current timestamp"]. The order of these three fragments indicates the order in which the preservation components are called.
[0041] In its implementation, after obtaining the preservation rules from the preservation configuration information, the system needs to determine the type of preservation operation required for each target data attribute. Specifically, the system parses the policy fields and policy values contained in the preservation rules, and determines the required preservation operation type based on the type of the policy field. For example, if the policy field in the preservation rule is "date offset," the required preservation operation type is determined to be "data calculation operation"; if the policy field is "call external interface to obtain data," the required preservation operation type is determined to be "interface call operation." The system records the required preservation operation type for each target data attribute. Next, based on the above preservation operation types, the system configures a corresponding preservation segment sequence for the target test case. The system transforms multiple preservation operation types into a sequentially arranged preservation segment sequence based on the logical dependencies between the various data attributes in the target test case and the necessity of the preservation operations. Each entry in the preservation segment sequence clearly indicates the type and order of the preservation components that need to be called subsequently. For example, if a test case requires first calling an API to obtain a verification code and then updating the database with that verification code, the configured preservation segment sequence would be ["Verification code API call segment", "Database status update segment"]. Finally, the system stores the configured preservation segment sequence as the target preservation operation sequence corresponding to the target test case in the system's memory or cache for use in subsequent preservation workflow orchestration.
[0042] Step S30: Based on the target preservation operation sequence, select multiple target preservation components from the preset component library, and arrange the multiple target preservation components to obtain a preservation workflow.
[0043] It should be noted that the aforementioned pre-built component library can be a collection of pre-built components that encapsulate various reusable modules for implementing data preservation operations, such as database update components, API call components, data generation components, and data calculation components. Each component has a standard input and output data format definition to facilitate data transfer and combination between different components.
[0044] It is understandable that the aforementioned target preservation component can be a specific component instance selected from a preset component library that matches each preservation operation type in the target preservation operation sequence. For example, if the target preservation operation sequence includes the operation of "calling the SMS interface", then the target preservation component selected from the preset component library is the "SMS interface call component".
[0045] It should be understood that the above orchestration can refer to the process of organizing and connecting multiple target preservation components in a certain logical order, including determining the execution order and data transmission relationships between components. The above preservation workflow can be an executable workflow formed by orchestrating multiple target preservation components in a specific order. This workflow can be sequentially called and executed by the system to complete the complete preservation processing of test data.
[0046] In its implementation, after obtaining the target preservation operation sequence, the system needs to select and combine specific components from a pre-defined component library based on the sequence. Specifically, the system reads each preservation operation type or preservation segment identifier listed in the target preservation operation sequence. The system iterates through all registered preservation components in the pre-defined component library, matching the functional description or component tag of each component with the operation type in the target preservation operation sequence. For each operation in the sequence, the system selects a matching target preservation component from the pre-defined component library. For example, if the target preservation operation sequence contains a "database update operation," the system selects the "database update component" as the target preservation component. Once all operations have matched corresponding target preservation components, the system obtains multiple target preservation components. Next, the system arranges these selected target preservation components. Following the order indicated by the target preservation operation sequence, the system arranges the multiple target preservation components sequentially, configuring the output data of the previous component as the input data of the next component (if data dependencies exist). The system described above organizes the orchestrated sequence of components into a complete preservation workflow. This workflow includes the sequential logic for component execution and the definition of data transfer between components. Finally, the system stores the orchestrated preservation workflow in memory, awaiting subsequent execution.
[0047] To facilitate understanding, the following explanation uses examples, but does not impose specific limitations on this embodiment. For example, assume the target preservation operation sequence is ["Call SMS interface", "Generate random verification code", "Update database"]. The system accesses a preset component library, which includes an "SMS platform call component", a "random string generation component", and a "database field update component". Based on the first operation in the sequence, "Call SMS interface", the system selects the "SMS platform call component" as the first target preservation component; based on the second operation, "Generate random verification code", it selects the "random string generation component" as the second target preservation component; and based on the third operation, "Update database", it selects the "database field update component" as the third target preservation component. Subsequently, the system orchestrates the three components into a preservation workflow in sequence: first, the "SMS platform call component" is executed, and its returned session identifier is passed to the "random string generation component" as a context parameter for generating the verification code; then, the "database field update component" is executed to write the generated verification code into a specified field. After orchestration, the system obtains a preservation workflow containing three sequentially executed components.
[0048] To improve the reusability, flexibility, and execution reliability of the preservation process, the step of selecting multiple target preservation components from a preset component library based on the target preservation operation sequence and arranging the multiple target preservation components to obtain a preservation workflow may include: matching corresponding target preservation components from the preset component library according to the preservation operation type of each step in the target preservation operation sequence; verifying whether the data interface definitions between two adjacent target preservation components match; if they match, sequentially connecting the multiple matched target preservation components according to the calling order indicated by the target preservation operation sequence to generate a preservation workflow with sequential execution logic.
[0049] It should be understood that by using component matching and interface verification mechanisms, the automatic screening and reliable orchestration of preservation components can be achieved, ensuring the compatibility of data interfaces of adjacent components, avoiding execution errors caused by runtime interface mismatches, dynamically assembling and generating executable preservation workflows, and improving the reusability, flexibility and execution reliability of the preservation process.
[0050] It should be explained that the aforementioned data interface definition can refer to the standardized description of the input parameter format and output result format exposed by each preservation component. For example, the input parameter type is a JSON object containing a "phone" field, and the output result is a JSON object containing a "code" field. Data interface definition matching means that the output data format of the previous component and the input data format of the subsequent component are consistent in data type, field name, and data structure, or are compatible and convertible.
[0051] It is understandable that the above-mentioned chaining refers to connecting multiple preservation components in a specified order, so that the execution result of the previous component can be passed as the input parameter of the next component. The above-mentioned sequential execution logic means that the preservation workflow will strictly execute each preservation component in the order of its arrangement during runtime. Only after the previous component has finished executing and returned a result will the execution of the next component be triggered. There is no parallel or jump execution.
[0052] In its implementation, after selecting multiple target preservation components from a pre-defined component library, the system needs to verify the data interface compatibility between components and perform concatenation orchestration to ensure these components can work collaboratively and transmit data correctly. Specifically, the system matches the corresponding target preservation components from the pre-defined component library based on the preservation operation type corresponding to each step in the target preservation operation sequence. After matching, the system obtains a list of target preservation components with the same number of steps as the target preservation operation sequence and corresponding in order. Next, the system sequentially checks each pair of adjacent target preservation components in this list to verify whether the data interface definitions between the two adjacent target preservation components match. The system reads the output interface definition of the previous target preservation component and the input interface definition of the next target preservation component, determining whether the output data format of the former meets the input requirements of the latter. For example, if the previous component outputs a string-type verification code, and the next component needs to receive a string-type verification code parameter as input, then it is considered a match. If the data interface definitions between two adjacent target preservation components match, the system sequentially connects the matched target preservation components according to the calling order indicated by the target preservation operation sequence. The system establishes a data transfer mapping relationship between the preceding and following components, mapping the output fields of the preceding component to the corresponding input fields of the following component. After concatenation, the system generates a preservation workflow with sequential execution logic. The execution order of each target preservation component in this workflow is completely consistent with the target preservation operation sequence, and the data transfer relationships between components are explicitly configured.
[0053] To facilitate understanding, the following explanation uses examples, but does not impose specific limitations on this embodiment. For example, suppose the target preservation operation sequence is ["call the verification code interface", "parse the verification code", "update the database"], and the three target preservation components matched in the preset component library are as follows: Component A (verification code interface calling component, outputting a JSON object containing the "sms_code" field), Component B (JSON parsing component, requiring a JSON object as input, outputting a string-type verification code value), and Component C (database update component, requiring a string-type verification code value and table name parameter as input). The above system first verifies the data interface definition between Component A and Component B: Component A outputs a JSON object, and Component B requires a JSON object as input, which is determined to be a match. Next, it verifies the data interface definition between Component B and Component C: Component B outputs a string-type verification code, and Component C requires a string-type verification code as input, which is determined to be a match. Since all adjacent components are successfully matched, the system sequentially links components A, B, and C. The JSON object output by component A is configured to be directly used as the input of component B, and the verification code string output by component B is used as one of the input parameters of component C. Finally, a freshness-preserving workflow with sequential execution logic is generated: component A is executed first, then component B, and finally component C.
[0054] Step S40: Execute the preservation workflow to update the data corresponding to the data attribute identifier in the initial test data and generate the post-preservation test data.
[0055] It should be understood that the aforementioned initial test data can refer to the raw test data obtained from the test data pool before any preservation processing, such as a test data record containing username, registration time, and verification code fields. Initial test data is typically stored in the test data pool in a standardized format and has not yet undergone dynamic updating.
[0056] It is understandable that the aforementioned post-preservation test data can refer to test data generated after the preservation workflow has been completed, and whose relevant data attributes have been updated according to the preservation rules. In the post-preservation test data, the field values corresponding to the data attribute identifiers have been replaced with new values that meet the expected requirements, such as updating the registration time from a fixed date to the current system date, and updating the verification code status from unverified to verified.
[0057] In its implementation, after orchestrating and generating the preservation workflow, the system needs to actually execute the workflow to update the test data. Specifically, the system obtains initial test data, which is raw data records read from the test data pool based on the test case identifier of the target test case. The system uses the initial test data as input parameters for the preservation workflow and initiates its execution. The system executes the logic in the pre-arranged order of the preservation workflow, sequentially calling each target preservation component in the workflow. During component execution, the system identifies fields in the initial test data that correspond to data attribute identifiers in the preservation configuration information and updates the values of these fields according to the internal logic of each component. For example, a data generation component updates the "verification code" field in the initial test data from null to a randomly generated six-digit number, and a database update component updates the "account status" field from "inactive" to "activated." After the system has executed all target preservation components in sequence, all data attributes in the initial test data that need to be preserved have been updated according to the preservation rules. The system will output the updated data as the post-preservation test data and store the post-preservation test data in memory or temporary storage area, waiting for subsequent automated interface testing.
[0058] This embodiment discloses a method for obtaining preservation configuration information corresponding to a target test case. The preservation configuration information includes a data attribute identifier and preservation rules associated with the data attribute identifier. Based on the preservation configuration information, a target preservation operation sequence corresponding to the target test case is determined. According to the target preservation operation sequence, multiple target preservation components are selected from a preset component library and arranged to obtain a preservation workflow. The preservation workflow is executed to update the data corresponding to the data attribute identifier in the initial test data, generating preserved test data. Because this embodiment determines the target preservation operation sequence corresponding to the target test case based on the preservation configuration information and then arranges multiple target preservation components according to the target preservation operation sequence to obtain a preservation workflow, compared to existing technologies, this embodiment improves the universality of data preservation logic, thereby reducing the development cost of data preservation and improving the efficiency of automated interface testing.
[0059] refer to Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the test data preservation method of the present invention.
[0060] Based on the first embodiment described above, in this embodiment, step S10 includes steps S101 to S104: Step S101: Obtain the interface business logic information of the target test case.
[0061] Step S102: Based on the interface business logic information, identify the target data attributes from the initial test data and configure the corresponding data attribute identifier for the target data attributes.
[0062] Step S103: Based on the data attribute identifier, configure the preservation rule corresponding to the target data attribute. The preservation rule includes a preservation strategy field and a preservation strategy value.
[0063] Step S104: Generate preservation configuration information corresponding to the target test case based on the data attribute identifier and the preservation rule.
[0064] It should be explained that the aforementioned interface business logic information can refer to data describing the processing flow and rules that the interface corresponding to the target test case needs to complete at the business level, such as the interface's input parameter definition, output result definition, business state transition conditions, data dependencies, etc. Interface business logic information can include business descriptions such as "this interface needs to verify user identity," "this interface will generate a unique order number," and "this interface needs to verify whether the verification code is correct."
[0065] It is understandable that the aforementioned target data attributes can refer to specific data fields identified from the initial test data that need to be dynamically updated during the preservation process, such as "registration time," "verification code status," "order amount," and "user level." Target data attributes are the objects of the preservation operation, distinct from data attribute identifiers (identifiers are unique markers corresponding to target data attributes).
[0066] It should be noted that the aforementioned preservation strategy fields can refer to fields used to define the type of preservation rule. For example, the strategy field can be "Date Strategy," "Numerical Strategy," "Status Strategy," and "Invocation Strategy," with each preservation strategy field representing a type of preservation operation. The aforementioned preservation strategy values can refer to the specific numerical values or parameters configured for the preservation strategy fields, used to indicate the target of data updates. For example, the strategy value corresponding to the date strategy field can be "+1 day" and "-3 hours," etc.; the strategy value corresponding to the numeric strategy field can be "random range 1-100" and "greater than 1000," etc.; and the strategy value corresponding to the status strategy field can be "unregistered" and "activated," etc.
[0067] In its implementation, the system first acquires the interface business logic information of the target test case when obtaining the preservation configuration information. Specifically, the system reads the interface business logic information associated with the target test case from the test case configuration file, interface document, or database table, including the interface's input / output definitions, business processing rules, and data dependencies. Next, based on this interface business logic information, the system identifies the target data attributes that need to be preserved from the initial test data. The system analyzes which data fields in the interface business logic information need to meet dynamic conditions before the interface call. For example, if the interface requires "verification code must be generated in real time," "timestamp must be the current time," and "order status must be unpaid before cancellation can be performed," then the system identifies "verification code," "timestamp," and "order status" as target data attributes. After identifying the target data attributes, the system configures a corresponding data attribute identifier for each target data attribute. For example, it configures the identifier "sms_code" for the target data attribute "verification code" and "current_timestamp" for the target data attribute "timestamp." Subsequently, based on the configured data attribute identifiers, the system configures corresponding preservation rules for each target data attribute. The aforementioned preservation rules include a preservation strategy field and a preservation strategy value. The system determines the preservation strategy field based on the data type and business requirements of the target data attribute. For example, for date-type data attributes, the preservation strategy field is set to "Date Strategy"; for numeric-type data attributes, the preservation strategy field is set to "Number Strategy". The system configures the corresponding preservation strategy value for the preservation strategy field according to the specific requirements of the preservation rules. For example, the strategy value for the date strategy field is set to "equal to the system date plus 1 day", and the strategy value for the numeric strategy field is set to "randomly generate an integer between 1 and 100". Finally, the system associates and binds the data attribute identifier and the configured preservation rules to generate the preservation configuration information corresponding to the target test case. This preservation configuration information includes all data attribute identifiers that need to be preserved under this test case and the preservation rules corresponding to each identifier, stored in a structured data format (such as JSON or database record rows).
[0068] It should be added that the step of configuring the preservation rule corresponding to the target data attribute based on the data attribute identifier may include: determining the data type of the target data attribute according to the data attribute identifier; determining the corresponding preservation strategy field based on the data type, and configuring a corresponding preservation strategy value for the preservation strategy field, wherein the preservation strategy value is used to indicate the data update target; and generating a preservation rule associated with the data attribute identifier according to the preservation strategy field and the preservation strategy value.
[0069] It should be understood that by differentiating preservation strategy fields and strategy values by data type, different data attributes can adopt appropriate update rules, thereby achieving refined classification and management of preservation strategies, improving the matching accuracy between preservation rules and data characteristics, and enhancing the versatility and scenario adaptability of data preservation solutions.
[0070] It should be noted that the data types mentioned above can refer to the category or format of the data values corresponding to the target data attribute, such as integer, string, date / time, boolean, and floating-point types. The data type determines the acceptable range of values for the data attribute and the types of data preservation operations that can be applied. For example, date / time data attributes can use date offset or timestamp generation operations, while integer data attributes can use random number generation or value range validation operations.
[0071] It should be explained that the aforementioned data update target can refer to the specific state or value that the data attribute is expected to be updated to through the preservation rules. For example, updating it to "the current system date," updating it to "a random integer greater than 100," or updating it to the "activated" state. The data update target is the core meaning expression of the preservation strategy value, and the specific form of the preservation strategy value depends on how the data update target is described.
[0072] In its implementation, when configuring preservation rules corresponding to target data attributes, the system first determines the data type of the target data attribute based on the pre-configured data attribute identifier. Specifically, the system reads the field type definition corresponding to the data attribute identifier from the table structure definition of the test data pool or from the data dictionary. For example, it reads that the data type of the "reg_time" field is "date and time type," the data type of the "order_amount" field is "decimal type," and the data type of the "user_status" field is "string type." After determining the data type, the system determines the corresponding preservation strategy field based on that data type. The system matches suitable preservation strategy field types for different data types according to a pre-established strategy mapping relationship. For example, for date and time type data attributes, the preservation strategy field is determined to be "date strategy"; for numeric type data attributes, the preservation strategy field is determined to be "numeric strategy" or "random number strategy"; for string type data attributes with a limited number of values, the preservation strategy field is determined to be "enumeration strategy" or "status strategy." After determining the preservation strategy field, the system configures a corresponding preservation strategy value for it. This value indicates the data update target. The system assigns specific strategy values to the preservation strategy field based on business needs and test scenario requirements. For example, a date strategy field configured with a value of "equal to system date plus 2 days" indicates that the data update target is to update the value of the target data attribute to two days after the current system date; a numeric strategy field configured with a value of "random range 50-200" indicates that the data update target is to update the value of the target data attribute to a random integer between 50 and 200. After configuration, the system generates preservation rules associated with data attribute identifiers based on the preservation strategy field and its value. The system combines the preservation strategy field and value according to a preset data structure (e.g., key-value pairs or structured strings) to form a complete preservation rule record and establishes an association between the preservation rule and the corresponding data attribute identifier.
[0073] This embodiment discloses the interface business logic information for obtaining target test cases; based on the interface business logic information, target data attributes are identified from initial test data, and corresponding data attribute identifiers are configured for the target data attributes; based on the data attribute identifiers, preservation rules corresponding to the target data attributes are configured, the preservation rules including preservation strategy fields and preservation strategy values; and preservation configuration information corresponding to the target test cases is generated according to the data attribute identifiers and the preservation rules. This embodiment automatically identifies target data attributes that need to be preserved through interface business logic information, and configures data attribute identifiers and preservation rules containing strategy fields and strategy values for them, realizing the precise definition and structured configuration of preservation strategies, enabling preservation operations to be executed on demand for specific data attributes, and improving the targeting and automation of preservation processing.
[0074] refer to Figure 3 , Figure 3 This is a flowchart illustrating the third embodiment of the test data preservation method of the present invention.
[0075] Based on the above embodiments, in this embodiment, after step S40, steps S50 to S70 are further included: Step S50: Verify the validity of the post-preservation test data to determine whether the post-preservation test data meets the expected requirements of the preservation rules in the preservation configuration information.
[0076] Step S60: If the condition is met, the data preservation is confirmed to be successful, and the execution of the interface automated test corresponding to the target test case is triggered.
[0077] Step S70: If the condition is not met, the data preservation is confirmed to have failed, and the test data after preservation is rolled back to the original state before the execution of the preservation workflow based on the data snapshot before the execution of the preservation workflow.
[0078] It should be noted that the aforementioned validity verification refers to the process of checking and validating the content of the post-preservation test data to determine whether the data has achieved the expected update effect. Validation verification typically includes field value type verification, numerical range verification, format compliance verification, or business logic verification.
[0079] It is understandable that the above-mentioned expected requirements may refer to the data update targets defined by the preservation rules in the preservation configuration information, such as "the verification code field should be updated to a 6-digit number", "the order status field should be updated to paid", and "the timestamp field should be updated to within the allowable error range before and after the current system time".
[0080] It should be understood that "successful data preservation" can refer to the state where the test data meets all expected requirements after preservation, indicating that the data preservation process is complete and the result meets expectations. "Triggered execution" can refer to the system actively initiating or calling the automated testing process for the interface corresponding to the target test case after confirming successful data preservation. "Automated interface testing" can refer to the testing process of sending requests and verifying responses automatically for the interface associated with the target test case, such as using a testing framework to send a POST request to the " / api / user / login" interface and verify the returned result.
[0081] Accordingly, the aforementioned data preservation failure can refer to a state where the test data after preservation does not meet the expected requirements in the preservation rules, indicating that the data preservation process has failed to achieve the expected results. The aforementioned data snapshot can refer to a complete backup of the initial test data before the preservation workflow is executed, such as copying all field values of the initial test data and storing them in a temporary storage area. The aforementioned rollback can refer to the operation process of restoring changed data to a previously known state; specifically, in this step, it means restoring the test data after preservation to its original state before the preservation workflow is executed. The aforementioned original state can refer to the state of the initial test data before the preservation workflow begins execution, a state that has not undergone any preservation updates.
[0082] In its implementation, after generating the post-preservation test data, the system performs validity checks on the data to ensure the correctness and reliability of the preservation results. Specifically, the system reads the expected requirements contained in the preservation rules defined in the preservation configuration information, such as a rule requiring that "the value of the order amount field must be greater than 0." The system compares the field values corresponding to the data attribute identifiers in the post-preservation test data with these expected requirements one by one. The system checks whether each updated data attribute fully meets the expected requirements defined by the corresponding preservation rule. If the current values of all data attributes meet the expected requirements of the preservation rules in the preservation configuration information, the system confirms that the data preservation is successful. After successful confirmation, the system automatically triggers the execution of the interface automated test corresponding to the target test case, such as calling the test execution engine to start the automated test script for the target test case. If the current value of any data attribute does not meet the corresponding expected requirements, the system confirms that the data preservation has failed. After confirming the data preservation failure, the system obtains a snapshot of the data saved before the preservation workflow was executed. Based on the original field values recorded in the data snapshot, the system restores all changed fields in the current post-preservation test data to their corresponding original values from the data snapshot. After the system completes the rollback operation, the test data is restored to its original state before the preservation workflow was executed.
[0083] This embodiment discloses a method for validating the test data after preservation, determining whether the data meets the expected requirements of the preservation rules in the preservation configuration information. If it does, the data preservation is confirmed as successful, and the execution of the interface automated test corresponding to the target test case is triggered. If it does not meet the requirements, the data preservation is confirmed as failed, and the test data is rolled back to its original state before the preservation workflow execution, based on the data snapshot before the workflow execution. This embodiment ensures that the data update results meet the expected requirements by validating the test data after preservation, achieving a reliable connection between preservation and automated testing. Furthermore, by rolling back to the original state based on the data snapshot when preservation fails, it avoids abnormal data contaminating the test environment, improving the reliability and fault tolerance of test data processing.
[0084] Furthermore, embodiments of the present invention also propose a storage medium storing a test data preservation program, wherein the test data preservation program, when executed by a processor, implements the steps of the test data preservation method described above.
[0085] Reference Figure 4 , Figure 4 This is a structural block diagram of the first embodiment of the test data preservation device of the present invention.
[0086] like Figure 4 As shown, the test data preservation device proposed in this embodiment of the invention includes: an information acquisition module 501, a sequence determination module 502, a screening and arrangement module 503, and a data update module 504.
[0087] The information acquisition module 501 is used to acquire the preservation configuration information corresponding to the target test case. The preservation configuration information includes a data attribute identifier and a preservation rule associated with the data attribute identifier.
[0088] The sequence determination module 502 is used to determine the target preservation operation sequence corresponding to the target test case based on the preservation configuration information.
[0089] The filtering and arrangement module 503 is used to filter out multiple target preservation components from a preset component library according to the target preservation operation sequence, and arrange the multiple target preservation components to obtain a preservation workflow.
[0090] The data update module 504 is used to execute the preservation workflow, update the data corresponding to the data attribute identifier in the initial test data, and generate the post-preservation test data.
[0091] The information acquisition module 501 is also used to construct a test data pool, which includes test case identifiers, data features, interface information, and data attribute fields; input initial test data into the test data pool according to a standardized format; and establish a data maintenance mechanism to perform add, delete, modify, and query operations on the initial test data in the test data pool.
[0092] The sequence determination module 502 is further configured to determine the type of preservation operation required for the target data attribute according to the preservation rules in the preservation configuration information; configure a preservation fragment sequence for the target test case based on the preservation operation type, wherein the preservation fragment sequence is used to indicate the calling order of the preservation components; and use the preservation fragment sequence as the target preservation operation sequence corresponding to the target test case.
[0093] The filtering and orchestration module 503 is further configured to match corresponding target preservation components from a preset component library according to the preservation operation type of each step in the target preservation operation sequence; verify whether the data interface definitions between two adjacent target preservation components match; if they match, sequentially connect the matched target preservation components in the order indicated by the target preservation operation sequence to generate a preservation workflow with sequential execution logic.
[0094] This device embodiment discloses a method for obtaining preservation configuration information corresponding to a target test case. The preservation configuration information includes a data attribute identifier and preservation rules associated with the data attribute identifier. Based on the preservation configuration information, a target preservation operation sequence corresponding to the target test case is determined. According to the target preservation operation sequence, multiple target preservation components are selected from a preset component library and arranged to obtain a preservation workflow. The preservation workflow is executed to update the data corresponding to the data attribute identifier in the initial test data, generating preserved test data. Because this device embodiment determines the target preservation operation sequence corresponding to the target test case based on the preservation configuration information, and then arranges multiple target preservation components according to the target preservation operation sequence to obtain a preservation workflow, compared to existing technologies, this device embodiment improves the versatility of data preservation logic, thereby reducing the development cost of data preservation and improving the efficiency of automated interface testing.
[0095] Based on the first embodiment of the test data preservation device of the present invention, a second embodiment of the test data preservation device of the present invention is proposed.
[0096] In this embodiment, the information acquisition module 501 is further configured to acquire interface business logic information of the target test case; based on the interface business logic information, identify target data attributes from the initial test data, and configure corresponding data attribute identifiers for the target data attributes; based on the data attribute identifiers, configure preservation rules corresponding to the target data attributes, the preservation rules including preservation strategy fields and preservation strategy values; and generate preservation configuration information corresponding to the target test case according to the data attribute identifiers and the preservation rules.
[0097] The information acquisition module 501 is further configured to determine the data type of the target data attribute based on the data attribute identifier; determine the corresponding preservation strategy field based on the data type, and configure a corresponding preservation strategy value for the preservation strategy field, wherein the preservation strategy value is used to indicate the data update target; and generate a preservation rule associated with the data attribute identifier based on the preservation strategy field and the preservation strategy value.
[0098] Other embodiments or specific implementations of the test data preservation device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0099] This application provides a test data preservation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the test data preservation method in Embodiment 1 above.
[0100] The following is for reference. Figure 5 The diagram illustrates a structural schematic of a test data preservation device suitable for implementing embodiments of this application. The test data preservation device in this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The test data preservation device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0101] like Figure 5As shown, the test data preservation device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the test data preservation device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the test data preservation device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show test data preservation devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0102] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0103] The test data preservation device provided in this application, employing the test data preservation method described in the above embodiments, can solve the technical problems of poor universality of data preservation logic in the prior art, leading to high development costs for data preservation and low efficiency of interface automated testing. Compared with the prior art, the beneficial effects of the test data preservation device provided in this application are the same as those of the test data preservation method provided in the above embodiments, and other technical features of this test data preservation device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0104] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0105] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0106] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0107] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0108] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0109] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A method for preserving test data, characterized in that, The method includes: Obtain the preservation configuration information corresponding to the target test case, wherein the preservation configuration information includes a data attribute identifier and a preservation rule associated with the data attribute identifier; Based on the preservation configuration information, determine the target preservation operation sequence corresponding to the target test case; Based on the target preservation operation sequence, multiple target preservation components are selected from the preset component library, and the multiple target preservation components are arranged to obtain a preservation workflow; The preservation workflow is executed to update the data corresponding to the data attribute identifier in the initial test data and generate the post-preservation test data.
2. The test data preservation method as described in claim 1, characterized in that, The step of obtaining the preservation configuration information corresponding to the target test case includes: Obtain the interface business logic information of the target test case; Based on the interface business logic information, target data attributes are identified from the initial test data, and corresponding data attribute identifiers are configured for the target data attributes. Based on the data attribute identifier, configure a preservation rule corresponding to the target data attribute. The preservation rule includes a preservation strategy field and a preservation strategy value. Based on the data attribute identifier and the preservation rules, generate the preservation configuration information corresponding to the target test case.
3. The test data preservation method as described in claim 2, characterized in that, The step of configuring the preservation rule corresponding to the target data attribute based on the data attribute identifier includes: Based on the data attribute identifier, determine the data type of the target data attribute; Based on the data type, a corresponding preservation strategy field is determined, and a corresponding preservation strategy value is configured for the preservation strategy field. The preservation strategy value is used to indicate the data update target. Based on the preservation strategy field and the preservation strategy value, a preservation rule associated with the data attribute identifier is generated.
4. The test data preservation method as described in claim 1, characterized in that, The step of determining the target preservation operation sequence corresponding to the target test case based on the preservation configuration information includes: Based on the preservation rules in the preservation configuration information, determine the type of preservation operation required for the target data attribute; Based on the preservation operation type, a preservation segment sequence is configured for the target test case, the preservation segment sequence being used to indicate the calling order of the preservation components; The preservation fragment sequence is used as the target preservation operation sequence corresponding to the target test case.
5. The test data preservation method as described in claim 4, characterized in that, The step of selecting multiple target preservation components from a preset component library based on the target preservation operation sequence, and arranging the multiple target preservation components to obtain a preservation workflow includes: According to the preservation operation type of each step in the target preservation operation sequence, the corresponding target preservation component is matched from the preset component library respectively; Verify whether the data interface definitions between two adjacent target preservation components match; If a match is found, the multiple matched target preservation components are sequentially connected in the order indicated by the target preservation operation sequence to generate a preservation workflow with sequential execution logic.
6. The test data preservation method as described in claim 1, characterized in that, Before the step of obtaining the preservation configuration information corresponding to the target test case, the method further includes: Construct a test data pool, which includes test case identifiers, data characteristics, interface information, and data attribute fields; The initial test data is entered into the test data pool according to a standardized format; Establish a data maintenance mechanism to perform CRUD operations on the initial test data in the test data pool.
7. The test data preservation method as described in claim 1, characterized in that, After the step of executing the preservation workflow, updating the data corresponding to the data attribute identifier in the initial test data, and generating the post-preservation test data, the method further includes: The validity of the post-preservation test data is verified to determine whether the post-preservation test data meets the expected requirements of the preservation rules in the preservation configuration information; If the conditions are met, the data preservation is confirmed to be successful, and the execution of the interface automated test corresponding to the target test case is triggered. If the conditions are not met, the data preservation is confirmed to have failed, and the test data after preservation is rolled back to the original state before the execution of the preservation workflow, based on the data snapshot before the execution of the preservation workflow.
8. A test data preservation device, characterized in that, The device includes: The information acquisition module is used to acquire the preservation configuration information corresponding to the target test case. The preservation configuration information includes a data attribute identifier and a preservation rule associated with the data attribute identifier. The sequence determination module is used to determine the target preservation operation sequence corresponding to the target test case based on the preservation configuration information. The filtering and arrangement module is used to filter out multiple target preservation components from a preset component library according to the target preservation operation sequence, and arrange the multiple target preservation components to obtain a preservation workflow. The data update module is used to execute the preservation workflow, update the data corresponding to the data attribute identifier in the initial test data, and generate the post-preservation test data.
9. A test data preservation device, characterized in that, The device includes: a memory, a processor, and a test data preservation program stored in the memory and executable on the processor, the test data preservation program being configured to implement the steps of the test data preservation method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores a test data preservation program, which, when executed by a processor, implements the steps of the test data preservation method as described in any one of claims 1 to 7.