Code testing method and device, computer equipment and computer readable storage medium

By detecting code changes in the coordination cluster, automatically comparing code differences, and executing relevant test cases, it solves the time-consuming communication and verification problems of testers, improves testing efficiency, and reduces risks.

CN118733441APending Publication Date: 2024-10-01PING AN PAY ELECTRONIC PAYMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410730335.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Testers need to spend a lot of time communicating with developers whether there are new or modified code submissions, and checking regression scenarios and cases after code changes, resulting in long testing time and low efficiency.

Method used

By detecting the version information and code data of the target coordination node in the coordination cluster, it automatically compares the target code with historical code, determines the difference code blocks, executes relevant test cases in the automated case library, and sends the execution results to the remote terminal.

Benefits of technology

It achieves timely triggering of test case execution after code updates, saves testers analysis and communication time, and reduces testing manpower and online risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733441A_ABST
    Figure CN118733441A_ABST
Patent Text Reader

Abstract

The invention discloses a code testing method and device, computer equipment and a computer readable storage medium, relates to the technical field of Internet, and can enable a tester not to pay attention to whether a code is newly added or not in real time, thereby saving the analysis time and communication cost of the tester on the new version code, and further reducing the testing manpower and the online risk. The method comprises the steps that when it is detected that a target coordination node exists in a coordination cluster, version information and target code data corresponding to the target coordination node are read, and the target coordination node is a coordination node with content change in the coordination cluster; querying historical code data of a previous version according to the version information, and comparing the target code data with the historical code data to obtain a difference code block; and in the automatic case library, determining a target case corresponding to the difference code block, executing the target case to perform code testing, and sending an execution result to the remote terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a code testing method, apparatus, computer equipment, and computer-readable storage medium. Background Art

[0002] With the continuous development of Internet technology, digital business is increasing, which requires business systems to continuously update data. In order to ensure the quality of business on the production line, Internet companies will order testers to run tests on the business before the business is released online, and then release it online after there are no problems in the test.

[0003] In related technologies, testers need to spend a lot of time communicating with developers to see if there are any new or modified code submissions. In addition, they also need to spend extra time to check regression scenarios and cases after the development code is changed, which leads to long testing time and low testing efficiency. Summary of the invention

[0004] In view of this, the present application provides a code testing method, apparatus, computer device and computer-readable storage medium, the main purpose of which is to solve the problem that testers currently need to spend a lot of time communicating with developers whether there are new or modified code submissions. In addition, it is also necessary to spend extra time to check the regression scenarios and cases after the development code is changed, which leads to long testing time and low testing efficiency.

[0005] According to the first aspect of the present application, a code testing method is provided, the method comprising:

[0006] When it is detected that there is a target coordination node in the coordination cluster, the version information and target code data corresponding to the target coordination node are read, wherein the target coordination node is the coordination node in the coordination cluster where content changes occur;

[0007] According to the version information, query the historical code data of the previous version, and obtain the difference code block by comparing the target code data with the historical code data;

[0008] In the automation case library, a target case corresponding to the difference code block is determined, and the target case is executed to perform code testing, and the execution result is sent to a remote terminal.

[0009] Optionally, when it is detected that there is a target coordination node in the coordination cluster, before reading the version information and target code data corresponding to the target coordination node, the method further includes:

[0010] In response to the code submission request, receiving a submission data package uploaded by the requesting user, wherein the submission data package carries version information and code data, and the version information includes branch information and version number;

[0011] In the coordination cluster, determining a target node branch according to the branch information;

[0012] A designated coordination node corresponding to the version number is determined among a plurality of coordination nodes associated with the target node branch, and the code data is written into the designated coordination node.

[0013] Optionally, querying the historical code data of the previous version according to the version information, and obtaining the difference code block by comparing the target code data with the historical code data, includes:

[0014] Read the version number in the version information, determine the historical version number of the previous code update according to the version number, query the historical coordination node corresponding to the historical version number in the coordination cluster, and read the historical code data stored in the historical coordination node;

[0015] The target code data and the historical code data are compared to obtain a code comparison result, a target class of each code block in the code comparison result is detected, and a code block associated with the target class to which the attribute is added is used as the difference code block.

[0016] Optionally, the comparing the target code data with the historical code data to obtain a code comparison result includes:

[0017] Traversing the target code blocks in the target code data and the historical code blocks in the historical code data, and comparing each of the target code blocks with the historical code blocks respectively;

[0018] Attributes are added to the target code block according to the comparison result, and target code data with the added attributes is output as the code comparison result.

[0019] Optionally, adding attributes to the target code block according to the comparison result includes:

[0020] If the comparison result indicates that the target code block does not exist in the historical code block, adding a first preset attribute to the target class corresponding to the target code block;

[0021] If the comparison result indicates that the target code block is a modified code of any historical code block, a second preset attribute is added to the target class corresponding to the target code block.

[0022] Optionally, searching the automation case library for a target case corresponding to the difference code block includes:

[0023] Perform code detection on the difference code block to obtain the entry method and input parameters associated with the difference code block, and traverse all automation cases in the automation case library to determine case information of each automation case;

[0024] detecting case information of each of the automation cases;

[0025] When it is detected that the case information matches the entry method, extracting the automation case corresponding to the case information as the first case;

[0026] Calling a preset plug-in to query the association relationship between the entry method and the input parameter;

[0027] If the association relationship does not exist between the entry method and the input parameter, the first case is used as the target case.

[0028] Optionally, after querying the association relationship between the entry method and the input parameter, the method further includes:

[0029] If the association relationship exists between the entry method and the input parameter, detecting case information of each automation case in the first case;

[0030] When it is detected that the case information matches the input parameter, an automated case corresponding to the case information is extracted as a second case, and the second case is used as the target case.

[0031] According to a second aspect of the present application, a code testing device is provided, the device comprising:

[0032] A reading module, configured to read the version information and target code data corresponding to the target coordination node when detecting that there is a target coordination node in the coordination cluster, wherein the target coordination node is the coordination node in the coordination cluster where content changes occur;

[0033] A comparison module, used for querying the historical code data of the previous version according to the version information, and obtaining a difference code block by comparing the target code data with the historical code data;

[0034] The execution module is used to determine the target case corresponding to the difference code block in the automation case library, execute the target case to perform code testing, and send the execution result to the remote terminal.

[0035] Optionally, the device further comprises:

[0036] A receiving module, configured to receive, in response to a code submission request, a submission data package uploaded by a requesting user, wherein the submission data package carries version information and code data, and the version information includes branch information and a version number;

[0037] A determination module, configured to determine a target node branch in the coordination cluster according to the branch information;

[0038] An input module is used to determine a designated coordination node corresponding to the version number among a plurality of coordination nodes associated with the target node branch, and write the code data into the designated coordination node.

[0039] Optionally, the comparison module is used to read the version number in the version information, determine the historical version number of the previous code update based on the version number, and query the historical coordination node corresponding to the historical version number in the coordination cluster, and read the historical code data stored in the historical coordination node; compare the target code data and the historical code data to obtain a code comparison result, detect the target class of each code block in the code comparison result, and use the code block associated with the target class with added attributes as the difference code block.

[0040] Optionally, the comparison module is used to traverse the target code blocks in the target code data and the historical code blocks in the historical code data, and compare each target code block with the historical code block respectively; add attributes to the target code block according to the comparison result, and output the target code data with added attributes as the code comparison result.

[0041] Optionally, the comparison module is used to add a first preset attribute to the target class corresponding to the target code block if the comparison result indicates that the target code block does not exist in the historical code block; and add a second preset attribute to the target class corresponding to the target code block if the comparison result indicates that the target code block is a modified code of any historical code block.

[0042] Optionally, the execution module is used to perform code detection on the difference code block, obtain the entry method and input parameters associated with the difference code block, and traverse all automation cases in the automation case library to determine the case information of each automation case; detect the case information of each automation case; when it is detected that the case information matches the entry method, extract the automation case corresponding to the case information as the first case; call a preset plug-in to query the association relationship between the entry method and the input parameter; if the association relationship does not exist between the entry method and the input parameter, use the first case as the target case.

[0043] Optionally, the execution module is also used to detect the case information of each automated case in the first case if the association relationship exists between the entry method and the input parameter; when it is detected that the case information matches the input parameter, extract the automated case corresponding to the case information as the second case, and use the second case as the target case.

[0044] According to a third aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.

[0045] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.

[0046] By means of the above technical scheme, a code testing method, device, computer equipment and computer-readable storage medium provided by the present application, the code testing system applicable to the present application will monitor and detect the zookeeper coordination cluster, and when it is detected that there is a target coordination node with content changes in the coordination cluster, the version information and target code data corresponding to the target coordination node are read in time. Further, according to the version information of the target coordination node, the historical code data of the previous version is queried, and the updated code block in the target code data, that is, the difference code block, is automatically determined by comparing the target code data with the historical code data. Next, in the automated case library, the target case associated with the difference code block is traversed according to the difference code block. Finally, the target case is executed to perform code testing, and the execution result is sent to the remote terminal. The present application can trigger the execution of the corresponding test case in time after monitoring the existence of code updates through the code testing system, and perform code testing, so that the tester no longer needs to pay attention to whether the code is newly added in real time, saving the tester's analysis time and communication cost for the new version of the code, thereby reducing the test manpower and online risks.

[0047] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0049] Figure 1 A schematic diagram of a code testing method provided in an embodiment of the present application is shown;

[0050] Figure 2A A schematic diagram of a code testing method provided in an embodiment of the present application is shown;

[0051] Figure 2B A schematic diagram of a code testing method provided in an embodiment of the present application is shown;

[0052] Figure 3A A schematic diagram of the structure of a code testing device provided in an embodiment of the present application is shown;

[0053] Figure 3B A schematic diagram of the structure of a code testing device provided in an embodiment of the present application is shown;

[0054] Figure 4 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0055] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0056] The present application embodiment provides a code testing method, such as Figure 1 As shown, the method includes:

[0057] With the continuous development of Internet technology, digital business is increasing, which makes the business system constantly update data. In order to ensure the quality of business on the production line, Internet companies will order testers to run tests on the business before the business is released online, and then release it online after there are no problems in the test. At present, testers need to spend a lot of time communicating with developers whether there are new and modified code submissions. In addition, it is necessary to spend extra time to check the regression scenarios and cases after the development code is changed, which leads to long testing time and low testing efficiency. Therefore, the present application provides a code testing method, which is applicable to a code testing system. The applicable code testing system will monitor and detect the zookeeper coordination cluster. When it is detected that there is a target coordination node with content changes in the coordination cluster, the version information and target code data corresponding to the target coordination node are read in time. Further, according to the version information of the target coordination node, the historical code data of the previous version is queried, and the updated code block in the target code data is automatically determined by comparing the target code data with the historical code data. That is, the difference code block. Next, in the automated case library, the target case associated with the difference code block is traversed according to the difference code block. Finally, the target case is executed for code testing, and the execution result is sent to the remote terminal. This application uses a code testing system to promptly trigger the execution of corresponding test cases after monitoring code updates to perform code testing, so that testers no longer need to pay real-time attention to whether there are new code updates, saving testers' analysis time and communication costs for new version codes, thereby reducing testing manpower and online risks.

[0058] 101. When it is detected that there is a target coordination node in the coordination cluster, version information and target code data corresponding to the target coordination node are read, wherein the target coordination node is a coordination node in which content changes occur in the coordination cluster.

[0059] In an embodiment of the present application, the code testing system will detect the data recorded in the coordination cluster in real time, and the detection can be performed specifically through a preset real-time monitoring plug-in. It should be noted that the code testing system includes a code library, a coordination cluster (zookeeper cluster) and a pava (public address and voice alarm) system. In the actual operation process, when it is detected that there is a target coordination node with content changes in the coordination cluster, the code testing system will issue a notification to the pava system to prompt the pava system that there is a code update, and enable the pava system to obtain the target code data and corresponding version information recorded in the target coordination node, wherein the version information includes the branch information to be released this time and the version number corresponding to the submitted code.

[0060] 102. According to the version information, query the historical code data of the previous version, and obtain the difference code block by comparing the target code data with the historical code data.

[0061] Next, in order to analyze the scope of the impact of this code change, the code testing system will query the historical version number of the previous code update submitted to the same business branch based on the version information of this code update. Then, the historical code data is obtained according to the historical version number, and the target code data is compared with the historical code data to obtain the difference code block, which is the scope of this code update.

[0062] 103. In the automation case library, determine the target case corresponding to the difference code block, execute the target case to perform code testing, and send the execution result to the remote terminal.

[0063] In this step, the code testing system automatically determines the case that matches the difference code block in the automated case library as the target case, triggers the Jenkins continuous integration tool to execute the target case, and finally analyzes the case execution status. The execution results obtained after analysis are sent to relevant testers and developers by email or text message, so that the testers and developers can judge whether the version of the code can be released online based on the execution results.

[0064] The method provided in the embodiment of the present application is applicable to a code testing system. The applicable code testing system will monitor and detect the zookeeper coordination cluster. When it is detected that there is a target coordination node with content changes in the coordination cluster, the version information and target code data corresponding to the target coordination node are read in time. Further, according to the version information of the target coordination node, the historical code data of the previous version is queried, and the updated code block in the target code data, that is, the difference code block, is automatically determined by comparing the target code data with the historical code data. Next, in the automated case library, the target cases associated with the difference code blocks are traversed according to the difference code blocks. Finally, the target case is executed to perform code testing, and the execution results are sent to the remote terminal. The present application can trigger the execution of the corresponding test case in time after monitoring the existence of code updates through the code testing system, and perform code testing, so that the tester no longer needs to pay attention to whether the code is newly added in real time, saving the tester's analysis time and communication costs for the new version of the code, thereby reducing the test manpower and online risks.

[0065] The present application embodiment provides a code testing method, such as Figure 2A As shown, the method includes:

[0066] 201. In response to a code submission request, receive a submission data package uploaded by a requesting user, and write code data in the submission data package to a designated cluster node in a coordination cluster.

[0067] In the actual operation process, developers will develop functions in the local environment according to the requirements document, and submit the completed code data to the tester for intranet environment testing. At present, for testers, testers need to pay attention to whether the developer submits the code data in a timely manner. After discovering that the developer has submitted the code data, they read the code data to determine the newly added or modified code blocks, and then fully execute the regression case after the code change to complete the test process of the code data.

[0068] In the embodiment of the present application, the developer writes the uploaded submission data packet to the designated cluster node in the coordination cluster through the code testing system. It should be noted that the code testing system includes a code library, a coordination cluster (zookeeper cluster) and a pava (public address and voice alarm) system.

[0069] Specifically, after the developer completes the writing of the code data, the developer packages the code data and the version information corresponding to the code data into a submission data package. Subsequently, the developer initiates a code submission request to the code testing system. The code testing system responds to the code submission request initiated by the developer, receives the submission data package uploaded by the requesting user, and uploads the code data to the code library via the code testing system. It should be noted that the submission data package carries version information and code data, wherein the version information includes branch information and version number. Furthermore, after receiving the submission data package, the code library in the code testing system will write the code data to the corresponding coordination node in the coordination cluster according to the version information in the submission data package. In fact, the code library first determines the target node branch in the coordination cluster according to the branch information in the version information, and then determines the designated coordination node corresponding to the version number among the multiple coordination nodes associated with the target node branch, and finally writes the code data to the designated coordination node.

[0070] 202 . Monitor the coordination cluster, and when it is detected that there is a target coordination node in the coordination cluster, read the version information and target code data corresponding to the target coordination node.

[0071] Furthermore, the pava system in the code testing system can use a monitoring plug-in to perform real-time detection of the coordination cluster in the code testing system to achieve the purpose of timely discovering the coordination nodes of content changes, thereby eliminating the need for testers to manually pay attention to whether developers submit changed code, reducing labor costs.

[0072] In the actual operation process, when the monitoring plug-in detects that there is a target coordination node with content changes in the coordination cluster, it will generate a prompt message and send the prompt message to the pava system. Furthermore, after receiving the prompt message, the pava system will obtain the target code data and corresponding version information recorded in the target coordination node by sending a request to the coordination cluster, where the version information includes the branch information to be released this time and the version number corresponding to the submitted code.

[0073] 203. According to the version information, query the historical code data of the previous version, and obtain the difference code block by comparing the target code data with the historical code data.

[0074] In this step, considering that the tester manually reads the code data to find the scope of this code change, the task is large and the reading time is long, which will lead to a long overall test time and low test efficiency. Therefore, in the embodiment of the present application, the code testing system will automatically analyze the scope of this code change and determine the difference code block. The specific process of determining the difference code block is as follows:

[0075] First, the Pava system in the code testing system needs to read the unique version number in the version information corresponding to the target code data, and then query the historical version number of the previous code update submission for the same business branch based on the version number.

[0076] Next, the pava system initiates an information acquisition request to the coordination cluster, where the information acquisition request carries the historical version number. After receiving the historical version number, the coordination cluster determines the corresponding historical coordination node according to the historical version number. Then, it reads the historical code data stored in the historical coordination node and sends the historical code data to the pava system.

[0077] Furthermore, the pava system compares the target code data and the historical code data to obtain the code comparison result. Specifically, the target code blocks in the target code data and the historical code blocks in the historical code data are traversed, and each target code block is compared with the historical code block respectively. Then, attributes are added to the target code block according to the comparison result. In the actual operation process, if the comparison result indicates that the target code block does not exist in the historical code block, the first preset attribute is added to the target class corresponding to the target code block. For example, if a code block has newly added code, the add attribute is added to the target class of the code block. If the comparison result indicates that the target code block is a modified code of any historical code block, the second preset attribute is added to the target class corresponding to the target code block. For example, if a code block is a modified code, the updata attribute is added to the target class of the code block. Finally, the target code data with the added attributes is output as the code comparison result.

[0078] Finally, the target class of each code block in the code comparison result is detected, and the code block associated with the target class with added attributes is taken as the difference code block.

[0079] Through the code testing system, the target code data and historical code data are automatically compared to determine the scope of this code update, that is, the difference code block. This not only avoids the mistakes caused by manual analysis by testers, but also saves testers' time in analyzing codes, thereby improving code testing efficiency.

[0080] 204. In the automation case library, determine the target case corresponding to the difference code block, execute the target case to perform code testing, and send the execution result to the remote terminal.

[0081] In this step, the Pava system in the code testing system automatically searches for cases matching the difference code blocks in the automated case library as target cases, and then executes the target cases for code testing, and sends the execution results to the remote terminal so that testers and developers can determine whether the version of the code can be released online based on the execution results.

[0082] In the actual operation process, the pava system performs code detection on the difference code block and obtains the entry method associated with the difference code block. The entry method is the interface exposed by the code block to the upstream, such as Interface, http interface, etc. Furthermore, the corresponding input parameters of the entry method are obtained through reflection. In fact, the input parameters are defined by the interface itself, such as public, addUser(User uer), etc.

[0083] Next, the pava system traverses all automation cases in the automation case library, determines the case information of each automation case and detects the case information of each automation case. When it is detected that the case information matches the entry method, the automation case corresponding to the case information is extracted as the first case.

[0084] Subsequently, the preset plug-in is called to query the association between the entry method and the input parameter. If there is no association between the entry method and the input parameter, the first case is used as the target case. For example, the input parameter is the user name, but the entry method performs a points redemption operation, which has no association with the user name, that is, there is no association between the entry method and the input parameter. If there is an association between the entry method and the input parameter, the case information of each automated case in the first case is detected. When it is detected that the case information matches the input parameter, the automated case corresponding to the case information is extracted as the second case, and the second case is used as the target case.

[0085] Finally, the target case is automatically executed by triggering Jenkins, which is a continuous integration tool used to monitor repetitive work and aims to provide an open and easy-to-use software platform to enable continuous integration of software projects. After the target case is executed, the code testing system analyzes the case execution and sends the execution results obtained after analysis to relevant testers and developers by email or SMS, so that testers and developers can determine whether the version of the code can be released online based on the execution results.

[0086] In summary, if Figure 2B As shown in the figure, the workflow of the code testing system is that the developer first submits the new version of the code data to the code base. The code base in the code testing system writes the code data to the coordination node in the zookeeper cluster (coordination cluster) through the branch and version number corresponding to the code data. At the same time, when the pava system in the code testing system receives the notification that there is a target coordination node with content changes in the coordination cluster, it obtains the changed branch, version number, code data and other information from the coordination cluster. Next, the pava system analyzes the scope of the code update based on the information obtained, obtains the difference code block, and then queries the target case in the automation case library based on the difference code block. Finally, by triggering Jenkins to automatically execute the target case, the case execution status will be analyzed, the execution results will be generated, and the execution results will be sent to the corresponding test and development personnel in the form of email or text message.

[0087] The method provided in the embodiment of the present application is applicable to a code testing system. The applicable code testing system will monitor and detect the zookeeper coordination cluster. When it is detected that there is a target coordination node with content changes in the coordination cluster, the version information and target code data corresponding to the target coordination node are read in time. Further, according to the version information of the target coordination node, the historical code data of the previous version is queried, and the updated code block in the target code data, that is, the difference code block, is automatically determined by comparing the target code data with the historical code data. Next, in the automated case library, the target cases associated with the difference code blocks are traversed according to the difference code blocks. Finally, the target case is executed to perform code testing, and the execution results are sent to the remote terminal. The present application can trigger the execution of the corresponding test case in time after monitoring the existence of code updates through the code testing system, and perform code testing, so that the tester no longer needs to pay attention to whether the code is newly added in real time, saving the tester's analysis time and communication costs for the new version of the code, thereby reducing the test manpower and online risks.

[0088] Further, as Figure 1 In a specific implementation of the method, the present application provides a code testing device, such as Figure 3AAs shown, the device includes: a reading module 301, a comparison module 302, and an execution module 303.

[0089] The reading module 301 is used to read the version information and target code data corresponding to the target coordination node when it is detected that there is a target coordination node in the coordination cluster, wherein the target coordination node is the coordination node in the coordination cluster where content changes occur;

[0090] The comparison module 302 is used to query the historical code data of the previous version according to the version information, and obtain the difference code block by comparing the target code data with the historical code data;

[0091] The execution module 303 is used to determine the target case corresponding to the difference code block in the automation case library, execute the target case to perform code testing, and send the execution result to the remote terminal.

[0092] In specific application scenarios, such as Figure 3B As shown, the device further includes: a receiving module 304 , a determining module 305 , and an input module 306 .

[0093] The receiving module 304 is used to receive a submission data package uploaded by a requesting user in response to a code submission request, wherein the submission data package carries version information and code data, and the version information includes branch information and version number;

[0094] The determination module 305 is used to determine the target node branch in the coordination cluster according to the branch information;

[0095] The input module 306 is used to determine a designated coordination node corresponding to the version number among multiple coordination nodes associated with the target node branch, and write the code data into the designated coordination node.

[0096] In a specific application scenario, the comparison module 302 is used to read the version number in the version information, determine the historical version number of the previous code update based on the version number, and query the historical coordination node corresponding to the historical version number in the coordination cluster, and read the historical code data stored in the historical coordination node; compare the target code data and the historical code data to obtain a code comparison result, detect the target class of each code block in the code comparison result, and use the code block associated with the target class with added attributes as the difference code block.

[0097] In a specific application scenario, the comparison module 302 is used to traverse the target code blocks in the target code data and the historical code blocks in the historical code data, and compare each target code block with the historical code block respectively; add attributes to the target code block according to the comparison result, and output the target code data with the added attributes as the code comparison result.

[0098] In a specific application scenario, the comparison module 302 is used to add a first preset attribute to the target class corresponding to the target code block if the comparison result indicates that the target code block does not exist in the historical code block; if the comparison result indicates that the target code block is a modified code of any historical code block, then add a second preset attribute to the target class corresponding to the target code block.

[0099] In a specific application scenario, the execution module 303 is used to perform code detection on the difference code block, obtain the entry method and input parameter associated with the difference code block, and traverse all automation cases in the automation case library to determine the case information of each automation case; detect the case information of each automation case; when it is detected that the case information matches the entry method, extract the automation case corresponding to the case information as the first case; call the preset plug-in to query the association relationship between the entry method and the input parameter; if the association relationship does not exist between the entry method and the input parameter, use the first case as the target case.

[0100] In a specific application scenario, the execution module 303 is also used to detect the case information of each automated case in the first case if there is the association relationship between the entry method and the input parameter; when it is detected that the case information matches the input parameter, the automated case corresponding to the case information is extracted as the second case, and the second case is used as the target case.

[0101] The device provided in the embodiment of the present application will monitor and detect the zookeeper coordination cluster. When it is detected that there is a target coordination node with content changes in the coordination cluster, the version information and target code data corresponding to the target coordination node are read in time. Furthermore, based on the version information of the target coordination node, the historical code data of the previous version is queried, and the updated code block in the target code data, that is, the difference code block, is automatically determined by comparing the target code data with the historical code data. Next, in the automated case library, the target cases associated with the difference code blocks are traversed according to the difference code blocks. Finally, the target case is executed to perform code testing, and the execution results are sent to the remote terminal. The present application can trigger the execution of the corresponding test case in time after monitoring the existence of code updates through the code testing system, and perform code testing, so that the tester no longer needs to pay attention to whether the code is newly added in real time, saving the tester's analysis time and communication costs for the new version of the code, thereby reducing the test manpower and online risks.

[0102] It should be noted that for other corresponding descriptions of the functional units involved in a code testing device provided in an embodiment of the present application, reference can be made to Figure 1 and FIG. 2A to FIG. 2B The corresponding description in will not be repeated here.

[0103] In an exemplary embodiment, see Figure 4 , and also provides a device, which includes a communication bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the code testing method in the above embodiment.

[0104] A computer-readable storage medium stores a computer program, which implements the steps of the code testing method when executed by a processor.

[0105] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by hardware, or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.

[0106] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required for implementing the present application.

[0107] Those skilled in the art will appreciate that the modules in the device in the implementation scenario can be distributed in the device in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple sub-modules.

[0108] The above application serial numbers are for description only and do not represent the advantages or disadvantages of the implementation scenarios.

[0109] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.

Claims

1. A code testing method, characterized in that: include: When it is detected that there is a target coordination node in the coordination cluster, the version information and target code data corresponding to the target coordination node are read, wherein the target coordination node is the coordination node in the coordination cluster where content changes occur; According to the version information, query the historical code data of the previous version, and obtain the difference code block by comparing the target code data with the historical code data; In the automation case library, a target case corresponding to the difference code block is determined, and the target case is executed to perform code testing, and the execution result is sent to a remote terminal.

2. The method according to claim 1, characterized in that: When it is detected that there is a target coordination node in the coordination cluster, before reading the version information and target code data corresponding to the target coordination node, the method further includes: In response to the code submission request, receiving a submission data package uploaded by the requesting user, wherein the submission data package carries version information and code data, and the version information includes branch information and version number; In the coordination cluster, determining a target node branch according to the branch information; A designated coordination node corresponding to the version number is determined among a plurality of coordination nodes associated with the target node branch, and the code data is written into the designated coordination node.

3. The method according to claim 1, characterized in that The step of querying the historical code data of the previous version based on the version information and obtaining the difference code block by comparing the target code data with the historical code data includes: Read the version number in the version information, determine the historical version number of the previous code update according to the version number, query the historical coordination node corresponding to the historical version number in the coordination cluster, and read the historical code data stored in the historical coordination node; The target code data and the historical code data are compared to obtain a code comparison result, a target class of each code block in the code comparison result is detected, and a code block associated with the target class to which the attribute is added is used as the difference code block.

4. The method according to claim 3, characterized in that The comparing the target code data with the historical code data to obtain a code comparison result includes: Traversing the target code blocks in the target code data and the historical code blocks in the historical code data, and comparing each of the target code blocks with the historical code blocks respectively; Attributes are added to the target code block according to the comparison result, and target code data with the added attributes is output as the code comparison result.

5. The method according to claim 4, characterized in that The adding attributes to the target code block according to the comparison result includes: If the comparison result indicates that the target code block does not exist in the historical code block, adding a first preset attribute to the target class corresponding to the target code block; If the comparison result indicates that the target code block is a modified code of any historical code block, a second preset attribute is added to the target class corresponding to the target code block.

6. The method according to claim 1, characterized in that The step of searching the automation case library for a target case corresponding to the difference code block includes: Perform code detection on the difference code block to obtain the entry method and input parameters associated with the difference code block, and traverse all automation cases in the automation case library to determine case information of each automation case; detecting case information of each of the automation cases; When it is detected that the case information matches the entry method, extracting the automation case corresponding to the case information as the first case; Calling a preset plug-in to query the association relationship between the entry method and the input parameter; If the association relationship does not exist between the entry method and the input parameter, the first case is used as the target case.

7. The method according to claim 6, characterized in that After querying the association relationship between the entry method and the input parameter, the method further includes: If the association relationship exists between the entry method and the input parameter, detecting case information of each automation case in the first case; When it is detected that the case information matches the input parameter, an automated case corresponding to the case information is extracted as a second case, and the second case is used as the target case.

8. A code testing device, characterized in that: include: A reading module, configured to read the version information and target code data corresponding to the target coordination node when detecting that there is a target coordination node in the coordination cluster, wherein the target coordination node is the coordination node in the coordination cluster where content changes occur; A comparison module, used for querying the historical code data of the previous version according to the version information, and obtaining a difference code block by comparing the target code data with the historical code data; The execution module is used to determine the target case corresponding to the difference code block in the automation case library, execute the target case to perform code testing, and send the execution result to the remote terminal.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.