Code testing method and device

By automating code testing and generating test reports, the time-consuming code testing problem caused by manual operations is solved, and fast and efficient code exception location and testing is achieved.

CN114546849BActive Publication Date: 2025-08-29BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210150930.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2025-08-29
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

In the prior art, code testing relies on manual operations, which makes it take a long time to quickly trigger regression verification and position code exception locations.

Method used

By automatically triggering code tests, matching exception scenarios, and generating test reports to indicate exception statements, achieving fast and efficient code testing and exception location.

Benefits of technology

It realizes the automation of code testing and quickly locates abnormal parts, effectively shortens the testing time and improves the testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114546849B_ABST
    Figure CN114546849B_ABST
Patent Text Reader

Abstract

The present disclosure provides a code testing method and device, which relate to computer technology, and in particular to the field of code testing. The specific implementation scheme is: testing the first code according to at least one test case, and obtaining the first test result of each test case, wherein the first code is the code to be put online. According to at least one test case and the first test result of each test case, the target test case is determined, wherein the first test result of the target test case is failure. Obtain the exception identifier corresponding to the target test case, and determine the target scenario that matches the exception identifier. According to the target scenario, the target test case and the first code, send a test report to the target device, wherein the test report includes the statements covered by the target test case in the first code. The technical solution of the present disclosure can effectively shorten the time consumed in code testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of code testing in computer technology, and in particular to a code testing method and device. Background Art

[0002] In the process of iterative project development, testing the project code is a very important step. Code testing can effectively ensure the correctness and integrity of project operation.

[0003] Currently, in the existing technology, code testing is usually implemented by manually configuring the environment and executing the test process. After the test, for test cases that have abnormalities, the causes of these abnormalities must be manually investigated.

[0004] Therefore, the existing technology relies on manual code testing, which results in a long time consumption of code testing. Summary of the Invention

[0005] The present disclosure provides a code testing method and device.

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

[0007] Testing the first code according to at least one test case to obtain a first test result for each test case, wherein the first code is the code to be put online;

[0008] Determining a target test case according to the at least one test case and a first test result of each of the test cases, wherein the first test result of the target test case is failure;

[0009] Obtain an exception identifier corresponding to the target test case, and determine a target scenario that matches the exception identifier;

[0010] A test report is sent to a target device according to the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code.

[0011] According to a second aspect of the present disclosure, there is provided a code testing device, comprising:

[0012] a processing module, configured to test a first code according to at least one test case to obtain a first test result for each test case, wherein the first code is code to be put online;

[0013] a determination module, configured to determine a target test case based on the at least one test case and a first test result of each of the test cases, wherein the first test result of the target test case is failure;

[0014] An acquisition module is used to obtain an exception identifier corresponding to the target test case and determine a target scenario that matches the exception identifier;

[0015] A sending module is used to send a test report to a target device according to the target scenario, the target test case and the first code, wherein the test report includes statements covered by the target test case in the first code.

[0016] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0017] at least one processor; and

[0018] a memory communicatively connected to the at least one processor; wherein,

[0019] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the method according to the first aspect.

[0020] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect.

[0021] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising: a computer program, wherein the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program so that the electronic device executes the method described in the first aspect.

[0022] The technology according to the present disclosure solves the problem of time-consuming code testing.

[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings are used to better understand the present invention and do not constitute a limitation of the present invention.

[0025] Figure 1 A schematic diagram of the implementation of the test process provided in the embodiment of the present disclosure;

[0026] Figure 2 A flowchart of a code testing method provided in an embodiment of the present disclosure;

[0027] Figure 3 The process of the code testing method provided by the embodiment of the present disclosure Figure 2 ;

[0028] Figure 4 Schematic diagram of the relationship between the first test case and the second test case provided in the embodiment of the present disclosure Figure 1 ;

[0029] Figure 5 Schematic diagram of the relationship between the first test case and the second test case provided in the embodiment of the present disclosure Figure 2 ;

[0030] Figure 6 Schematic diagram of the relationship between the first test case and the second test case provided in the embodiment of the present disclosure Figure 3 ;

[0031] Figure 7 A schematic diagram of the correspondence between scenarios and abnormal identifications provided in an embodiment of the present disclosure;

[0032] Figure 8 This is a schematic diagram of the implementation of generating a test report introduced in the embodiment of the present disclosure Figure 1 ;

[0033] Figure 9 This is a schematic diagram of the implementation of generating a test report introduced in the embodiment of the present disclosure Figure 2 ;

[0034] Figure 10 This is a schematic diagram of the implementation of generating a test report introduced in the embodiment of the present disclosure Figure 3 ;

[0035] Figure 11 A flowchart of a code testing method provided in an embodiment of the present disclosure;

[0036] Figure 12 This is a schematic structural diagram of a code testing device according to an embodiment of the present disclosure;

[0037] Figure 13 It is a block diagram of an electronic device used to implement the code testing method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0038] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0039] In order to better understand the technical solutions of the present disclosure, the related technologies involved in the present disclosure are further introduced in detail below.

[0040] With the continuous development of computer technology, more and more projects based on computer technology have emerged, among which different projects can usually provide different services to users.

[0041] During the project development process, iterations are often necessary to update and improve the project. During this iteration, testing the code to be released is a crucial step to ensure the correctness, integrity, security, and quality of the project.

[0042] Testing is the process of reviewing or comparing actual output with expected output. The classic definition of testing is: the process of operating a program under specified conditions to discover program errors and evaluate whether it meets design requirements.

[0043] For example, you can combine Figure 1 Understand the implementation process of project testing, Figure 1 A schematic diagram of the implementation of the test process provided in the embodiment of the present disclosure.

[0044] like Figure 1 As shown, it is assumed that there is currently a project code to be tested, and it is assumed that there is currently a test case 1. In the test case 1, for example, input data and expected output may be included, where the expected output is the output that can be obtained by inputting the input data into the project code to be tested under expected circumstances.

[0045] Reference Figure 1 For example, the project code to be tested can be used to process the input data. After the project code to be tested is processed, Figure 1 The actual output is shown in . The actual output can then be compared with the expected output to get the test results.

[0046] Specifically, if the actual output is consistent with the expected output, the test result of test case 1 can be determined to be successful (test passed); if the actual output is inconsistent with the expected output, the test result of test case 1 can be determined to be failed (test failed).

[0047] Based on the code testing process described above, existing technologies typically rely on manual environment configuration and test execution when implementing code testing. Specifically, manual deployment triggering and scenario verification are required. When anomalies occur, quality assurance (QA) and research and development (RD) engineers are needed to manually locate the problem. RDs can locate the code themselves, while QA engineers need to determine the impacted business scenarios based on the failure scenario.

[0048] However, the implementation of manually triggered testing will result in the inability to quickly trigger regression verification and manually locate code anomalies, which will cause code testing to take a long time.

[0049] In response to the problems in the existing technology, the present disclosure proposes the following technical ideas: automatically triggering code testing, and for failed test cases, automatically matching abnormal scenarios and automatically reporting test reports. The test report can directly point out where the abnormal statements matched by the current test report are, so that code testing can be implemented quickly and efficiently, and abnormal problems can be located quickly and efficiently.

[0050] Based on the above introduction, the code testing method provided by the present disclosure is introduced below in conjunction with specific embodiments. It should be noted that the execution subject of each embodiment of the present disclosure can be, for example, a server, a processor, a microprocessor, a chip, or other device with data processing functions. The specific execution subject of each embodiment of the present disclosure is not limited and can be selected and set according to actual needs. As long as the device has data processing functions and data transmission and reception functions, it can serve as the execution subject of each embodiment of the present disclosure.

[0051] First combine Figure 2 To explain, Figure 2 A flowchart of a code testing method provided in an embodiment of the present disclosure.

[0052] like Figure 2 As shown, the method includes:

[0053] S201. Test a first code according to at least one test case to obtain a first test result for each test case, wherein the first code is the code to be put online.

[0054] In this embodiment, in order to realize automated testing of project code, for example, multiple test cases can be pre-set. In one possible implementation method, the preset multiple test cases should cover comprehensive testing of the respective situations of the project code. In the actual implementation process, the actual preset test cases can be selected and set according to actual needs, and this embodiment does not impose any restrictions on this.

[0055] Also, the first code in this embodiment is the code to be launched in the project. Based on the above introduction, it can be determined that during the iteration process of the project, the code to be launched needs to be verified. Then the current first code is actually the code that needs to be launched in the process of project iteration, so the first code needs to be tested.

[0056] Therefore, in this embodiment, the first code can be tested according to at least one test case, thereby obtaining a first test result for each test case, wherein the first test result can be success or failure.

[0057] Furthermore, for any test case, when the first code is tested according to the test case, the first code is actually used to process the input data in the test case to obtain an actual output, and then the actual output is compared with the expected output in the test case to obtain a first test result. The specific implementation method has been intercepted in the above embodiment and will not be repeated here.

[0058] S202: Determine a target test case according to at least one test case and a first test result of each test case, wherein the first test result of the target test case is failure.

[0059] After obtaining the first test results of each test case, for example, a target test case may be determined in at least one test case. In this embodiment, the first test result of the target test case is failure.

[0060] In one possible implementation, in this embodiment, for example, all test cases for which the first test result is failure may be determined as target test cases. Alternatively, some test cases for which the first test result is failure may be determined as target test cases, where some of the test cases may be test cases for which the test result is failure due to the code itself.

[0061] S203: Obtain an exception identifier corresponding to the target test case, and determine a target scenario that matches the exception identifier.

[0062] It is understandable that each test case in this embodiment obtains a first test result only after being processed by the first code, wherein the first test result may be a success or a failure.

[0063] For test cases where the first test result is a failure, it indicates that the actual output is different from the expected output, that is, the output of these test cases is abnormal. For example, the exception identifier corresponding to these test cases can be obtained. The exception identifier can be used to indicate the specific abnormality of the test case, such as whether the returned content is incorrect or the request is rejected, etc.

[0064] The exception identifier can be, for example, a string returned after running a test case, or a string corresponding to a preset test case. It is understood that each test case is designed for a specific testing purpose. For example, if a test case is designed to test whether the number of search results returned by a first code is a preset number, then if the first test result of the test case is a failure, it can be determined that the number of search results returned by the first code is not the preset number. For example, a preset string can be set to indicate this exception.

[0065] And in this embodiment, each abnormality mark can also be provided with a corresponding scenario, which is used to indicate what abnormal scenario the current abnormality mark corresponds to. For example, in the above example, the corresponding scenario can be the scenario of "abnormal number of returned results".

[0066] In this embodiment, after determining the target test case, for example, the exception identifier corresponding to the target test case can be obtained, and at the same time, the target scenario matching the exception identifier can be determined.

[0067] It should also be noted that although there is a direct correspondence between the exception identifier and the scenario, because the exception identifier is usually in the form of a string, it cannot intuitively express the current specific exception situation. Therefore, by determining the target scenario corresponding to the exception identifier, the current specific exception situation can be effectively and intuitively displayed.

[0068] S204: Send a test report to the target device according to the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code.

[0069] After determining the first test result of each test case, the test of the first code is actually completed, and the target scenario corresponding to the target test case is also determined, that is, the specific abnormality that has occurred is determined. The test report can be determined based on the target scenario, target test case and first code.

[0070] It's understandable that different test cases cover different statements in the code. The statements covered by a test case in the code are actually the parts of the code that the test case is testing. To quickly and effectively locate problematic parts of the code, one possible implementation method is to include the statements covered by the target test case in the first code in the test report.

[0071] Furthermore, the test report may also include, for example, target scenarios, target test cases, etc. This embodiment does not limit the specific content of the test report, and any content related to the test may be included in the test report.

[0072] After the test report is confirmed, it can be sent to the target device so that the relevant operators can quickly understand the current code test results and debug the code accordingly according to the test report to repair the abnormal parts in the code.

[0073] The code testing method provided by the disclosed embodiments includes: testing a first code according to at least one test case to obtain a first test result for each test case, wherein the first code is code to be released online; determining a target test case based on the at least one test case and the first test result of each test case, wherein the first test result of the target test case is a failure; obtaining an exception identifier corresponding to the target test case, and determining a target scenario that matches the exception identifier; sending a test report to a target device based on the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code; testing the first code to be released online using preset test cases to obtain a first test result for each test case; and, based on the target test case for which the first test result is determined to be a failure in the test case, determining the target scenario of the current exception based on the exception identifier corresponding to the target test case, and sending a test report to the target device, wherein the test report includes statements covered by the target test case in the first code, thereby effectively implementing automatic testing of the code and quickly locating the abnormal portion of the code, thereby effectively shortening the time required for code testing.

[0074] Based on the above introduction, the following Figures 3 to 7 The code testing method provided by this disclosure is further introduced in detail. Figure 3 The process of the code testing method provided by the embodiment of the present disclosure Figure 2 , Figure 4 Schematic diagram of the relationship between the first test case and the second test case provided in the embodiment of the present disclosure Figure 1 , Figure 5 Schematic diagram of the relationship between the first test case and the second test case provided in the embodiment of the present disclosure Figure 2 , Figure 6 Schematic diagram of the relationship between the first test case and the second test case provided in the embodiment of the present disclosure Figure 3 , Figure 7 A schematic diagram of the correspondence between scenarios and exception identifiers provided in an embodiment of the present disclosure.

[0075] like Figure 3 As shown, the method includes:

[0076] S301. Test a first code according to at least one test case to obtain a first test result for each test case, wherein the first code is the code to be put online.

[0077] The implementation of S301 is similar to that of S201 and will not be described in detail here.

[0078] S302: Test the second code according to at least one test case to obtain a second test result for each test case, wherein the second code is an online code.

[0079] In this embodiment, after testing the first code and obtaining the first test results of each test case, there may be test cases whose first test results are failures. In order to determine whether these failed test cases are caused by the project itself or by data, the second code will also be tested according to at least one test case in this embodiment.

[0080] Among them, the second code is the code that has been put into use, that is, the second code is the code that has been put into use. Based on the above introduction, it can be determined that the first code is the code that is currently to be put into use. Therefore, the first code and the second code in this embodiment are different codes. It can be understood that the first code is a code that has been iteratively updated based on the second code.

[0081] To determine whether a problem exists within the code itself after code iteration, after testing the first code using at least one test case, the second code may also be tested using at least one test case. It should be noted that the test cases used to test the first code and the second code are identical.

[0082] Among them, testing the first code according to at least one test case can be understood as offline testing, and testing the second code according to at least one test case can be understood as online testing.

[0083] Specifically, by testing the second code according to at least one test case, a second test result of each test case can be obtained. Similarly, the second test result can be success or failure.

[0084] S303: Determine the test case whose first test result is failure as the first test case, and determine the test case whose second test result is failure as the second test case.

[0085] After testing the first code and obtaining the first test result and the second test result for each test case, a test case with a failed test result can be selected from the test cases. In one possible implementation, for example, a test case with a failed first test result can be determined as the first test case, and a test case with a failed second test result can be determined as the second test case.

[0086] S304: Determine the intersection of the first test case and the second test case as the third test case.

[0087] The currently determined first test case is a failed test case corresponding to the first code, and the second test case is a failed test case corresponding to the second code. In this embodiment, the intersection of the first test case and the second test case can be determined as a third test case. The third test case is a test case that failed in the test for the first code and also failed in the test for the second code.

[0088] The following describes the possible relationship between the first test case and the second test case, and the corresponding implementation of determining the third test case, with reference to the diagram.

[0089] In one possible implementation, referring to Figure 4 Assume that there are multiple first test cases, namely Test Case 1, Test Case 2, Test Case 3, Test Case 4, and Test Case 5, and the second test case is empty. This means that there are failure cases in the offline test of the first code, but there are no failure cases in the online test of the second code.

[0090] In this case, it can be understood that the test cases all pass the test in the second code that has not been iterated, but there are cases where the test fails in the first code after iteration. Then it is possible that errors or exceptions were introduced into the first code during the code iteration process, and further processing is required for the failed test cases corresponding to the first code.

[0091] In this case, the determined intersection of the first test case and the second test case is actually empty, that is, the third test case is empty.

[0092] In another possible implementation, referring to Figure 5 , assuming that there are multiple first test cases and multiple second test cases, and the first test cases and the second test cases are exactly the same, for example Figure 5 In the example, the first test case and the second test case are both Test Case 1, Test Case 2, Test Case 3, Test Case 4, and Test Case 5. This means that there are failure cases in the offline test for the first code, and there are also failure cases in the online test for the second code, and the test cases that fail in the online and offline tests are exactly the same.

[0093] In this case, it can be understood that the failed test cases corresponding to the first code and the failed test cases corresponding to the second code are exactly the same, which indicates that the problem is not caused by code iteration, but may be a problem with the data that the code depends on, or there may be a problem with the design of the test case.

[0094] In this case, the intersection of the first test case and the second test case is actually the first test case, that is, the third test case is equal to the first test case. For example, Figure 5 In the example, the third test case includes test case 1, test case 2, test case 3, test case 4, and test case 5.

[0095] Because the test failure in this case isn't caused by a code issue, the test results of the failed test case can be manipulated, for example. For example, the first test result of the third test case can be modified to success, and a test report can be sent to the target device. The test report also includes first indication information, indicating that the result of the third test case has been modified. After receiving this test report, relevant personnel can determine that an anomaly occurred during the test and that modifications have been made to the anomaly's results. They can then conduct appropriate checks on the data, test cases, and so on.

[0096] In another possible implementation, referring to Figure 6 , suppose there are multiple first test cases and multiple second test cases, and the first test cases and the second test cases are not exactly the same, for example Figure 5 , the first test cases are test case 1, test case 4 and test case 3, and the second test cases are test case 2, test case 3 and test case 5.

[0097] That is to say, there are failed test cases in the offline test of the first code, and there are failed test cases in the online test of the second code. The test cases in which the online test and the offline test fail are partially the same and partially different, and are not exactly the same.

[0098] In this case, it can be understood that the failed test case corresponding to the first code is not exactly the same as the failed test case corresponding to the second code, so the same parts are similar to the above Figure 5 This indicates that the problem is not caused by code iteration, but may be a problem with the data that the code depends on, or a problem with the design of the test case. The different parts are similar to the above Figure 4 This indicates that the problem is caused by code iteration.

[0099] In this case, the intersection of the first test case and the second test case is actually the test case that fails in both the first code test and the second code test. Figure 6 In the example, the third test case includes test case 3.

[0100] Based on the above Figures 4 to 6 It can be determined from the introduction that what needs to be paid attention to at present is the difference between the first test case and the second test case. In order to determine the difference, for example, the intersection of the first test case and the second test case can be first determined to obtain the third test case.

[0101] S305: Determine the test cases in the first test case except the third test case as target test cases.

[0102] Because what we need to focus on currently is the difference between the first test case and the second test case, and the above-mentioned third test case is the intersection of the first test case and the second test case, after determining the third test case, the test cases in the first test case except the third test case can be determined as target test cases. The target test case here is actually the test case of the difference between the first test case and the second test case.

[0103] For example, in the above Figure 4 In the example, since there is no intersection, the target test cases are test case 1, test case 2, test case 3, test case 4, and test case 5; Figure 5 In the example, since there is no difference, the target test case is empty; and in the above Figure 6 In the example, the target test cases for the difference are test case 1 and test case 4.

[0104] It should be noted that the several situations introduced above are all for the case where the first test result of the first code fails. This is because subsequent operations will only be performed when there is a failed test case in the first code. If there is no failed test case in the first code, it means that all test cases of the first code have passed, and there is no need to perform subsequent exception search operations.

[0105] At the same time, based on the above introduction, it can be determined that in this embodiment, both offline testing of the first code and online testing of the second code are performed. Then, based on the first test result of the online test and the second test result of the offline test, the target test cases that failed the test for the first code but succeeded in the test for the second code are determined. Therefore, it is possible to effectively filter out test cases that failed the test due to code iteration from multiple test cases, and then process the target test cases, thereby effectively reducing the workload of test processing and improving the efficiency of test processing.

[0106] S306: Obtain an exception identifier corresponding to the target test case, and determine a target scenario that matches the exception identifier.

[0107] The implementation of S306 is similar to that of S203 above, and will not be described in detail here.

[0108] The following combination Figure 7 This paper introduces several possible implementation methods of exception identification and corresponding scenarios, such as Figure 7 As shown, for example, multiple corresponding relationships between abnormal identification and scenarios can be set.

[0109] Assume that the current project a is used to filter suitable houses according to conditions. Figure 7 Eight scenarios are listed as examples for project a.

[0110] Among them, scenario one is a constant change, and its corresponding exception identifier can be, for example, exception identifier 1. The exception identifier in this embodiment is usually a string, so exception identifier 1 can be, for example, "title is wrong". Then, when it is determined that the exception identifier corresponding to a test case is "title is wrong", it can be determined that the currently matched scenario is scenario one "constant change".

[0111] Also, scenario two is a service panic, and its corresponding exception identifier can be, for example, exception identifier 2, and exception identifier 2 can be, for example, "HTTP Error 500". Then, when it is determined that the exception identifier corresponding to a test case is "HTTP Error 500", it can be determined that the currently matched scenario is scenario two "service panic".

[0112] Also, scenario three is that a large number of requests are rejected, and its corresponding exception identifier may be, for example, exception identifier 3, which may be, for example, "connection refused". Then, when it is determined that the exception identifier corresponding to a test case is "connection refused", it can be determined that the currently matched scenario is scenario three "a large number of requests are rejected".

[0113] Also, scenario four is no recall, and its corresponding exception identifier can be, for example, exception identifier 4, and exception identifier 4 can be, for example, "housing_resources is empty". Then, when it is determined that the exception identifier corresponding to a test case is "housing_resources is empty", it can be determined that the currently matched scenario is scenario four "no recall".

[0114] Also, scenario five is a recommended state exception, and its corresponding exception identifier can be, for example, exception identifier 5, and exception identifier 5 can be, for example, "wrong rec_flag_type". Then, when it is determined that the exception identifier corresponding to a test case is "wrong rec_flag_type", it can be determined that the currently matched scenario is scenario five "recommended state exception".

[0115] Also, scenario six is ​​the recall price anomaly, and its corresponding anomaly identifier can be, for example, anomaly identifier 6, and anomaly identifier 6 can be, for example, "wrong price". Then, when it is determined that the anomaly identifier corresponding to a test case is "wrongprice", it can be determined that the currently matched scenario is scenario six "recall price anomaly".

[0116] Also, scenario seven is a recall time anomaly, and its corresponding anomaly identifier can be, for example, anomaly identifier 7, and anomaly identifier 7 can be, for example, "wrong commuting_time". Then, when it is determined that the anomaly identifier corresponding to a test case is "wrong commuting_time", it can be determined that the currently matched scenario is scenario seven "recall time anomaly".

[0117] Also, scenario eight is an abnormal housing community type, and its corresponding abnormal identifier can be, for example, abnormal identifier 8, and abnormal identifier 8 can be, for example, "wrong data_type". Then, when it is determined that the abnormal identifier corresponding to a test case is "wrong data_type", it can be determined that the currently matched scenario is scenario eight "abnormal housing community type".

[0118] Furthermore, there may be many other possible scenarios, and the specific scenario settings and the abnormal identification corresponding to the scenario can be selected according to actual needs.

[0119] At the same time, in this embodiment, a corresponding annotation code can be set for each scenario, and the annotation code can be returned to the target device together with the test report. In this way, the corresponding operator can quickly determine which is the current abnormal scenario by checking the annotation code.

[0120] It should also be noted that the exception identifier described above can be stored in the log data corresponding to the test case, for example. It can be a field in the test case log data, or it can be a corresponding identifier preset by the test case to indicate the abnormal situation reflected when the current test case fails. Alternatively, it can be an identifier returned by the first code after running the first code. This embodiment does not impose any restrictions on this, and it can be selected and set according to actual needs.

[0121] Based on the above introduction, it can be determined that the current abnormal situation cannot be intuitively expressed by simply determining the abnormality mark. Therefore, it is also necessary to determine the target scenario corresponding to the abnormality mark, so as to quickly and intuitively determine what specific abnormal situation has occurred.

[0122] S307: Send a test report to the target device according to the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code.

[0123] After the target scenario is determined, in this embodiment, a test report can be sent to the target device according to the target scenario, the target test case, and the first code.

[0124] The test report includes statements covered by the target test case in the first code. Furthermore, in a possible implementation, the test report in this embodiment may further include, for example, at least one of the following: The test report also includes at least one of the following: an identifier of the target test case, execution information of the target test case, an identifier of the target scenario, and an exception identifier corresponding to the target test case.

[0125] Among them, the running information of the target test case may include, for example, the input information of the target test case, the expected output of the target test case, the actual output of the target test case, the running log data of the target test case, the debugging information of the target test case, etc. This embodiment does not limit the running information of the target test case. Any information related to the running of the target test case can be used as the running information in this embodiment.

[0126] In addition, the information included in the test report may include, for example, the branch to which the first code tested belongs, the list of operators who submitted the first code, etc. This embodiment also does not limit the specific implementation of the test report, which can be selected and set according to actual needs.

[0127] The code testing method provided by the embodiment of the present disclosure performs offline testing on the first code through preset test cases to obtain first test results for each test case, and when there are failed test cases in the test of the first code, the second code is tested online through the preset test cases at the same time to obtain second test results for each test case, and then, based on the first test result and the second test result, a target test case is determined in which the test results of the test for the first code and the test for the second code have a difference set, that is, the test for the target test case fails for the first code, but succeeds for the test for the second code, so that the test cases that fail due to code iteration can be preliminarily screened out from multiple failed test cases, and then the corresponding target scenarios are determined for the screened target test cases, and corresponding test reports are generated, so that the automated testing of the first code can be effectively realized, and the workload of code testing can be effectively reduced, the efficiency of code testing can be further improved, and the time consumption of code testing can be reduced.

[0128] Based on the contents introduced in the above embodiments, the code testing method provided by the present disclosure has different processing logic for generating test reports in different target scenarios. Therefore, the following describes the implementation methods for generating test reports in several different types of target scenarios in combination with diagrams.

[0129] First combine Figure 8 This section introduces the implementation of generating test reports in the first type of scenario. Figure 8 This is a schematic diagram of the implementation of generating a test report introduced in the embodiment of the present disclosure Figure 1 .

[0130] like Figure 8 As shown, the first type of scenario may include, for example: the result returned according to the query condition is empty.

[0131] Among them, the query condition can be, for example, a query condition preset in the input data in the test case. After the first code performs a corresponding query based on the query condition, the result returned is empty, which means that the actual output is empty. Because there is a preset output in the test case, the preset output is not empty, so it can be determined that the test result of the current target test case is failure.

[0132] like Figure 8As shown, if it is determined that the current target scenario is that the result returned according to the query condition is empty, that is, scenario four introduced in the above example, then, for example, the user identifier in the input data of the test case can be obtained first, and then the recall data and filter data corresponding to the user identifier can be obtained in the log data, wherein the recall data is a plurality of results recalled according to the query condition, and the filter data is the result filtered out in the recall data according to the corresponding filter condition. It can be understood that the difference between the recall data and the filter data is actually the result returned by the first code. After determining the recall data, filter data and returned results, this information can be temporarily stored to be returned to the corresponding device in a subsequent test report.

[0133] Furthermore, for the abnormal situation where the returned result is empty, this embodiment can also obtain the first target statement covered by the current target test case, and determine whether the filtering condition or the recall condition is updated in the first target statement.

[0134] In one possible implementation, if it is determined that the recall condition or the filtering condition has been updated in the first target statement, it can be determined that the failure of the current target test case is as expected, that is, it can be determined that the failure of the target test case is caused by the update of the first target statement.

[0135] However, the update of the first target statement here may cause the target test case to fail in the following two situations:

[0136] Case 1: There are problems with the updated code itself, such as problems with the code logic, or there may be function errors or input errors when writing the code;

[0137] Case 2: There is no problem with the writing of the updated code itself, that is, the first code is currently determined to perform such an update. It is normal for the result returned by the current first code to be empty. In this case, the data of the target test case should be updated.

[0138] In order to distinguish which of the above situations it is, in this embodiment, for example, a confirmation message can be sent to the communication interface corresponding to rd to check whether there is a writing problem in the first target statement covered by the rd target test case, after receiving the confirmation message returned by rd.

[0139] If the confirmation information is an exception confirmation information, it means that rd determines that the first target statement covered by the current target test case is problematic. In this case, a test report can be sent to the target device. In addition to the content introduced above, the test report can also include, for example, the exception confirmation information returned by rd, recall data, filtered data, and returned results, etc.

[0140] Alternatively, if the confirmation information is normal confirmation information, it means that rd determines that there is no writing problem in the first target statement covered by the current target test case, that is, it is normal for the result returned by the current first code to be empty. In this case, for example, the test result of the target test case can be intervened, the test result of the target test case can be modified to success, and a test report can be sent to the target device. The test report can also include indication information, wherein the indication information is used to indicate that the result of the target test case has been modified.

[0141] In another possible implementation, if it is determined that the filtering conditions and recall conditions have not been updated in the first target statement, it can be determined that the returned result is empty based on the original filtering conditions and recall conditions. This situation can be determined to be inconsistent with expectations, so it can be determined that it is a code failure (bug), and a test report can be sent directly to the target device.

[0142] The above introduces a possible implementation method of the first type of scenario. The first type of scenario in this embodiment can be described as: it can be determined that the corresponding statement in the first code is updated, but it cannot be determined whether the update of the statement is the desired update, and further judgment is required.

[0143] Secondly, combined Figure 9 This section introduces the implementation of generating test reports in the second type of scenario. Figure 9 This is a schematic diagram of the implementation of generating a test report introduced in the embodiment of the present disclosure Figure 2 .

[0144] like Figure 9 As shown, the second type of scenario includes at least one of the following: the number of results returned according to the query condition is less than a preset number, the results returned according to the query condition do not meet the query condition, and the returned constant is different from the expected constant.

[0145] Reference Figure 9 If the current target scenario is determined to be that the number of results returned according to the query conditions is less than the preset number, that is, scenario 5 introduced in the above example, the number of results returned according to the query conditions is less than the preset number. For example, normally 4 recommended results should be returned, but only one recommended result is currently returned.

[0146] In this case, it can be determined whether the first result returned is of the preset type, because in the design of this embodiment, if the first result returned is of the preset type, it is normal for the number of results returned according to the query conditions to be less than the preset number.

[0147] For example, if the current project is used to search for suitable housing sources based on input conditions, the preset type may be, for example, a community with no housing sources. If, for example, the first one returned is a community with no housing sources, it is normal that the number of housing source results obtained based on the query conditions does not meet the preset number of 4. In this case, the number of returned housing sources is usually only 1.

[0148] Therefore, in one possible implementation method, if it is determined that the first result returned is of a preset type, it can be determined that there is no problem with the actual output of the current target test case, so the test result of the target test case can be intervened, the test result of the target test case can be modified to success, and a test report can be sent to the target device. The test report can also include a second indication information, wherein the second indication information is used to indicate that the result of the target test case has been modified.

[0149] And in another possible implementation, if it is determined that the first result returned is not of the preset type, then it can be determined that it is abnormal that the current number of results returned according to the query conditions is less than the preset number, that is, it is determined that the target test case is indeed a failed result, and the test report can be sent directly to the target device.

[0150] and reference Figure 9 If the current target scenario is determined to be a constant that is different from the expected constant, that is, scenario 1 described in the above example, for example, some constant information such as "No relevant results yet, recommending communities and properties with similar conditions for you" does not meet expectations, the specific constant information can be determined based on actual needs.

[0151] In this case, the second target statement covered by the target test case in the first code can be obtained. The second target statement includes the above-mentioned preset constant to be returned, and then it can be determined whether the returned constant is the same as the preset constant in the second target statement.

[0152] In one possible implementation, if the return constant is determined to be the same as the preset constant in the second target statement, then there is no problem with the output of the current return constant. It is possible that the preset constant in the second target statement has been updated, causing the return constant to be different from the expected constant. Therefore, in this case, the test result of the target test case can be intervened, the test result of the target test case can be modified to success, and a test report can be sent to the target device. The test report can also include second indication information, where the second indication information is used to indicate that the result of the target test case has been modified.

[0153] And in another possible implementation, if it is determined that the return constant is different from the preset constant in the second target statement, it means that the current return constant is not different from the expected constant due to the update of the second target statement. Then it can be determined that the current return constant is different from the expected constant, which is itself abnormal. In other words, it is determined that the target test case is indeed a failure result, and the test report can be sent directly to the target device.

[0154] and reference Figure 9 If it is determined that the current target scenario is that the results returned according to the query conditions do not meet the query conditions, that is, scenarios 6 and 7 introduced in the above example, for example, for recall price anomalies, that is, the houses recalled according to the input conditions are not within the selected price range of the input conditions; and for example, for recall time anomalies, that is, the houses recalled according to the input conditions are not within the selected time range of the input conditions.

[0155] In this case, the second target statement covered by the target test case in the first code can be obtained. The second target statement includes the specific processing logic of the above-mentioned recall. There is a type of recall processing called multi-scheme recall, in which multi-scheme recall refers to selecting multiple types of results for recall based on the input conditions.

[0156] For example, if the current input conditions are a price of 5,000 yuan and a commute time of less than 20 minutes, then properties will be screened based on these conditions. Multi-option recall, however, means that based on the price of 5,000 yuan and the commute time of less than 20 minutes, possible transportation methods include walking, driving, taxi, public transportation, etc., and these transportation methods are combined to filter out properties that meet the conditions based on the price of 5,000 yuan and the commute time of 20 minutes.

[0157] Therefore, in this embodiment, after obtaining the second target sentence covered by the test case, it can be determined whether the second target sentence contains a multi-solution recall.

[0158] In one possible implementation, if the second target statement contains multiple recall options, it may be further determined whether the recall threshold in the second target statement has changed. For example, the recall threshold may include the aforementioned options of driving, public transportation, walking, etc. The recall threshold can be designed based on actual scenarios and needs, as long as multiple possible options are provided for filtering the returned results.

[0159] Among them, if it is determined that the recall preset in the second target statement has changed, it can be determined that the result returned by the current query condition does not meet the query condition because of the change in the recall preset. For example, the original recall preset was set to public transportation and walking, and then the recall preset changed to public transportation and driving. It can be understood that the housing resources that can be reached within 20 minutes of walking and the housing resources that can be reached within 20 minutes of driving must be different, so the actual result currently returned will be different from the expected result (the expected result is set according to the original recall preset), which will cause the test result of the current target test case to fail. Therefore, in response to this situation, it is necessary to intervene in the test result of the target test case, modify the test result of the target test case to be successful, and send a test report to the target device. The test report can also include a second indication information, wherein the second indication information is used to indicate that the result of the target test case has been modified.

[0160] In another possible implementation, if the second target statement does not contain a multi-solution recall, it means that the current result returned based on the query conditions must meet the query conditions, which is a normal phenomenon. Therefore, in this case, it can be determined that the test result of the current target test case is a failure, and then the test report can be sent directly to the target device.

[0161] Based on the above introduction, it can be determined that for the second type of scenario, when it is determined that the returned result matches the second target statement, the result of the target test case can be intervened; when the returned result does not match the second target statement, the test report can be sent directly.

[0162] Among them, the return result matches the second target statement, which means that the return result satisfies the output corresponding to the second target statement. That is to say, if the result is output according to the current second target statement, the output is exactly the current return result.

[0163] Secondly, combined Figure 10 This chapter introduces the implementation of generating test reports in the third type of scenario. Figure 10 This is a schematic diagram of the implementation of generating a test report introduced in the embodiment of the present disclosure Figure 3 .

[0164] like Figure 10 As shown, the third type of scenario includes at least one of the following: the number of rejected requests is greater than a preset threshold, and the service fails.

[0165] Reference Figure 10 If the number of rejected requests in the current target scenario is greater than the preset threshold, that is, scenario 3 described in the above example, where a large number of requests are rejected, a service anomaly can be directly determined, and a test report can be sent to the target device. In this case, when sending the test report, for example, it is sent to the relevant personnel responsible for quality assurance.

[0166] And, refer to Figure 10 If the current target scenario is determined to be a service failure (panic), which is the second scenario described in the above example, the first code bug can be directly determined, and then a test report can be sent to the target device. In this case, when sending the test report, for example, the test report is sent to the relevant person in charge of Rd.

[0167] The above describes several different implementations of generating and sending test reports in different scenarios. In one possible implementation, the running information of the target test case included in the test report described above may be stored in a target link, for example.

[0168] For example, after determining the various information introduced above, you can determine the correspondence between the target test case and the target scenario, and then generate a target link for the correspondence between the target test case and the target scenario. By opening the target link, you can obtain the correspondence between the target test case and the target scenario, as well as the running information of the target test case.

[0169] In the test report, the title of the test report may include, for example: the branch to which the first code belongs, the identifier of the failed target test case, the target scenario, the stage at which the problem was discovered, and the triggering person, for example: triggering branch (master)_failed case (:search_house_zhengzhou_walk")_scenario for reporting the problem (service panic)_stage at which the problem was discovered (access stage)_triggering person (xx). In the specific task result feedback, for example, the following information may be displayed:

[0170] "xx, one rental automation case failed, deployed branch = xique-407. There were no cases caused by data failure, all failures were caused by the project itself. For the correspondence between failed cases and business scenarios, see: aaa.html". Among them, aaa.html is the target link. Relevant operators can view the contents of the relevant test report by opening the target link.

[0171] In this embodiment, there is no limitation on the specific implementation of the test report. As long as the test report can include the relevant content introduced above, the specific display method can be selected and set according to actual needs.

[0172] Based on the above introduction, it can be determined that in this embodiment, corresponding logic for generating and sending test reports is set for different scenarios, so that the automatic triggering generation, automatic sending, and automatic positioning of code abnormalities of test reports can be comprehensively and quickly realized for a variety of different situations, thereby quickly and effectively implementing the test of the first code, effectively shortening the time spent on code testing.

[0173] In the code testing method provided by the present invention, the submission (marge) of the code is also monitored. When the submission of the code is monitored, the configuration of the environment corresponding to the code can be automatically triggered, and then the code testing process introduced above is automatically executed based on the configured environment, so that the entire process of code testing can be effectively automatically triggered, further reducing the degree of manual intervention and shortening the time consumption of code testing.

[0174] Based on the above introduction, the following Figure 11 The overall implementation process of the code testing method provided by this disclosure is further introduced. Figure 11 A flowchart of a code testing method provided in an embodiment of the present disclosure.

[0175] like Figure 11 As shown, the code testing method provided in this embodiment can automatically monitor the code branches, that is, monitor the submitted code, and after monitoring the submitted code, automatically deploy the environment. The specific implementation of monitoring branches and environment deployment can also be understood as Figure 11 The steps of code submission, compilation output, code scanning, and code release are shown in .

[0176] After the environment is deployed, the code can be tested. The first code is tested based on multiple preset test cases, and then the test cases are located.

[0177] In test case location, we first conduct a preliminary judgment strategy. In this preliminary judgment strategy, we can determine the intersection of online testing (corresponding to the second code) and offline testing (corresponding to the first code). The intersection determined here corresponds to the three situations described above.

[0178] The first case is that the failure cases of online testing and offline testing are completely different, and the intersection is empty. In this case, it can be determined that the failure case is caused by the project and needs to be specifically handled in subsequent scenario positioning.

[0179] The second situation is that the failure cases of online testing and offline testing are exactly the same, and the intersection is the failure case of offline testing. In this case, it can be determined that the failure case is not caused by the project, and the test results of the failure case can be intervened.

[0180] The third situation is that the failure cases of online and offline tests are partially the same and partially different. In this case, it can be determined that the different difference parts are caused by the project, and then subsequent scenario positioning processing is performed on the different difference parts.

[0181] In the positioning of the content introduced above, the failure case that needs to be processed for scene positioning is actually the target test case introduced in the above embodiment. Then, by determining the target scene corresponding to the target test case and performing corresponding processing according to the processing logic corresponding to different scenes, a scene positioning test report is generated.

[0182] After the test report is generated, the result notification can be carried out, that is, the test report is sent to the target device. The abnormal location in the code can be automatically marked in the result notification and automatically reported to the corresponding communication interface, so as to realize the automation of code testing to the greatest extent.

[0183] In summary, the code testing method provided by the present disclosure adopts the idea of ​​micro-testing, which can provide real-time testing and real-time feedback for code changes, and can provide auxiliary positioning information for abnormal scenarios, solving the problem of time-consuming troubleshooting. Combined with the automatic monitoring mechanism of the on-site pipeline, it monitors code changes, automatically triggers deployment and scene regression, solves the process of human participation, and achieves non-perceptible triggering; it also adds auxiliary positioning capabilities after scene regression, reduces the time investment of manual troubleshooting, and automatically reports abnormal problems; and after the automatic test is completed, the results are automatically transmitted back to the students who modified the code in real time, achieving a micro-test closed loop.

[0184] Figure 12 FIG. 1 is a schematic diagram of the structure of the code testing device according to an embodiment of the present disclosure. Figure 12 As shown, the code testing device 1200 of this embodiment may include: a processing module 1201 , a determining module 1202 , an acquiring module 1203 , and a sending module 1204 .

[0185] The processing module 1201 is configured to test a first code according to at least one test case to obtain a first test result for each test case, wherein the first code is the code to be put online;

[0186] A determination module 1202 is configured to determine a target test case based on the at least one test case and a first test result of each of the test cases, wherein the first test result of the target test case is failure;

[0187] An acquisition module 1203 is configured to acquire an exception identifier corresponding to the target test case and determine a target scenario that matches the exception identifier;

[0188] The sending module 1204 is configured to send a test report to a target device according to the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code.

[0189] In a possible implementation, the determining module 1202 is specifically configured to:

[0190] Testing the second code according to the at least one test case to obtain a second test result for each test case, wherein the second code is an online code;

[0191] Determine the test case for which the first test result is a failure as a first test case, and determine the test case for which the second test result is a failure as a second test case;

[0192] A target test case is determined according to the first test case and the second test case.

[0193] In a possible implementation, the determining module 1202 is specifically configured to:

[0194] Determine the intersection of the first test case and the second test case as a third test case;

[0195] The test cases in the first test cases, excluding the third test case, are determined as the target test cases.

[0196] In a possible implementation, the processing module 1201 is further configured to:

[0197] After determining the intersection of the first test case and the second test case as the third test case, the first test result of the third test case is modified to success, and a test report is sent to the target device, wherein the test report also includes first indication information, wherein the first indication information is used to indicate that the result of the third test case has been modified.

[0198] In a possible implementation, the sending module 1204 is specifically configured to:

[0199] If the target scenario is of the first type, obtaining a first target statement covered by the target test case in the first code;

[0200] If the filtering condition or the recall condition is updated in the first target statement, after receiving abnormality confirmation information for the updated filtering condition or the recall condition, sending a test report to the target device;

[0201] If the filtering condition and the recall condition are not updated in the first target statement, the test report is directly sent to the target device;

[0202] The first type of scenario includes at least one of the following: the result returned according to the query condition is empty.

[0203] In a possible implementation, the sending module 1204 is specifically configured to:

[0204] If the target scenario is of the second type, obtaining a second target statement covered by the target test case in the first code;

[0205] Obtain the return result corresponding to the target test case;

[0206] Sending a test report to a target device according to the returned result and the target statement;

[0207] Among them, the second type of scenario includes at least one of the following: the number of results returned according to the query condition is less than a preset number, the results returned according to the query condition do not meet the query condition, and the returned constant is different from the expected constant.

[0208] In a possible implementation, the sending module 1204 is specifically configured to:

[0209] If the returned result matches the second target statement, the result of the target test case is modified to success, and a test report is sent to the target device, wherein the test report also includes second indication information, wherein the second indication information is used to indicate that the result of the target test case has been modified.

[0210] If the returned result does not match the second target statement, a test report is directly sent to the target device.

[0211] In a possible implementation, the sending module 1204 is specifically configured to:

[0212] If the target scenario is the third type, directly sending a test report to the target device;

[0213] The third type of scenario includes at least one of the following: the number of rejected requests is greater than a preset threshold, and service failure.

[0214] In a possible implementation, the test report further includes at least one of the following: an identifier of the target test case, running information of the target test case, an identifier of the target scenario, and an exception identifier corresponding to the target test case.

[0215] The present disclosure provides a code testing method and apparatus, which are applied to the field of code testing in computer technology to achieve the purpose of shortening the time consumption of code testing.

[0216] It should be noted that the head model in this embodiment is not a head model for a specific user and cannot reflect the personal information of a specific user. It should be noted that the two-dimensional face image in this embodiment comes from a public data set.

[0217] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0218] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0219] According to an embodiment of the present disclosure, the present disclosure also provides a computer program product, which includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above embodiments.

[0220] Figure 13 A schematic block diagram of an example electronic device 1300 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0221] like Figure 13As shown, device 1300 includes a computing unit 1301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1302 or a computer program loaded from a storage unit 1308 into a random access memory (RAM) 1303. Various programs and data required for the operation of device 1300 can also be stored in RAM 1303. Computing unit 1301, ROM 1302, and RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to bus 1304.

[0222] Various components in device 1300 are connected to I / O interface 1305, including an input unit 1306, such as a keyboard and mouse; an output unit 1307, such as various types of displays and speakers; a storage unit 1308, such as a magnetic disk and optical disk; and a communication unit 1309, such as a network card, a modem, a wireless communication transceiver, etc. Communication unit 1309 allows device 1300 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0223] The computing unit 1301 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1301 performs the various methods and processes described above, such as the code testing method. For example, in some embodiments, the code testing method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as the storage unit 1308. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 1300 via the ROM 1302 and / or the communication unit 1309. When the computer program is loaded into the RAM 1303 and executed by the computing unit 1301, one or more steps of the code testing method described above can be performed. Alternatively, in other embodiments, the computing unit 1301 can be configured to perform the code testing method by any other appropriate means (e.g., by means of firmware).

[0224] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0225] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0226] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0227] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0228] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0229] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. This client-server relationship is established by computer programs running on the respective computers, establishing a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosts and VPS services ("Virtual Private Servers" or simply "VPS"). The server may also be a server in a distributed system or a server integrated with blockchain.

[0230] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0231] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A code testing method, comprising: Testing the first code according to at least one test case to obtain a first test result for each test case, wherein the first code is the code to be put online; When the first test result includes a failed test case, testing the second code according to the at least one test case to obtain a second test result for each of the test cases, wherein the second code is the code that has been put online; and the first code is the code that is iteratively updated based on the second code; Determine the test case with a first test result of failure as a first test case, and determine the test case with a second test result of failure as a second test case; Determine the intersection of the first test case and the second test case as a third test case; Determining the test cases in the first test cases, excluding the third test case, as target test cases; Obtaining an exception identifier corresponding to the target test case and determining a target scenario that matches the exception identifier; the target scenario is used to reflect the abnormal situation; Sending a test report to a target device according to the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code; After determining the intersection of the first test case and the second test case as a third test case, the method further includes: The first test result of the third test case is modified to success, and a test report is sent to the target device, wherein the test report also includes first indication information, wherein the first indication information is used to indicate that the result of the third test case is modified.

2. The method according to claim 1, wherein Sending a test report to a target device according to the target scenario, the target test case, and the first code includes: If the target scenario is of the first type, obtaining a first target statement covered by the target test case in the first code; If the filtering condition or the recall condition is updated in the first target statement, after receiving abnormality confirmation information for the updated filtering condition or the recall condition, sending a test report to the target device; If the filtering condition and the recall condition are not updated in the first target statement, the test report is directly sent to the target device; The first type of scenario includes at least one of the following: the result returned according to the query condition is empty.

3. The method according to claim 1, wherein Sending a test report to a target device according to the target scenario and the first code includes: If the target scenario is of the second type, obtaining a second target statement covered by the target test case in the first code; Obtain the return result corresponding to the target test case; Sending a test report to the target device according to the returned result and the second target statement; Among them, the second type of scenario includes at least one of the following: the number of results returned according to the query condition is less than a preset number, the results returned according to the query condition do not meet the query condition, and the returned constant is different from the expected constant.

4. The method according to claim 3, wherein: Sending a test report to the target device according to the returned result and the second target statement, including: If the returned result matches the second target statement, modifying the result of the target test case to success, and sending a test report to the target device, wherein the test report also includes second indication information, wherein the second indication information is used to indicate that the result of the target test case has been modified; If the returned result does not match the second target statement, a test report is directly sent to the target device.

5. The method according to claim 1, wherein Sending a test report to a target device according to the target scenario and the first code includes: If the target scenario is the third type, directly sending a test report to the target device; The third type of scenario includes at least one of the following: the number of rejected requests is greater than a preset threshold, and service failure.

6. The method according to claim 1, wherein the test report further includes at least one of the following: an identifier of the target test case, running information of the target test case, an identifier of the target scenario, and an exception identifier corresponding to the target test case.

7. A code testing device comprising: a processing module, configured to test a first code according to at least one test case to obtain a first test result for each test case, wherein the first code is code to be put online; a determination module configured to, when the first test result includes a failed test case, test the second code according to the at least one test case to obtain a second test result for each of the test cases, wherein the second code is an already-released code; and the first code is an iteratively updated code based on the second code; Determine the test case for which the first test result is a failure as a first test case, and determine the test case for which the second test result is a failure as a second test case; Determine the intersection of the first test case and the second test case as a third test case; Determine target test cases from the first test cases, excluding the third test case; An acquisition module is used to obtain an exception identifier corresponding to the target test case and determine a target scenario that matches the exception identifier; the target scenario is used to reflect the abnormal situation; a sending module, configured to send a test report to a target device based on the target scenario, the target test case, and the first code, wherein the test report includes statements covered by the target test case in the first code; The processing module is further configured to: After determining the intersection of the first test case and the second test case as the third test case, the first test result of the third test case is modified to success, and a test report is sent to the target device, wherein the test report also includes first indication information, wherein the first indication information is used to indicate that the result of the third test case has been modified.

8. The device according to claim 7, wherein The sending module is specifically used for: If the target scenario is of the first type, obtaining a first target statement covered by the target test case in the first code; If the filtering condition or the recall condition is updated in the first target statement, after receiving abnormality confirmation information for the updated filtering condition or the recall condition, sending a test report to the target device; If the filtering condition and the recall condition are not updated in the first target statement, the test report is directly sent to the target device; The first type of scenario includes at least one of the following: the result returned according to the query condition is empty.

9. The device according to claim 7, wherein The sending module is specifically used for: If the target scenario is of the second type, obtaining a second target statement covered by the target test case in the first code; Obtain the return result corresponding to the target test case; Sending a test report to a target device according to the returned result and the target statement; Among them, the second type of scenario includes at least one of the following: the number of results returned according to the query condition is less than a preset number, the results returned according to the query condition do not meet the query condition, and the returned constant is different from the expected constant.

10. The device according to claim 9, wherein The sending module is specifically used for: If the returned result matches the second target statement, modifying the result of the target test case to success, and sending a test report to the target device, wherein the test report also includes second indication information, wherein the second indication information is used to indicate that the result of the target test case has been modified; If the returned result does not match the second target statement, a test report is directly sent to the target device.

11. The device according to claim 7, wherein The sending module is specifically used for: If the target scenario is the third type, directly sending a test report to the target device; The third type of scenario includes at least one of the following: the number of rejected requests is greater than a preset threshold, and service failure.

12. The device according to claim 7, wherein the test report further comprises at least one of the following: an identifier of the target test case, running information of the target test case, an identifier of the target scenario, and an exception identifier corresponding to the target test case.

13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.

15. A computer program product comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Test submission method and system, electronic equipment and storage medium

    CN112162931A

  • Code automatic testing method and device, electronic equipment and storage medium

    CN113986263A