An interface test case self-healing method, device and equipment
Patent Information
- Application Number
- CN202611247894.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-10-30
AI Technical Summary
然而,在软件系统的迭代过程中,接口定义、测试数据状态或测试环境配置等测试信息可能发生变化,而已有的接口测试用例难以及时适配测试信息的变化,容易导致接口测试用例执行失败,影响接口测试效率
本申请实施例提供的接口测试用例的自愈方法,通过获取接口测试用例对应的接口定义维度、测试数据状态维度和测试环境配置维度的多维测试信息,对所述多维测试信息进行差异检测,可以确定接口定义、测试数据状态和测试环境配置中的至少一个维度是否存在差异。在存在差异的情况下,根据相应的差异信息生成并执行对应的自愈任务,从而对接口测试用例、测试数据状态或测试环境配置进行相应处理,使接口测试用例能够适应相关测试信息的变化,减少因测试信息变化与接口测试用例不匹配而导致的接口测试失败,保障了接口测试效率。
Smart Images

Figure CN123011581A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing technology, and in particular to a self-healing method, apparatus and device for interface test cases. Background Technology
[0002] As the business scale of software systems continues to expand, the number of interfaces contained within these systems gradually increases. To improve the efficiency of interface testing, interface testing can now be automated by executing test cases.
[0003] Currently, interface test cases can be generated based on test information such as interface definition, test data status, and test environment configuration, and the corresponding interfaces can be tested based on this information. However, during the iteration of a software system, test information such as interface definition, test data status, or test environment configuration may change. Existing interface test cases may struggle to adapt to these changes in a timely manner, easily leading to test case execution failures and impacting interface testing efficiency.
[0004] Therefore, there is an urgent need for a solution to address the aforementioned technical problems. Summary of the Invention
[0005] Based on the above problems, this application provides a self-healing method, apparatus and device for interface test cases, with the aim of ensuring interface testing efficiency.
[0006] The embodiments of this application disclose the following technical solutions: Firstly, embodiments of this application provide a self-healing method for interface test cases, including: Obtain the interface test cases to be processed and the multi-dimensional test information corresponding to the interface test cases; the multi-dimensional test information includes the first test information of the interface definition dimension, the second test information of the test data status dimension, and the third test information of the test environment configuration dimension; Difference detection is performed on the first test information, the second test information, and the third test information to obtain multi-dimensional difference information; the multi-dimensional difference information includes first difference information representing interface definition differences, second difference information representing test data state differences, and third difference information representing test environment configuration differences; When the multidimensional difference information indicates that there is a difference, a corresponding self-healing task is generated based on the difference information indicating the difference. The self-healing task includes at least one of the following: interface test case update task, data state recovery task, and environment configuration synchronization task. Execute the self-healing task to obtain the self-healing processing result corresponding to the self-healing task.
[0007] In one possible implementation, performing the self-healing task includes: Determine the task priority of each of the generated self-healing tasks; the task priorities of the interface test case update task, the data state recovery task, and the environment configuration synchronization task decrease in that order. If at least two self-healing tasks are generated, the at least two self-healing tasks are executed sequentially according to the task priority.
[0008] In one possible implementation, the first test information includes historical interface definition information and current interface definition information; obtaining the first test information includes: Retrieve the first code version information recorded in the API knowledge base and the second code version information corresponding to the current API source code; If the first code version information and the second code version information are inconsistent, obtain the historical interface definition information and the current interface definition information; Obtaining the first difference information includes: By comparing the historical interface definition information with the current interface definition information, at least one interface change is determined from the following: field addition, field deletion, parameter type change, enumeration value change, and field required attribute change. The first difference information is generated based on the interface changes; The self-healing task includes the interface test case update task. Executing the self-healing task and obtaining the self-healing processing result corresponding to the self-healing task includes: Based on the first difference information, determine the interface test cases affected by the interface change; Based on the type of interface change, at least one of the test fields, field values, parameter types, and type conversion logic in the affected interface test cases is updated to obtain the updated interface test cases. The updated interface test cases are then determined as the self-healing processing result corresponding to the interface test case update task.
[0009] In one possible implementation, updating at least one of the test fields, field values, parameter types, and type conversion logic in the affected interface test cases according to the type of interface change to obtain updated interface test cases includes: If the first difference information indicates that a field has been added, the corresponding field is added to the test data of the affected interface test cases, and the value of the added field is set to a preset default value or a recommended value recorded in the interface knowledge base. If the first difference information indicates that a field has been deleted, the corresponding field is deleted from the test data of the affected interface test case; If the first difference information indicates a change in parameter type, update the parameter type or type conversion logic in the affected interface test case according to the changed parameter type; If the first difference information indicates that there is a change in the enumeration value, update or supplement the enumeration type test data in the affected interface test cases according to the changed enumeration value; If the first difference information indicates a change in the required field attribute, the test data of the corresponding field and the interface test cases associated with the field are updated according to the changed required field attribute.
[0010] In one possible implementation, the second test information includes expected test data status information and actual test data status information; obtaining the second test information includes: Determine the expected test data status based on the preconditions of the interface test cases; Before executing the interface test cases, query the actual test data status; Obtaining the second difference information includes: By comparing the expected test data state with the actual test data state, the second difference information is obtained; The self-healing task includes the data state recovery task; executing the self-healing task and obtaining the self-healing processing result corresponding to the self-healing task includes: Based on the second difference information, a data status update statement is generated and executed to obtain the self-healing processing result corresponding to the data status recovery task.
[0011] In one possible implementation, the third test information includes test environment configuration information corresponding to at least three test environments; obtaining the third test information includes: In response to a test environment switch or environment configuration change, read the environment configuration files corresponding to multiple test environments; Obtaining the third difference information includes: Compare the configuration values of corresponding configuration items in different test environments; The configuration value differences are divided into normal differences to be retained and abnormal differences to be synchronized, thus obtaining the third difference information; The self-healing task includes the environment configuration synchronization task; executing the self-healing task and obtaining the self-healing processing result corresponding to the self-healing task includes: Based on the third difference information, the configuration value corresponding to the abnormal difference is synchronized to the target test environment; The aforementioned normal differences are retained.
[0012] In one possible implementation, the method further includes: Before executing the interface test case update task or the environment configuration synchronization task, or if the data state recovery task fails, output the corresponding self-healing strategy selection information and set the corresponding processing flow to a waiting state. Receive user selection instructions, determine processing strategies and processing scope based on the user selection instructions, and execute corresponding processing operations.
[0013] In one possible implementation, obtaining the self-healing processing result corresponding to the self-healing task includes: The execution results of the self-healing task are verified; If the verification is successful, at least one self-healing result is obtained, including the updated interface test cases, the restored test data status, and the synchronized test environment configuration information. If the verification fails, output the abnormal information and processing strategy selection information corresponding to the self-healing task.
[0014] Second aspect: This application provides a self-healing device for interface test cases, including: Acquisition unit, detection unit, generation unit, and execution unit; The acquisition unit is used to acquire the interface test cases to be processed and the multi-dimensional test information corresponding to the interface test cases; the multi-dimensional test information includes first test information of the interface definition dimension, second test information of the test data status dimension, and third test information of the test environment configuration dimension. The detection unit is used to perform difference detection on the first test information, the second test information, and the third test information to obtain multi-dimensional difference information; the multi-dimensional difference information includes first difference information representing interface definition differences, second difference information representing test data state differences, and third difference information representing test environment configuration differences. The generation unit is used to generate a corresponding self-healing task based on the multidimensional difference information indicating the existence of differences when the multidimensional difference information indicates the existence of differences. The self-healing task includes at least one of the following: interface test case update task, data state recovery task, and environment configuration synchronization task. The execution unit is used to execute the self-healing task and obtain the self-healing processing result corresponding to the self-healing task.
[0015] Third aspect: This application provides a computer device, which includes a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the steps of the method described above according to the instructions in the program code.
[0016] Fourth aspect: Embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method described above.
[0017] Fifth aspect: This application provides a computer program product, which, when run on a computer, enables the computer to perform the steps of the method described above.
[0018] Sixth aspect: This application provides a chip including a processor coupled to a memory for executing a computer program or instructions stored in the memory, such that the chip implements the steps of the method described above.
[0019] Compared with the prior art, this application has the following advantages: The self-healing method for interface test cases provided in this application obtains multi-dimensional test information corresponding to the interface test cases, including interface definition, test data status, and test environment configuration. By performing difference detection on this multi-dimensional test information, it can determine whether at least one dimension of the interface definition, test data status, and test environment configuration exists. If a difference exists, a corresponding self-healing task is generated and executed based on the difference information. This process adjusts the interface test cases, test data status, or test environment configuration accordingly, enabling the interface test cases to adapt to changes in relevant test information. This reduces interface test failures caused by mismatches between test information and interface test cases, thus ensuring interface testing efficiency. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A schematic diagram illustrating an application scenario of a self-healing method for interface test cases provided in an embodiment of this application; Figure 2 A flowchart illustrating a self-healing method for interface test cases provided in an embodiment of this application; Figure 3 A flowchart for performing a self-healing task is provided as an embodiment of this application; Figure 4 A flowchart illustrating a self-healing method for an interface definition dimension provided in an embodiment of this application; Figure 5A flowchart illustrating a self-healing method for the state dimension of test data provided in this application embodiment; Figure 6 A flowchart illustrating a self-healing method for a test environment configuration dimension provided in an embodiment of this application; Figure 7 A flowchart illustrating a self-healing task interaction control method provided in this application embodiment; Figure 8 This is a schematic diagram of the structure of a self-healing device for an interface test case provided in an embodiment of this application. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. The terminology used in the following embodiments is for the purpose of describing specific embodiments only and is not intended to limit the application. For example, references to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized. "Multiple" in the embodiments of this application refers to two or more.
[0023] It should be noted that in the description of the embodiments of this application, the terms "first" and "second" are used only for the purpose of distinguishing descriptions and should not be construed as indicating or implying relative importance, nor should they be construed as indicating or implying order.
[0024] Currently, interface test cases can be generated based on test information such as interface definition, test data status, and test environment configuration, and the corresponding interfaces can be tested based on this information. However, during the iteration of a software system, test information such as interface definition, test data status, or test environment configuration may change. Existing interface test cases may struggle to adapt to these changes in a timely manner, easily leading to test case execution failures and impacting interface testing efficiency.
[0025] For example, if new fields are added, deleted, or parameter types are adjusted after the interface test cases are generated, and the existing test cases are not updated synchronously, the test cases may fail to execute. If the pre-test data is modified by other test processes, making the actual data state inconsistent with the expected state, it may also cause the pre-test to fail. Configuration differences between different test environments may cause test cases to execute abnormally across environments.
[0026] Currently, the above-mentioned problems usually require manual modification of test cases, data restoration, or configuration synchronization, which is not only time-consuming but also prone to omissions, making it difficult to guarantee the efficiency of interface testing.
[0027] Based on this, the self-healing method for interface test cases provided in this application obtains multi-dimensional test information corresponding to the interface test cases, including the interface definition dimension, test data state dimension, and test environment configuration dimension. By performing difference detection on this multi-dimensional test information, it can determine whether there are differences in at least one dimension among the interface definition, test data state, and test environment configuration. If differences exist, a corresponding self-healing task is generated and executed based on the relevant difference information. This process adjusts the interface test cases, test data state, or test environment configuration accordingly, enabling the interface test cases to adapt to changes in relevant test information. This reduces interface test failures caused by mismatches between test information and interface test cases, thus ensuring interface testing efficiency.
[0028] like Figure 1 As shown in the figure, this is a schematic diagram of an application scenario for a self-healing method for interface test cases provided in an embodiment of this application. This method can be executed by terminal device 110, server 120, or jointly executed by terminal device 110 and server 120. The following description uses the joint execution of the method by terminal device 110 and server 120 as an example.
[0029] Terminal device 110 can send interface test cases to be processed and related information to the server 120. Server 120 obtains multi-dimensional test information corresponding to the interface test cases, including first test information in the interface definition dimension, second test information in the test data status dimension, and third test information in the test environment configuration dimension.
[0030] Based on this, server 120 performs difference detection on the first test information, the second test information, and the third test information to obtain multi-dimensional difference information. The multi-dimensional difference information includes first difference information representing interface definition differences, second difference information representing test data state differences, and third difference information representing test environment configuration differences. When the multi-dimensional difference information indicates the existence of differences, a corresponding self-healing task is generated according to the difference information indicating the existence of differences. The self-healing task includes at least one of interface test case update task, data state recovery task, and environment configuration synchronization task. The self-healing task is executed to obtain the self-healing processing result corresponding to the self-healing task.
[0031] Server 120 can send the self-healing processing result to terminal device 110 so that terminal device 110 can output the self-healing processing result.
[0032] It is understood that both terminal device 110 and server 120 can serve as computer devices for executing the methods described in the embodiments of this application. Terminal device 110 and server 120 can execute the methods independently or collaboratively through a communication connection; the embodiments of this application do not specifically limit this.
[0033] The following describes a self-healing method for interface test cases provided in an embodiment of this application, with reference to the accompanying drawings.
[0034] like Figure 2 As shown, this figure is a flowchart of a self-healing method for interface test cases provided in an embodiment of this application, including S201-S204.
[0035] S201. Obtain the interface test cases to be processed and the multi-dimensional test information corresponding to the interface test cases.
[0036] The multidimensional test information includes first test information in the interface definition dimension, second test information in the test data status dimension, and third test information in the test environment configuration dimension.
[0037] In this embodiment of the application, the interface test case to be processed can be an interface test case that has been generated and is ready to be executed, or it can be an interface test case that needs to be re-examined after changes in code version, test data or test environment.
[0038] Based on the interface identifier, test case identifier, or test project identifier, the interface knowledge base, test data, and test environment configuration associated with the interface test case can be determined.
[0039] The first test information may include, but is not limited to, historical interface definition information stored in the interface knowledge base and current interface definition information in the target code version; the second test information may include, but is not limited to, expected test data status information required by the interface test cases and actual test data status information in the test database; the third test information may include, but is not limited to, test environment configuration information corresponding to multiple test environments such as system integration test environment, user acceptance test environment and iteration test environment.
[0040] S202. Perform difference detection on the first test information, the second test information and the third test information to obtain multi-dimensional difference information.
[0041] In this embodiment of the application, multidimensional difference information can be used to indicate at least one of the following: the test information dimension in which the difference exists, the object of the difference, the content of the difference, the status of the difference, the scope of influence, and the suggested handling method.
[0042] For example, the multidimensional difference information includes first difference information representing differences in interface definition, second difference information representing differences in test data state, and third difference information representing differences in test environment configuration.
[0043] Regarding the interface definition dimension, the first difference can be obtained by comparing historical interface definition information with current interface definition information. Regarding the test data status dimension, the second difference can be obtained by comparing expected test data status information with actual test data status information. Regarding the test environment configuration dimension, the third difference can be obtained by comparing the configuration values of the same configuration items in different test environments.
[0044] S203. When multidimensional difference information indicates that there is a difference, generate a corresponding self-healing task based on the difference information indicating the difference.
[0045] The self-healing task may include, but is not limited to, at least one of the following: interface test case update task, data state recovery task, and environment configuration synchronization task.
[0046] For example, when the first difference information indicates that there is a difference in interface definition, an interface test case update task can be generated; when the second difference information indicates that there is a difference in test data status, a data status recovery task can be generated; when the third difference information indicates that there is a difference in test environment configuration that needs to be synchronized, an environment configuration synchronization task can be generated.
[0047] When differences exist in multiple dimensions simultaneously, multiple self-healing tasks can be generated; when no difference is detected in a certain dimension, the difference status of that dimension can be set to no difference.
[0048] S204. Execute the self-healing task and obtain the self-healing processing result corresponding to the self-healing task.
[0049] In this embodiment of the application, the self-healing result may include, but is not limited to, at least one of the following: updated interface test cases, restored test data status, and synchronized test environment configuration information.
[0050] In one possible implementation, the execution result of the self-healing task can be verified while obtaining the self-healing result. If the verification passes, at least one of the updated interface test cases, the restored test data state, and the synchronized test environment configuration information is identified as the self-healing result; if the verification fails, the corresponding exception information and processing strategy selection information are output.
[0051] In one possible implementation, after obtaining the self-healing processing result corresponding to the self-healing task, the task type, processing object, processing quantity, start time, completion time, verification result and exception information of the self-healing task can also be recorded for subsequent query and auditing.
[0052] In summary, this application's embodiments acquire multi-dimensional test information—including interface definition, test data status, and test environment configuration—corresponding to interface test cases. By performing difference detection on this multi-dimensional test information, it can determine whether at least one dimension of the interface definition, test data status, and test environment configuration exists. If a difference exists, a corresponding self-healing task is generated and executed based on the difference information. This process adjusts the interface test cases, test data status, or test environment configuration accordingly, enabling the interface test cases to adapt to changes in relevant test information. This reduces interface test failures caused by mismatches between test information and interface test cases, thus ensuring interface testing efficiency.
[0053] To avoid the disordered execution of multiple self-healing tasks, reduce the mutual influence between different self-healing tasks, and improve the orderliness and execution efficiency of multiple self-healing tasks, the embodiments of this application can determine the execution order of each self-healing task during the execution of the self-healing task in the above-described S204, and execute the self-healing task based on the execution order. For example... Figure 3 As shown in the figure, this is a flowchart of a self-healing task provided by an embodiment of this application, including S301 to S302.
[0054] S301. Determine the task priority corresponding to each of the generated self-healing tasks.
[0055] In this embodiment of the application, when multidimensional difference information indicates that there are differences in at least two test dimensions, at least two self-healing tasks can be generated based on the difference information indicating the differences.
[0056] For example, when both the first and second difference information indicate a difference, an interface test case update task and a data state recovery task can be generated; when differences exist in all three dimensions, an interface test case update task, a data state recovery task, and an environment configuration synchronization task can be generated.
[0057] It should be noted that the specific method for generating the self-healing task in this step can be referred to in S203 above, and will not be repeated here.
[0058] In one possible implementation, the corresponding task priority can be determined based on the task type of the self-healing task.
[0059] In this embodiment of the application, differences in interface definition may cause the fields, parameter types, or field values of the interface test cases to be mismatched with the current interface definition, thereby affecting the normal execution of the interface test cases. Therefore, the interface test case update task can be set as the first priority.
[0060] Differences in test data status often affect the preconditions for executing interface test cases. Therefore, the data status recovery task can be set as the second priority so that it is executed after the interface test cases are adapted to the current interface definition.
[0061] The differences in test environment configuration may include inherent differences in the environment that need to be retained, and some environment configuration differences may not necessarily affect the execution of the current interface test cases. Therefore, the environment configuration synchronization task can be set as the third priority.
[0062] Among them, the interface test case update task has the first priority, which is higher than the data status recovery task, which has the second priority, and the second priority is higher than the environment configuration synchronization task, which has the third priority.
[0063] In one possible implementation, the first priority can be a blocking priority, the second priority can be a forced execution priority, and the third priority can be a suggested execution priority.
[0064] It is understandable that the priority order of self-healing tasks corresponding to each task type can be preset or adjusted based on actual needs; the above is just an example.
[0065] S302. Execute the at least two self-healing tasks in sequence according to task priority.
[0066] When at least two self-healing tasks are generated, the at least two self-healing tasks can be executed sequentially from high to low according to the task priority corresponding to each self-healing task.
[0067] For example, when generating interface test case update tasks, data state recovery tasks, and environment configuration synchronization tasks simultaneously, the interface test case update task can be executed first, followed by the data state recovery task, and finally the environment configuration synchronization task.
[0068] If the interface test case update task has not been completed or the execution result has not been verified, the execution of the data state recovery task and the environment configuration synchronization task can be paused to avoid performing subsequent processing based on interface test cases that have not yet been adapted to the current interface definition.
[0069] If the data state recovery task has not been completed or the execution result has not been verified, the execution of interface test cases that depend on the corresponding test data state can be paused, and the environment configuration synchronization task can also be paused. The environment configuration synchronization task can be executed after the first priority task and the second priority task have been completed.
[0070] In one possible implementation, an environment configuration synchronization suggestion can also be output, and the decision on whether to execute the environment configuration synchronization task can be made based on the received user selection instruction.
[0071] After each self-healing task is completed, the corresponding self-healing results can be obtained. The specific execution methods and result verification methods for the self-healing tasks can be found in the following sections.
[0072] In summary, by setting different task priorities based on the task type of the self-healing task and executing multiple self-healing tasks sequentially according to the task priority, the differences in interface definitions that have a significant impact on the execution of interface test cases can be prioritized. This avoids performing data state restoration or environment configuration synchronization before the interface test cases are adapted to the current interface definition, thereby improving the orderliness of processing multiple self-healing tasks and improving the efficiency of interface testing.
[0073] To facilitate understanding, the self-healing processes for the interface definition dimension, test data status dimension, and test environment configuration dimension will be introduced separately below.
[0074] like Figure 4 As shown, this figure is a flowchart of a self-healing processing method for the interface definition dimension provided in an embodiment of this application. This embodiment can be a possible implementation of the above-described S201 to S204 in the interface definition dimension, and the method may include steps S401 to S407.
[0075] S401. Obtain the first code version information recorded in the interface knowledge base and the second code version information corresponding to the current interface source code.
[0076] In this embodiment of the application, the interface knowledge base can be used to store the interface definition information and corresponding code version information on which the interface test cases are generated.
[0077] The first code version information can represent the code version corresponding to the interface definition information in the interface knowledge base, and the second code version information can represent the code version corresponding to the interface to be tested.
[0078] In one possible implementation, the interface knowledge base can also record code repository information and code branch information. Based on the code repository information and the code branch information, the current interface source code can be determined, and the second code version information corresponding to the current interface source code can be obtained.
[0079] S402. Compare the first code version information and the second code version information.
[0080] In this embodiment, it can be determined whether the first code version information and the second code version information are consistent. If the first code version information and the second code version information are consistent, it can be determined that the interface definition information in the interface knowledge base corresponds to the same code version as the current interface source code, and further difference detection at the interface definition dimension can be avoided.
[0081] If the first code version information and the second code version information are inconsistent, it means that the interface definition information in the interface knowledge base may differ from the interface definition information in the current interface source code, and the computer device can continue to execute S403.
[0082] It should be noted that inconsistent code version information can be used as a condition to trigger interface definition difference detection, but inconsistent code version information does not necessarily mean that the interface definition has changed.
[0083] S403. Obtain historical interface definition information and current interface definition information.
[0084] Among them, historical interface definition information and current interface definition information constitute the first test information of the interface definition dimension.
[0085] Historical interface definition information can be interface definition information stored in the interface knowledge base and used as the basis for generating interface test cases. Current interface definition information can be interface definition information obtained from the current interface source code corresponding to the second code version information.
[0086] Interface definition information may include at least one of the following: interface field name, field type, field enumeration value, required field attributes, and hierarchical relationship between fields.
[0087] In one possible implementation, a historical field list can be obtained from the interface knowledge base, and the current field list can be obtained based on the interface control information, interface parameter information, and data object information in the current interface source code.
[0088] S404. Compare the historical interface definition information with the current interface definition information to obtain the first difference information.
[0089] In this embodiment, each interface field in the historical interface definition information can be compared with each interface field in the current interface definition information to determine at least one interface change among field addition, field deletion, parameter type change, enumeration value change, and field required attribute change.
[0090] For example, if the current interface definition contains fields that are not included in the historical interface definition, the corresponding interface change can be identified as a field addition; if a field in the historical interface definition does not appear in the current interface definition, the corresponding interface change can be identified as a field deletion.
[0091] For fields that exist in both historical and current interface definition information, the field types, enumeration values, and required attributes can be further compared to determine whether there have been changes in parameter types, enumeration values, or required field attributes.
[0092] In this embodiment, first difference information can be generated based on detected interface changes. The first difference information may include at least one of the following: interface change type, fields where the interface change occurred, field attributes before the change, field attributes after the change, and the number of interface test cases affected by the interface change.
[0093] In one possible implementation, after obtaining the first difference information, a list of interface changes can also be output to show the changes to each interface and their corresponding impact.
[0094] S405. Generate an interface test case update task based on the first difference information.
[0095] In this embodiment of the application, interface test cases affected by interface changes can be determined based on the first difference information, and an interface test case update task can be generated to update the affected interface test cases. For example, based on the changed interface field, interface test cases containing or dependent on the changed interface field can be searched among the generated interface test cases to determine the affected interface test cases.
[0096] In one possible implementation, before executing the interface test case update task, the first self-healing strategy selection information can be output, and the interface test case update task can be set to a waiting state.
[0097] The first self-healing strategy selection information may include at least one of the following: updating all affected interface test cases, updating only core interface test cases, updating user-specified interface test cases, and skipping interface test case updates.
[0098] Core interface test cases can include interface test cases associated with required fields or business-critical fields.
[0099] In this embodiment of the application, a user selection instruction can be received, and the processing scope of the interface test case update task can be determined according to the user selection instruction.
[0100] S406. Update the affected interface test cases according to the type of interface change.
[0101] In this embodiment of the application, the computer device can update at least one of the test fields, field values, parameter types, and type conversion logic in the affected interface test cases according to different interface change types.
[0102] For example, if the first difference information indicates that a field has been added, the corresponding field can be added to the test data of the affected interface test cases, and the value of the added field can be set to a preset default value or a recommended value recorded in the interface knowledge base.
[0103] If the first difference information indicates that a field has been deleted, the corresponding field can be deleted from the test data of the affected interface test cases.
[0104] If the first difference information indicates a change in parameter type, the parameter type or type conversion logic in the affected interface test cases can be updated according to the changed parameter type.
[0105] If the first difference information indicates that there is a change in the enumeration value, the test data corresponding to the enumeration value in the affected interface test cases can be updated or supplemented according to the changed enumeration value.
[0106] If the first difference information indicates that there is a change in the required field attribute, the test data of the corresponding field and the interface test cases associated with that field can be updated according to the changed required field attribute.
[0107] For example, when a field changes from optional to required, the field value can be added to the relevant interface test cases; when a field changes from required to optional, the test scenarios related to that field can be updated according to testing needs.
[0108] S407. Obtain the self-healing processing result corresponding to the interface test case update task.
[0109] In one possible implementation, the updated interface test case can be directly identified as the self-healing result corresponding to the interface test case update task.
[0110] In another possible implementation, the updated interface test cases can be verified.
[0111] In this embodiment, it can be verified whether the updated interface test cases match the current interface definition information. For example, it can be verified whether the updated interface test cases contain the required fields required by the current interface definition, whether the field types are consistent with the current interface definition, and whether the enumeration values in the test data belong to the enumeration values allowed by the current interface definition.
[0112] If verification passes, the updated interface test cases can be identified as the self-healing result corresponding to the interface test case update task, and the number of updated interface test cases can be output. If verification fails, interface test case update exception information and corresponding handling strategy selection information can be output.
[0113] In summary, this application embodiment compares the code version information recorded in the interface knowledge base with the code version information corresponding to the current interface source code. When the code versions are inconsistent, it obtains and compares the historical interface definition information with the current interface definition information, which can determine the changes that have occurred in the interface fields. The affected interface test cases are then updated according to the interface changes, so that the interface test cases can adapt to the current interface definition and reduce the failure of interface tests caused by changes in the interface definition.
[0114] like Figure 5 As shown, this figure is a flowchart of a self-healing processing method for the test data state dimension provided in an embodiment of this application. This embodiment can be a possible implementation of the above-described S201 to S204 in the test data state dimension, and the method may include steps S501 to S507.
[0115] S501. Determine the expected test data status based on the preconditions of the interface test cases.
[0116] In this embodiment of the application, for interfaces that may modify the test data status, the test data status on which the interface test cases depend can be detected before executing the corresponding interface test cases.
[0117] For example, the interface may include, but is not limited to, at least one of the data modification interfaces that use POST request, PUT request, or DELETE request methods.
[0118] In this embodiment of the application, based on the preconditions of the interface test cases, the fields to be tested and the expected field values corresponding to each field to be tested can be determined, and the expected test data status information can be obtained based on the fields to be tested and the expected field values.
[0119] For example, the preconditions for interface test cases could require the target data record to be in a valid state, or require the target data record to be in a preset business state. Based on this, the data fields to be tested and their expected field values can be determined.
[0120] In one possible implementation, the fields to be detected can also be determined based on the list of fields recorded in the interface knowledge base.
[0121] S502. Before executing the interface test cases, query the actual test data status.
[0122] In this embodiment of the application, a corresponding status detection statement can be generated based on the field to be detected, and the status detection statement can be executed in the pre-processing stage of the interface test case.
[0123] Based on the execution result of the status detection statement, the actual field value corresponding to each field to be detected is obtained, and the actual test data status information is obtained based on the actual field value.
[0124] The expected test data status information and the actual test data status information constitute the second test information of the test data status dimension.
[0125] S503. Compare the expected test data status with the actual test data status to obtain the second difference information.
[0126] In this embodiment of the application, by comparing the expected field value and the actual field value of each field to be tested, if the expected field value and the actual field value of each field to be tested are consistent, it can be determined that the test data status meets the preconditions of the interface test case, and the interface test case can continue to be executed.
[0127] If the expected field value of at least one field to be detected is inconsistent with the actual field value, it can be determined that there is a difference in the test data status, and a second difference information is generated. The second difference information may include at least one of the following: the field to be detected, the expected field value, the actual field value, the difference status, and a suggested recovery method.
[0128] In one possible implementation, after obtaining the second difference information, a list of test data status differences can also be output to show the expected field value, actual field value, and difference status of each field to be detected.
[0129] S504. Generate and execute a data status update statement based on the second difference information.
[0130] In this embodiment of the application, when the second difference information indicates that there is a difference in the test data status, a data status recovery task can be generated.
[0131] Based on the field to be detected, the expected field value, and the identifier of the data record to be restored recorded in the second difference information, a data status update statement is generated and executed to restore the actual test data status to the expected test data status.
[0132] For example, when the target data record exists, but the actual field value of at least one of the fields to be detected is inconsistent with the expected field value, the corresponding field can be restored to the expected field value through a data status update statement.
[0133] S505. Re-query the test data status to determine whether the data status recovery task was executed successfully.
[0134] In this embodiment of the application, after executing the data status update statement, the status detection statement can be executed again to obtain the actual field values of each field to be detected.
[0135] The actual field values that are retrieved are compared with their corresponding expected field values. If the retrieved actual field values match the corresponding expected field values, the data state recovery task can be considered successfully executed, and the recovered test data state is determined as the self-healing result corresponding to the data state recovery task. Subsequently, the corresponding interface test cases can be generated or executed.
[0136] If the actual field value obtained again is still inconsistent with the corresponding expected field value, or if the data status update statement fails to execute normally, it can be determined that the data status recovery task has failed.
[0137] S506. If the data state recovery task fails, output the corresponding self-healing strategy selection information.
[0138] In this embodiment of the application, the reasons for the failure of the data state recovery task can be determined. The reasons for failure may include at least one of the following: the data record to be recovered does not exist, insufficient data modification permissions, field constraint conflicts, and database connection failure.
[0139] Based on the cause of failure, a second self-healing strategy selection information is generated, and the corresponding processing flow is set to a waiting state. This second self-healing strategy selection information may include at least one of the following: generating test data based on a user-provided data construction scheme, skipping test data state detection, modifying the expected test data state, and stopping the generation of corresponding interface test cases.
[0140] For example, when the data record to be recovered does not exist, the user can be prompted to provide a data construction scheme to construct test data that meets the preconditions; when the expected test data status no longer meets the current business rules, the corresponding expected test data status can be modified according to the user's selection.
[0141] S507. Execute the corresponding processing operation according to the user's selected instruction.
[0142] In this embodiment of the application, a user selection instruction input by the user regarding the selection information of the second self-healing strategy can be received, and the test data status recovery method can be determined according to the user selection instruction.
[0143] If the user chooses to provide a data construction scheme, the corresponding test data can be generated based on the user's provided data construction scheme; if the user chooses to skip the test data status check, the current test data status check can be skipped; if the user chooses to modify the expected test data status, the corresponding preconditions can be updated based on the user's input; if the user chooses to stop generating interface test cases, the generation or execution process of the corresponding interface test cases can be terminated.
[0144] In summary, the embodiments of this application, by comparing the expected test data state and the actual test data state before executing the interface test cases, can automatically generate and execute data state update statements when the two are inconsistent, and confirm the recovery result by re-querying, thereby ensuring that the test data state meets the preconditions of the interface test cases and reducing interface test failures caused by test data state mismatch.
[0145] like Figure 6 As shown, this figure is a flowchart of a self-healing processing method for the test environment configuration dimension provided in an embodiment of this application. This embodiment can be a possible implementation of the above-described S201 to S204 in the test environment configuration dimension, and the method may include steps S601 to S607.
[0146] S601: In response to a test environment switch or environment configuration change, read the environment configuration files corresponding to each of the multiple test environments.
[0147] In this embodiment of the application, the test environment may include at least three of the following: system integration test environment, user acceptance test environment, and iterative test environment.
[0148] When a user switches an interface test case from one test environment to another, or when the environment configuration of any test environment changes, a test environment configuration difference detection process can be triggered. This process reads the environment configuration file corresponding to each test environment to obtain the test environment configuration information for each environment.
[0149] The test environment configuration information corresponding to each of the multiple test environments constitutes the third test information in the test environment configuration dimension.
[0150] S602. Extract the configuration items to be compared from each of the aforementioned environment configuration files.
[0151] In this embodiment of the application, the same configuration items to be compared and their configuration values can be extracted from each environment configuration file according to a preset list of configuration items.
[0152] The configuration items to be compared may include at least one of the following: interface address, enterprise domain name, core layer domain name, tenant database configuration, and timeout period.
[0153] Different configuration items to be compared can have different configuration types. For example, interface address, environment domain name, and tenant database configuration can be configuration items related to a specific test environment, while runtime parameters such as timeout can be configuration items that need to be consistent across different test environments.
[0154] S603. Compare the configuration values of the corresponding configuration items in different test environments.
[0155] In this embodiment, the configuration values of the same configuration item in multiple test environments can be compared according to the configuration item identifier. For example, the timeout time in multiple test environments can be compared separately, or the interface address, enterprise domain name, core layer domain name, or tenant database configuration in multiple test environments can be compared separately.
[0156] For configuration items with the same configuration value, it can be determined that there is no difference in configuration value for that configuration item. For configuration items with different configuration values, S604 can be executed to determine the type of difference in configuration value.
[0157] S604. Divide the configuration value differences into normal differences to be retained and abnormal differences to be synchronized, and obtain the third difference information.
[0158] In this embodiment of the application, the configuration value difference between different test environments can be determined as a normal difference or an abnormal difference based on the configuration type corresponding to the configuration item to be compared or the preset configuration difference rule.
[0159] Normal differences can be configuration value differences that need to be retained due to differences in functionality or resources between different test environments. For example, different test environments may have different interface addresses, environment domain names, or tenant database configurations.
[0160] An anomaly can be a configuration value difference that is not consistent between different test environments, which should ideally be consistent. For example, the timeout times of multiple test environments usually need to be consistent. If the timeout time of one test environment differs from the others, this configuration value difference can be identified as an anomaly.
[0161] In this embodiment, third difference information can be obtained based on the normal and abnormal differences. The third difference information may include at least one of the following: the configuration item to be compared, the configuration value corresponding to each test environment, the difference status, and synchronization suggestion information.
[0162] In one possible implementation, after obtaining the third difference information, a configuration difference list can be output to show the user the configuration values, difference types, and corresponding synchronization suggestions for each configuration item in different test environments.
[0163] S605. Generate an environment configuration synchronization task based on the third difference information.
[0164] In this embodiment of the application, when the third difference information includes at least one abnormal difference to be synchronized, an environment configuration synchronization task can be generated.
[0165] Before executing the environment configuration synchronization task, third self-healing strategy selection information can be output, and the environment configuration synchronization task can be set to a waiting state. The third self-healing strategy selection information can include at least one of the following: synchronizing all configuration items to be synchronized, synchronizing only preset key configuration items, and skipping environment configuration synchronization.
[0166] In this embodiment of the application, a user selection instruction input by the user for the third self-healing strategy selection information can be received, and the environmental configuration synchronization range can be determined according to the user selection instruction.
[0167] S606. Based on the third difference information, synchronize the configuration values corresponding to the abnormal differences to the target test environment, and retain the normal differences.
[0168] In this embodiment of the application, a benchmark test environment and a target test environment can be determined from multiple test environments, and the configuration values corresponding to abnormal differences can be synchronized to the target test environment based on the environment configuration file of the benchmark test environment.
[0169] The benchmark testing environment can be a pre-specified testing environment or a testing environment selected by the user. For example, the system integration testing environment can be designated as the benchmark testing environment, while the user acceptance testing environment and the iteration testing environment can be designated as the target testing environments.
[0170] During synchronization, only configuration items corresponding to abnormal differences can be synchronized without modifying normal differences that need to be retained. For example, for interface addresses and environment domain names in different test environments, the original configuration values of each test environment can be retained; for timeouts that need to be kept consistent, the configuration values in the benchmark test environment can be synchronized to the target test environment. This avoids overwriting the specific configurations required by different test environments during environment configuration synchronization.
[0171] S607. Obtain the self-healing processing result corresponding to the environment configuration synchronization task.
[0172] In this embodiment of the application, after the environment configuration synchronization is completed, the synchronized test environment configuration information can be obtained.
[0173] In one possible implementation, the synchronized test environment configuration information can be directly determined as the self-healing processing result corresponding to the environment configuration synchronization task.
[0174] In another possible implementation, the execution result of the environment configuration synchronization task can be verified, and the self-healing processing result corresponding to the environment configuration synchronization task can be determined based on the verification result.
[0175] For example, the environment configuration file corresponding to the target test environment can be reread, and the synchronized configuration values can be compared with the corresponding configuration values in the benchmark test environment to verify whether the configuration items corresponding to abnormal differences have been successfully synchronized. Simultaneously, the configuration values corresponding to normal differences before and after synchronization can be compared to verify whether the normal differences have been retained.
[0176] If the configuration values corresponding to abnormal differences have been synchronized to the corresponding configuration values in the benchmark test environment, and the configuration values corresponding to normal differences remain unchanged, it can be determined that the execution result of the environment configuration synchronization task has passed verification, and the synchronized test environment configuration information is determined as the self-healing processing result corresponding to the environment configuration synchronization task. Based on this, the number of synchronized configuration items can also be output.
[0177] If the configuration value corresponding to the abnormal difference is not synchronized, or the configuration value corresponding to the normal difference changes, it can be determined that the execution result verification of the environment configuration synchronization task has failed, and the corresponding abnormal information and processing strategy selection information are output to request the user to process further.
[0178] In summary, by comparing the configuration values of corresponding configuration items in multiple test environments and dividing the differences in configuration values into normal differences to be retained and abnormal differences to be synchronized, this application embodiment can synchronize only the configuration values corresponding to abnormal differences while retaining the unique configurations required by different test environments. This reduces the possibility of interface test cases failing to execute across environments due to abnormal and inconsistent test environment configurations.
[0179] In the foregoing embodiments, interface test case update tasks, data state recovery tasks, and environment configuration synchronization tasks can be generated and executed respectively for differences in interface definition, differences in test data state, and differences in test environment configuration; when multiple self-healing tasks are generated, they can also be executed sequentially according to the task priority corresponding to each self-healing task.
[0180] In practice, different self-healing tasks have varying impacts on interface test cases, test data status, and test environment configuration. For example, an interface test case update task may involve multiple interface test cases, an environment configuration synchronization task may involve multiple test environments, and a data status recovery task may require alternative processing methods if automatic recovery fails. Based on this, embodiments of this application provide an interactive control method for self-healing tasks. This method can be one possible implementation of the aforementioned self-healing task execution process, used to determine the processing strategy and scope of the self-healing task based on user selection.
[0181] This application embodiment can be implemented in conjunction with any of the foregoing embodiments, and is used to output corresponding self-healing strategy selection information before executing interface test case update tasks or environment configuration synchronization tasks, or in the event of data state recovery task failure, and to perform corresponding processing operations according to the received user selection instructions. For example... Figure 7 As shown in the figure, this is a flowchart of a self-healing task interaction control method provided in an embodiment of this application. The method may include S701 to S704.
[0182] S701. Determine whether the conditions for outputting self-healing strategy selection information are met.
[0183] In this embodiment of the application, it can be determined whether to output the corresponding self-healing strategy selection information based on the task type and execution status of the self-healing task.
[0184] For example, when the self-healing task includes an interface test case update task, the conditions for outputting the first self-healing strategy selection information can be determined before executing the interface test case update task.
[0185] In cases where the self-healing task includes an environment configuration synchronization task, the conditions for outputting third self-healing strategy selection information can be determined before executing the environment configuration synchronization task.
[0186] When the self-healing task includes a data state recovery task, the data state recovery task can be executed first; if the data state recovery task fails, it is determined that the conditions for outputting the second self-healing strategy selection information are met.
[0187] Therefore, in the embodiments of this application, the appropriate user interaction timing can be determined according to the processing characteristics of different self-healing tasks.
[0188] S702. Output the self-healing strategy selection information corresponding to the self-healing task, and set the corresponding processing flow to a waiting state.
[0189] In this embodiment of the application, when the conditions for outputting self-healing strategy selection information are met, the computer device can output at least one processing strategy corresponding to the current self-healing task and suspend the corresponding processing flow.
[0190] When the self-healing task is an interface test case update task, the first self-healing strategy selection information may include at least one of the following: updating all affected interface test cases, updating only core interface test cases, updating user-specified interface test cases, and skipping interface test case updates.
[0191] Among them, core interface test cases can be interface test cases associated with required fields or key business fields.
[0192] When the self-healing task is a data state recovery task, the second self-healing strategy selection information may include at least one of the following: generating test data according to the data construction scheme provided by the user, skipping test data state detection, modifying the expected test data state, and stopping the generation of corresponding interface test cases.
[0193] When the self-healing task is an environment configuration synchronization task, the third self-healing strategy selection information may include at least one of the following: synchronizing all configuration items to be synchronized, synchronizing only preset key configuration items, and skipping environment configuration synchronization.
[0194] In this embodiment of the application, after outputting the self-healing strategy selection information, the corresponding self-healing task or processing flow can be set to a waiting state. In the waiting state, the execution of the corresponding modification, restoration, or synchronization operations can be paused until a user selection instruction is received.
[0195] S703. Receive user selection instructions and determine processing strategies and processing scope based on the user selection instructions.
[0196] In this embodiment, the user can select a corresponding processing strategy based on the self-healing strategy selection information. The computer device can receive the user's selection instruction and determine the processing strategy and processing scope of the corresponding self-healing task based on the user's selection instruction.
[0197] For example, in an interface test case update task, the scope of processing may include all affected interface test cases, core interface test cases, or user-specified interface test cases.
[0198] In the data state recovery task, the processing strategy may include constructing test data, skipping test data state detection, modifying the expected test data state, or stopping the generation or execution of the corresponding interface test cases.
[0199] In the environment configuration synchronization task, the processing scope can include all configuration items to be synchronized or preset key configuration items.
[0200] In one possible implementation, the user selection instructions may also include user-inputted test data construction information, expected test data status, or target configuration items.
[0201] S704. Execute the corresponding processing operation according to the user selection instruction.
[0202] In this embodiment of the application, the corresponding self-healing task or processing flow can be switched from the waiting state to the execution state, and the corresponding processing operation can be performed according to the processing strategy and processing scope determined by the user selection instruction.
[0203] For example, if the user chooses to update all affected interface test cases, all interface test cases affected by the first difference information can be updated; if the user chooses to update only the core interface test cases or the interface test cases specified by the user, only the interface test cases within the corresponding range can be updated; if the user chooses to skip the update, the current interface test case update task can be stopped.
[0204] If the user chooses to provide a data construction scheme, test data that meets the preconditions of the interface test cases can be generated according to the data construction scheme; if the user chooses to skip the test data status detection, the current test data status detection can be skipped; if the user chooses to modify the expected test data status, the corresponding expected test data status can be updated according to the user input; if the user chooses to stop generating interface test cases, the generation or execution process of the corresponding interface test cases can be terminated.
[0205] If the user selects to synchronize all configuration items to be synchronized, all abnormal differences indicated by the third difference information can be synchronized; if the user selects to synchronize only the preset key configuration items, only the corresponding key configuration items can be synchronized; if the user selects to skip environment configuration synchronization, the current environment configuration synchronization task can be stopped.
[0206] In summary, the embodiments of this application output corresponding self-healing strategy selection information before executing interface test case update tasks or environment configuration synchronization tasks, or in the event of data state recovery task failure, and determine the processing strategy and processing scope according to the user's selection instructions. This can avoid executing corresponding processing without obtaining user selection, enabling users to control the execution method and scope of impact of self-healing tasks, and reducing the possibility of inappropriate self-healing operations affecting the interface testing process.
[0207] For ease of understanding, the methods provided in the embodiments of this application will be described in general below.
[0208] In one example, the API testing platform receives a request to generate or execute API test cases for a target code version. The API testing platform can read the code repository identifier, first code version information, and code branch information stored in the API knowledge base, and obtain the second code version information corresponding to the target code version.
[0209] When the first code version information differs from the second code version information, the interface testing platform retrieves historical and current interface definition information, identifies newly added fields, changes in enumeration values, and changes in parameter types, and generates an interface change list. The platform outputs the interface change list and an interface test case update strategy, allowing the user to choose to update all affected interface test cases. The platform then updates the structured test data and test programs according to the field change type and verifies the update results.
[0210] After the interface test cases are updated, the interface testing platform proceeds to test data status detection. Based on the preconditions of the interface test cases, the platform determines that the target data should be in an enabled and valid state, and then queries the test database to check the actual status.
[0211] When the actual status is disabled or invalid, the interface testing platform generates and executes a data status update operation, and then queries and verifies it again. If the verification passes, processing continues. If the target data does not exist or the update fails, the failure reason and data status handling strategy are output, allowing the user to determine whether to construct data, adjust the expected status, skip the detection, or stop test case processing.
[0212] Subsequently, the interface testing platform can read the environment configuration files of multiple test environments and compare configuration items such as interface address, environment domain name, tenant database configuration, and timeout. The interface testing platform identifies differences in interface address, environment domain name, and tenant database configuration as normal differences, and inconsistencies in timeout as abnormal differences.
[0213] After the user selects to synchronize only critical configurations, the interface testing platform updates the target testing environment based on the timeout of the benchmark testing environment, while retaining the differences in environment address and database configuration.
[0214] When the above tasks are generated simultaneously, the interface testing platform first executes the interface test case update task, then the data state recovery task, and finally the environment configuration synchronization task. After each task passes verification, the interface testing platform obtains the corresponding self-healing results and executes the updated interface test cases.
[0215] In summary, this embodiment of the application, by detecting differences in interface definition, test data status, and test environment configuration during interface testing, and generating corresponding self-healing tasks based on the detected differences, can identify problems affecting the execution of interface test cases from multiple dimensions. By executing interface test case update tasks, data status recovery tasks, and environment configuration synchronization tasks sequentially according to task priority, and combining user selection and execution result verification, the self-healing tasks can be executed in an orderly and controllable manner, reducing mutual influence between different tasks, decreasing interface test failures caused by changes in interface definition, mismatched test data status, or abnormal test environment configuration, improving the adaptability of interface test cases to changes in relevant test information, and enhancing the stability and execution efficiency of the interface testing process.
[0216] This application also provides a self-healing device for interface test cases, see [link to relevant documentation]. Figure 8 The figure is a schematic diagram of the structure of a self-healing device for interface test cases provided in an embodiment of this application. Its specific implementation method is consistent with the implementation method and the technical effect achieved in the embodiments of the above method, and some contents will not be repeated.
[0217] A self-healing device 8100 for interface test cases, characterized in that it comprises: The unit comprises an acquisition unit 8101, a detection unit 8102, a generation unit 8103, and an execution unit 8104. The acquisition unit 8101 is used to acquire the interface test cases to be processed and the multi-dimensional test information corresponding to the interface test cases; the multi-dimensional test information includes first test information of the interface definition dimension, second test information of the test data status dimension, and third test information of the test environment configuration dimension. The detection unit 8102 is used to perform difference detection on the first test information, the second test information and the third test information to obtain multi-dimensional difference information; the multi-dimensional difference information includes first difference information representing interface definition differences, second difference information representing test data state differences and third difference information representing test environment configuration differences; The generation unit 8103 is used to generate a corresponding self-healing task based on the difference information indicating the existence of differences when the multidimensional difference information indicates the existence of differences. The self-healing task includes at least one of the interface test case update task, data state recovery task, and environment configuration synchronization task. The execution unit 8104 is used to execute the self-healing task and obtain the self-healing processing result corresponding to the self-healing task.
[0218] In one possible implementation, the execution unit is specifically used for: Determine the task priority of each of the generated self-healing tasks; the task priorities of the interface test case update task, the data state recovery task, and the environment configuration synchronization task decrease in that order. If at least two self-healing tasks are generated, the at least two self-healing tasks are executed sequentially according to the task priority.
[0219] In one possible implementation, the first test information includes historical interface definition information and current interface definition information; the acquisition unit is specifically used for: Retrieve the first code version information recorded in the API knowledge base and the second code version information corresponding to the current API source code; If the first code version information and the second code version information are inconsistent, obtain the historical interface definition information and the current interface definition information; The detection unit is specifically used for: By comparing the historical interface definition information with the current interface definition information, at least one interface change is determined from the following: field addition, field deletion, parameter type change, enumeration value change, and field required attribute change. The first difference information is generated based on the interface changes; The self-healing task includes the interface test case update task, and the execution unit is specifically used for: Based on the first difference information, determine the interface test cases affected by the interface change; Based on the type of interface change, at least one of the test fields, field values, parameter types, and type conversion logic in the affected interface test cases is updated to obtain the updated interface test cases. The updated interface test cases are then determined as the self-healing processing result corresponding to the interface test case update task.
[0220] In one possible implementation, the execution unit is specifically used for: If the first difference information indicates that a field has been added, the corresponding field is added to the test data of the affected interface test cases, and the value of the added field is set to a preset default value or a recommended value recorded in the interface knowledge base. If the first difference information indicates that a field has been deleted, the corresponding field is deleted from the test data of the affected interface test case; If the first difference information indicates a change in parameter type, update the parameter type or type conversion logic in the affected interface test case according to the changed parameter type; If the first difference information indicates that there is a change in the enumeration value, update or supplement the enumeration type test data in the affected interface test cases according to the changed enumeration value; If the first difference information indicates a change in the required field attribute, the test data of the corresponding field and the interface test cases associated with the field are updated according to the changed required field attribute.
[0221] In one possible implementation, the second test information includes expected test data status information and actual test data status information; the acquisition unit is specifically used for: Determine the expected test data status based on the preconditions of the interface test cases; Before executing the interface test cases, query the actual test data status; The detection unit is specifically used for: By comparing the expected test data state with the actual test data state, the second difference information is obtained; The self-healing task includes the data state recovery task; the execution unit is specifically used for: Based on the second difference information, a data status update statement is generated and executed to obtain the self-healing processing result corresponding to the data status recovery task.
[0222] In one possible implementation, the third test information includes test environment configuration information corresponding to at least three test environments; the acquisition unit is specifically used for: In response to a test environment switch or environment configuration change, read the environment configuration files corresponding to multiple test environments; The detection unit is specifically used for: Compare the configuration values of corresponding configuration items in different test environments; The configuration value differences are divided into normal differences to be retained and abnormal differences to be synchronized, thus obtaining the third difference information; The self-healing task includes the environment configuration synchronization task; the execution unit is specifically used for: Based on the third difference information, the configuration value corresponding to the abnormal difference is synchronized to the target test environment; The aforementioned normal differences are retained.
[0223] In one possible implementation, the apparatus further includes: a processing unit; The processing unit is specifically used for: Before executing the interface test case update task or the environment configuration synchronization task, or if the data state recovery task fails, output the corresponding self-healing strategy selection information and set the corresponding processing flow to a waiting state. Receive user selection instructions, determine processing strategies and processing scope based on the user selection instructions, and execute corresponding processing operations.
[0224] In one possible implementation, the execution unit is specifically used for: The execution results of the self-healing task are verified; If the verification is successful, at least one self-healing result is obtained, including the updated interface test cases, the restored test data status, and the synchronized test environment configuration information. If the verification fails, output the abnormal information and processing strategy selection information corresponding to the self-healing task.
[0225] In summary, this application's embodiments acquire multi-dimensional test information—including interface definition, test data status, and test environment configuration—corresponding to interface test cases. By performing difference detection on this multi-dimensional test information, it can determine whether at least one dimension of the interface definition, test data status, and test environment configuration exists. If a difference exists, a corresponding self-healing task is generated and executed based on the difference information. This process adjusts the interface test cases, test data status, or test environment configuration accordingly, enabling the interface test cases to adapt to changes in relevant test information. This reduces interface test failures caused by mismatches between test information and interface test cases, thus ensuring interface testing efficiency.
[0226] It is understandable that the above-mentioned units can be implemented through software, hardware, or a combination of both. Multiple units can be integrated into the same processing module, or deployed separately in a test platform, code management system, database management system, or environment configuration management system.
[0227] This application also provides a computer device. The computer device includes a processor and a memory. The memory stores program code and provides the program code to the processor; the processor executes the self-healing method for interface test cases described in any of the above embodiments according to instructions in the program code.
[0228] In this embodiment, the computer device may be a server, a test platform device, a personal computer, a cloud computing node, or other electronic device with data processing capabilities. The processor may include a central processing unit, a dedicated processor, or other processing unit capable of executing program instructions. The memory may include volatile memory and non-volatile memory.
[0229] This application embodiment may also provide a computer-readable storage medium storing program code. When the program code is executed by a processor, it causes the processor to execute the self-healing method of the aforementioned interface test cases. The computer-readable storage medium may include a magnetic storage medium, an optical storage medium, a semiconductor storage medium, or other media capable of storing program code.
[0230] The above description is merely one 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 technical scope 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.
Claims
1. A self-healing method for interface test cases, characterized in that, include: Obtain the interface test cases to be processed and the multi-dimensional test information corresponding to the interface test cases; The multidimensional test information includes first test information in the interface definition dimension, second test information in the test data status dimension, and third test information in the test environment configuration dimension. Perform difference detection on the first test information, the second test information, and the third test information to obtain multidimensional difference information; The multidimensional difference information includes first difference information representing interface definition differences, second difference information representing test data status differences, and third difference information representing test environment configuration differences. When the multidimensional difference information indicates that there is a difference, a corresponding self-healing task is generated based on the difference information indicating the difference. The self-healing task includes at least one of the following: interface test case update task, data state recovery task, and environment configuration synchronization task. Execute the self-healing task to obtain the self-healing processing result corresponding to the self-healing task.
2. The method according to claim 1, characterized in that, The execution of the self-healing task includes: Determine the task priority of each of the generated self-healing tasks; the task priorities of the interface test case update task, the data state recovery task, and the environment configuration synchronization task decrease in that order. If at least two self-healing tasks are generated, the at least two self-healing tasks are executed sequentially according to the task priority.
3. The method according to claim 1, characterized in that, The first test information includes historical interface definition information and current interface definition information; obtaining the first test information includes: Retrieve the first code version information recorded in the API knowledge base and the second code version information corresponding to the current API source code; If the first code version information and the second code version information are inconsistent, obtain the historical interface definition information and the current interface definition information; Obtaining the first difference information includes: By comparing the historical interface definition information with the current interface definition information, at least one interface change is determined from the following: field addition, field deletion, parameter type change, enumeration value change, and field required attribute change. The first difference information is generated based on the interface changes; The self-healing task includes the interface test case update task. Executing the self-healing task and obtaining the self-healing processing result corresponding to the self-healing task includes: Based on the first difference information, determine the interface test cases affected by the interface change; Based on the type of interface change, at least one of the test fields, field values, parameter types, and type conversion logic in the affected interface test cases is updated to obtain the updated interface test cases. The updated interface test cases are then determined as the self-healing processing result corresponding to the interface test case update task.
4. The method according to claim 3, characterized in that, The step of updating at least one of the test fields, field values, parameter types, and type conversion logic in the affected interface test cases according to the type of interface change, to obtain updated interface test cases, includes: If the first difference information indicates that a field has been added, the corresponding field is added to the test data of the affected interface test cases, and the value of the added field is set to a preset default value or a recommended value recorded in the interface knowledge base. If the first difference information indicates that a field has been deleted, the corresponding field is deleted from the test data of the affected interface test case; If the first difference information indicates a change in parameter type, update the parameter type or type conversion logic in the affected interface test case according to the changed parameter type; If the first difference information indicates that there is a change in the enumeration value, update or supplement the enumeration type test data in the affected interface test cases according to the changed enumeration value; If the first difference information indicates a change in the required field attribute, the test data of the corresponding field and the interface test cases associated with the field are updated according to the changed required field attribute.
5. The method according to claim 1, characterized in that, The second test information includes expected test data status information and actual test data status information; Obtaining the second test information includes: Determine the expected test data status based on the preconditions of the interface test cases; Before executing the interface test cases, query the actual test data status; Obtaining the second difference information includes: By comparing the expected test data state with the actual test data state, the second difference information is obtained; The self-healing task includes the data state recovery task; executing the self-healing task and obtaining the self-healing processing result corresponding to the self-healing task includes: Based on the second difference information, a data status update statement is generated and executed to obtain the self-healing processing result corresponding to the data status recovery task.
6. The method according to claim 1, characterized in that, The third test information includes test environment configuration information corresponding to at least three test environments; obtaining the third test information includes: In response to a test environment switch or environment configuration change, read the environment configuration files corresponding to multiple test environments; Obtaining the third difference information includes: Compare the configuration values of corresponding configuration items in different test environments; The configuration value differences are divided into normal differences to be retained and abnormal differences to be synchronized, thus obtaining the third difference information; The self-healing task includes the environment configuration synchronization task; executing the self-healing task and obtaining the self-healing processing result corresponding to the self-healing task includes: Based on the third difference information, the configuration value corresponding to the abnormal difference is synchronized to the target test environment; The aforementioned normal differences are retained.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Before executing the interface test case update task or the environment configuration synchronization task, or if the data state recovery task fails, output the corresponding self-healing strategy selection information and set the corresponding processing flow to a waiting state. Receive user selection instructions, determine processing strategies and processing scope based on the user selection instructions, and execute corresponding processing operations.
8. The method according to any one of claims 1 to 6, characterized in that, Obtaining the self-healing processing result corresponding to the self-healing task includes: The execution results of the self-healing task are verified; If the verification is successful, at least one self-healing result is obtained, including the updated interface test cases, the restored test data status, and the synchronized test environment configuration information. If the verification fails, output the abnormal information and processing strategy selection information corresponding to the self-healing task.
9. A self-healing device for interface test cases, characterized in that, include: Acquisition unit, detection unit, generation unit, and execution unit; The acquisition unit is used to acquire the interface test cases to be processed and the multi-dimensional test information corresponding to the interface test cases. The multidimensional test information includes first test information in the interface definition dimension, second test information in the test data status dimension, and third test information in the test environment configuration dimension. The detection unit is used to perform difference detection on the first test information, the second test information and the third test information to obtain multi-dimensional difference information; The multidimensional difference information includes first difference information representing interface definition differences, second difference information representing test data status differences, and third difference information representing test environment configuration differences. The generation unit is used to generate a corresponding self-healing task based on the multidimensional difference information indicating the existence of differences when the multidimensional difference information indicates the existence of differences. The self-healing task includes at least one of the following: interface test case update task, data state recovery task, and environment configuration synchronization task. The execution unit is used to execute the self-healing task and obtain the self-healing processing result corresponding to the self-healing task.
10. A computer device, characterized in that, The computer device includes: a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of the method as described in any one of claims 1 to 8 according to instructions in the program code.
