Accurate test construction method and device based on error correlation coefficient

By randomly injecting errors into the code to be tested in the precision test, calculating the error correlation coefficient, and establishing the mapping relationship between the code and the test cases, the time-consuming and labor-consuming problem of establishing the mapping relationship in the existing precision test methods is solved, and an efficient and automated testing process is achieved.

CN119807030APending Publication Date: 2025-04-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411748184.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

When the existing precision testing methods establish the mapping relationship between code and test cases, there are problems such as uneven results of coverage analysis tools and time-consuming and labor-consuming, resulting in low testing efficiency.

Method used

By randomly injecting errors into the code to be tested, running all test cases, counting the performance of each test case under different error situations, and calculating the error correlation coefficient, thereby establishing a mapping relationship between the code and the test case.

Benefits of technology

This method can quantify the degree of correlation between each test case and code, reduce unnecessary test cases, improve test efficiency, reduce test time and cost, and is suitable for any code language.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807030A_ABST
    Figure CN119807030A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software testing, and discloses a precise test construction method and device based on an error correlation coefficient, and the method comprises the steps: carrying out the random error injection of a to-be-tested code, and obtaining an error test code; based on the error test code, running all the test cases to obtain an error test case; repeating the process for preset test times to obtain the error times that each test case becomes an error test case; determining an error correlation coefficient of the test case based on the error frequency of the test case and a preset test frequency; and constructing an accurate test based on the error correlation coefficient corresponding to each test case. According to the method, the error correlation coefficient is calculated, the mapping relation between the code and the test case is effectively established, the correlation degree between each test case and the code is quantified, unnecessary test cases are reduced, the test efficiency is improved, the test time is shortened, the test cost is reduced, the method is not influenced by a coverage rate tool and different code differences, and good compatibility is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to a method and device for constructing a precise test based on an error correlation coefficient. Background Art

[0002] Precision testing uses specific algorithms, technical means and tools to analyze code, program running process, test cases, etc. and their relationships, so as to obtain relevant information and knowledge, accurately locate and optimize the test scope, and use accurate data to evaluate test results and product quality, making the entire testing process more efficient, accurate and reliable. At the same time, it can effectively reduce the risk of missed tests and minimize testing costs.

[0003] Currently, the implementation of precise testing is mainly divided into two steps: first, accurately identify the code scope affected by each code modification. The code impact scope can be accurate to the class method, function level or code block, and then establish a mapping relationship between code and test cases.

[0004] For the second step of precise testing, if you want to establish a mapping relationship between code and test cases, you usually use code coverage analysis to better understand which codes are executed by the test cases, and further clarify which codes are covered and which codes are not covered in the test execution. However, each code language has a corresponding coverage analysis tool, and the results of coverage analysis vary. In addition, establishing a mapping between code and test cases is a long process that requires a lot of time and manpower costs, and has low testing efficiency. Summary of the invention

[0005] In view of this, the present invention provides a method and device for constructing a precise test based on an error correlation coefficient to solve the problem of accurately establishing a mapping relationship between code and test cases to construct a precise test.

[0006] In a first aspect, the present invention provides a method for constructing an accurate test based on an error correlation coefficient, the method comprising:

[0007] For the code to be tested, random errors are injected into the code to be tested to obtain error test code;

[0008] Based on the error test code, run all test cases to get the error test cases;

[0009] Repeat the above error injection and error test case obtaining process for a preset number of tests to obtain the number of errors each test case has when it becomes an error test case;

[0010] For each test case, determining an error correlation coefficient of the test case based on the number of errors of the test case and a preset number of tests;

[0011] Build accurate tests based on the error correlation coefficient corresponding to each test case.

[0012] The accurate test construction method based on error correlation coefficient provided by the embodiment of the present invention can simulate various possible error scenarios by randomly injecting errors into the code to be tested, increase the diversity and coverage of the test, run all test cases based on the error test code obtained after the error injection, obtain the error test case, and comprehensively evaluate the impact after the error injection. By repeating the error injection and testing process for many times, the performance of each test case under different error conditions can be statistically analyzed. For each test case, the error correlation coefficient is calculated based on the number of errors of the test case and the preset number of tests, and the mapping relationship between the code and the test case is effectively established. The degree of association between each test case and the code can be quantified, so as to construct an accurate test based on the error correlation coefficient corresponding to each test case, reduce unnecessary test cases, improve test efficiency, and reduce test time and cost through the automated test process. At the same time, it is applicable to any code language, is not affected by coverage tools and differences between different codes, and has good compatibility.

[0013] In an optional implementation, based on the error test code, all test cases are run to obtain the error test case, including:

[0014] Compile the error test code and deploy it to the test environment;

[0015] In the test environment, run a full set of regression tests to identify the erroneous test cases that failed to run from all test cases.

[0016] The precise test construction method based on error correlation coefficient provided in the embodiment of the present invention can determine the error test cases that failed to run from all test cases by compiling the error test code and deploying it to the test environment, and running the full regression test in the test environment. This helps to accurately identify which test cases are affected by the error code. The automated testing process reduces manpower and time costs and improves testing efficiency.

[0017] In an optional implementation, for each test case, based on the number of errors of the test case and a preset number of tests, determining an error correlation coefficient of the test case includes:

[0018] For each test case, the ratio of the number of errors of the test case to the preset number of tests is determined as the error correlation coefficient of the test case.

[0019] The accurate test construction method based on error correlation coefficient provided in the embodiment of the present invention can quantify the correlation degree between the test case and the code by taking the ratio of the number of errors of the test case to the preset number of tests as the error correlation coefficient, thereby effectively establishing a mapping relationship between the code and the test case.

[0020] In an optional implementation, based on the error correlation coefficient corresponding to each test case, a precise test is constructed, including:

[0021] Determine a target error correlation threshold from the error correlation coefficient corresponding to each test case;

[0022] From all the test cases, determining at least one target test case whose error correlation coefficient is greater than a target error correlation threshold;

[0023] Based on at least one target test case, the code to be tested is accurately tested.

[0024] The precise test construction method based on error correlation coefficient provided in the embodiment of the present invention can determine the target error correlation threshold from the error correlation coefficients corresponding to all test cases, so that the target test cases greater than the target error correlation threshold only need to be run for precise testing, thereby reducing unnecessary test cases, thereby reducing test time and cost and improving test efficiency.

[0025] In an optional implementation, for the code to be tested, randomly injecting errors into the code to be tested to obtain an error test code includes:

[0026] For the code to be tested, random error injection is performed based on the minimum function level of the code to be tested to obtain error test code.

[0027] The precise test construction method based on error correlation coefficient provided in the embodiment of the present invention can more accurately control the location and type of error injection by performing random error injection based on the minimum function level of the code to be tested, which helps to more carefully simulate various errors that may occur in actual operation and improve the accuracy and diversity of error injection.

[0028] In an optional implementation, the random error injection includes a syntax error in a line of code, a change in code logic at the function level, an input parameter error in the code, and an error in the return value of the code.

[0029] The precise test construction method based on the error correlation coefficient provided in the embodiment of the present invention can comprehensively cover various possible error types by randomly injecting errors including syntax errors in a line of code, changes in code logic at the function level, errors in code input parameters, and errors in code return values, thereby helping to more comprehensively evaluate the degree of correlation between test cases and codes in different error scenarios.

[0030] In a second aspect, the present invention provides a precise test construction device based on an error correlation coefficient, the device comprising:

[0031] An injection module is used to randomly inject errors into the code to be tested to obtain an error test code;

[0032] The run module is used to run all test cases based on the error test code to obtain the error test cases;

[0033] A first determination module is used to repeat the process of injecting errors and obtaining error test cases for a preset number of times, and obtain the number of errors each test case has become an error test case;

[0034] A second determination module is used to determine, for each test case, an error correlation coefficient of the test case based on the number of errors of the test case and a preset number of tests;

[0035] A building module is used to build accurate tests based on the error correlation coefficient corresponding to each test case.

[0036] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the precise test construction method based on the error correlation coefficient of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0037] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the precise test construction method based on the error correlation coefficient of the above-mentioned first aspect or any corresponding embodiment thereof.

[0038] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the precise test construction method based on the error correlation coefficient of the above-mentioned first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 is a flow chart of a method for constructing an accurate test based on an error correlation coefficient according to an embodiment of the present invention;

[0041] Figure 2 is a flowchart of another accurate test construction method based on error correlation coefficient according to an embodiment of the present invention;

[0042] Figure 3 is a flowchart of establishing a mapping relationship between codes to be tested and test cases according to an embodiment of the present invention;

[0043] Figure 4 is a structural block diagram of a precise test construction device based on error correlation coefficient according to an embodiment of the present invention;

[0044] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0046] When building a precise test, it is necessary to establish a mapping relationship between code and test cases. Usually, this is achieved with the help of code coverage analysis, but each code language has a corresponding coverage analysis tool, and the results of coverage analysis are uneven. At the same time, establishing the mapping between code and test cases is a long process, which requires a lot of time and labor costs, and the test efficiency is low. The precise test construction method based on the error correlation coefficient provided by the embodiment of the present invention effectively establishes the mapping relationship between code and test cases by counting the performance of each test case under different error conditions, calculating the error correlation coefficient, and quantifying the degree of association between each test case and the code, thereby constructing a precise test based on the error correlation coefficient corresponding to each test case, reducing unnecessary test cases, and improving test efficiency. The automated test process reduces test time and cost, and is applicable to any code language at the same time, is not affected by coverage tools and differences between different codes, and has good compatibility.

[0047] According to an embodiment of the present invention, an embodiment of a precise test construction method based on an error correlation coefficient is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0048] In this embodiment, a precise test construction method based on error correlation coefficient is provided, which can be used for the above-mentioned electronic device. Figure 1 is a flow chart of a method for constructing an accurate test based on an error correlation coefficient according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0049] Step S101, for the code to be tested, random errors are injected into the code to be tested to obtain error test code. Specifically, in the traditional precise testing process, all test cases are usually run, even if many of the test cases are irrelevant to the current code change, which leads to high time cost and low test efficiency. Therefore, it is necessary to establish a mapping relationship between code and test case, so as to use only test cases related to code change for precise testing and reduce unnecessary test cases. In the related art, a mapping relationship between code and test case is established by a coverage analysis tool, but different code languages ​​need to use different coverage analysis tools, which leads to uneven results of the coverage analysis tool and the inability to effectively establish a mapping relationship between code and test case. The embodiment of the present invention randomly selects a section of code as the code to be tested, does not restrict the code language of the code to be tested, and does not need to use a coverage analysis tool, so it has good compatibility. By randomly injecting errors into the code to be tested, the error conditions that may occur in actual operation are simulated to obtain error test code.

[0050] Step S102, based on the error test code, run all test cases to obtain error test cases. Specifically, run all test cases on the code injected with the error. If the test case runs normally under the error test code, it means that the correlation between the test case and the code to be tested is low, and the change of the code to be tested cannot affect the running of the test case. If the test case fails to run under the error test code, it means that the correlation between the test case and the code to be tested is high, and the change of the code to be tested will affect the running of the test case. These failed test cases are regarded as error test cases.

[0051] Step S103, repeat the process of injecting errors and obtaining error test cases for the preset number of tests, and obtain the number of errors that each test case becomes an error test case. Specifically, repeat the above steps S101 and S102, and randomly inject an error into the code to be tested in each test, and then run all test cases to obtain the error test cases corresponding to each test until the preset number of tests is completed. Assume that there are test case 1, test case 2, test case 3, test case 4 and test case 5, and the preset number of tests is 3. In the first test, the error test cases obtained are: test case 1, test case 3 and test case 5; in the second test, the error test case obtained is: test case 4; in the third test, the error test cases obtained are: test case 2 and test case 5. At this time, the number of errors of each test case in the test process can be obtained: the number of errors of test case 1 is 1; the number of errors of test case 2 is 1; the number of errors of test case 3 is 1; the number of errors of test case 4 is 0; the number of errors of test case 5 is 2. Optionally, the above preset number of tests is only an example. In actual situations, the value should be as large as possible to help more accurately determine the mapping relationship between code and test cases.

[0052] Step S104, for each test case, based on the number of errors in the test case and the preset number of tests, determine the error correlation coefficient of the test case. Specifically, based on the number of errors in the test case and the preset number of tests, the error correlation coefficient of the test case can be obtained, which can quantify the degree of association between the test case and the code to be tested. The greater the degree of association, the greater the degree of influence of the test case by the code to be tested, that is, if the code to be tested changes, it is more likely to affect the operation of the test case.

[0053] Step S105, constructing a precise test based on the error correlation coefficient corresponding to each test case. Specifically, the test cases for constructing a precise test can be screened by the error correlation coefficient of the test case, and unnecessary test cases can be reduced to reduce test time and cost, thereby improving test efficiency.

[0054] The accurate test construction method based on error correlation coefficient provided by the embodiment of the present invention can simulate various possible error scenarios by randomly injecting errors into the code to be tested, increase the diversity and coverage of the test, run all test cases based on the error test code obtained after the error injection, obtain the error test case, and comprehensively evaluate the impact after the error injection. By repeating the error injection and testing process for many times, the performance of each test case under different error conditions can be statistically analyzed. For each test case, the error correlation coefficient is calculated based on the number of errors of the test case and the preset number of tests, and the mapping relationship between the code and the test case is effectively established. The degree of association between each test case and the code can be quantified, so as to construct an accurate test based on the error correlation coefficient corresponding to each test case, reduce unnecessary test cases, improve test efficiency, and reduce test time and cost through the automated test process. At the same time, it is applicable to any code language, is not affected by coverage tools and differences between different codes, and has good compatibility.

[0055] In this embodiment, a precise test construction method based on error correlation coefficient is provided, which can be used for the above-mentioned electronic device. Figure 2 is a flowchart of another accurate test construction method based on error correlation coefficient according to an embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:

[0056] Step S201: For the code to be tested, random errors are injected into the code to be tested to obtain an error test code.

[0057] Specifically, the above step S201 includes:

[0058] Step S2011, for the code to be tested, random error injection is performed based on the minimum function level of the code to be tested to obtain error test code. Specifically, error injection is performed according to the minimum level of the code, that is, the function level, which can more accurately control the location and type of error injection, help to more carefully simulate various errors that may occur in actual operation, and improve the accuracy and diversity of error injection.

[0059] In some optional implementations, random error injection includes syntax errors in a line of code, function-level code logic changes, code input parameter errors, and code return value errors. Specifically, a syntax error is to randomly select a line of code and introduce a syntax error, such as a spelling error, missing semicolon, etc.; a function-level code logic change is to randomly select a function and modify its internal logic, such as changing conditional judgments, loop structures, etc.; a code input parameter error is to randomly select a function call and modify its input parameters, such as passing in an incorrect data type, exceeding the expected value range, etc.; a code return value error is to randomly select a function and modify its return value, such as returning an incorrect data type, returning an abnormal value, etc. Optionally, other function-level related errors may also be used, and the embodiments of the present invention are not limited to this.

[0060] Step S202, based on the error test code, run all test cases to obtain error test cases.

[0061] Specifically, the above step S202 includes:

[0062] Step S2021, compile the error test code and deploy it to the test environment. Specifically, compile the error test code and then deploy it to the test environment so that subsequent testing can be performed in the test environment.

[0063] Step S2022, in the test environment, run a full regression test to identify the erroneous test cases that failed to run from all test cases. Specifically, a full regression test is a test method used to verify whether any changes or updates to the code affect the running of the test cases. Specifically, a full regression test involves re-running all test cases to find the erroneous test cases that failed to run.

[0064] Step S203, repeat the process of injecting errors and obtaining error test cases for a preset number of times, and obtain the number of errors each test case has become an error test case. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.

[0065] Step S204: for each test case, based on the number of errors of the test case and the preset number of tests, determine the error correlation coefficient of the test case.

[0066] Specifically, the above step S204 includes:

[0067] Step S2041, for each test case, the ratio of the number of errors of the test case to the preset number of tests is determined as the error correlation coefficient of the test case. Specifically, the error correlation coefficient of the test case is calculated by the following formula (1) to quantify the degree of association between the test case and the code to be tested, thereby effectively establishing a mapping relationship between the code and the test case, without considering the coverage analysis tools and code languages ​​in the relevant technology, and has strong compatibility. The error correlation coefficient is in the interval [0, 1]. The larger the error correlation coefficient, the greater the degree of association between the test case and the code to be tested. The maximum is 1, indicating that the test case will definitely be affected by the changed code to be tested.

[0068]

[0069] Where r represents the error correlation coefficient of any test case; F represents the number of errors in the test case; and N represents the preset number of tests.

[0070] In some optional implementations, after the error correlation coefficients of all test cases are determined, database archiving may be performed.

[0071] In some optional embodiments, Figure 3 is a flowchart of establishing a mapping relationship between codes to be tested and test cases according to an embodiment of the present invention, such as Figure 3 As shown, random error injection is performed at the minimum function level for the code to be tested to obtain the error test code. Then, the error test code is compiled and deployed to the test environment. Then, all test cases are run to obtain the error test cases that failed to run. Then, it is determined whether the preset number of tests has been reached. If not, it returns to the random error injection step to continue testing. If the preset number of tests has been reached, the ratio of the number of errors of each test case during the test process of the preset number of tests to the preset number of tests is used as the error correlation coefficient of the test case.

[0072] Step S205: construct an accurate test based on the error correlation coefficient corresponding to each test case.

[0073] Specifically, the above step S205 includes:

[0074] Step S2051, determining a target error correlation threshold from the error correlation coefficient corresponding to each test case. Specifically, the user can select any error correlation coefficient from the error correlation coefficients of all test cases as the target error correlation threshold according to code quality, test requirements, etc.

[0075] Step S2052: Determine at least one target test case from all test cases whose error correlation coefficient is greater than a target error correlation threshold. Specifically, select a test case from all test cases whose error correlation coefficient is greater than the target error correlation threshold as the target test case.

[0076] Step S2053, based on at least one target test case, the code to be tested is accurately tested. Specifically, the target test case determined in the above step is the test case that the user believes is related to the code change. When performing accurate testing, only the target test case needs to be run, which reduces unnecessary test cases, thereby reducing test time and cost and improving test efficiency.

[0077] The accurate test construction method based on error correlation coefficient provided by the embodiment of the present invention can simulate various possible error scenarios by randomly injecting errors into the code to be tested, increase the diversity and coverage of the test, run all test cases based on the error test code obtained after the error injection, obtain the error test case, and comprehensively evaluate the impact after the error injection. By repeating the error injection and testing process for many times, the performance of each test case under different error conditions can be statistically analyzed. For each test case, the error correlation coefficient is calculated based on the number of errors of the test case and the preset number of tests, and the mapping relationship between the code and the test case is effectively established. The degree of association between each test case and the code can be quantified, so as to construct an accurate test based on the error correlation coefficient corresponding to each test case, reduce unnecessary test cases, improve test efficiency, and reduce test time and cost through the automated test process. At the same time, it is applicable to any code language, is not affected by coverage tools and differences between different codes, and has good compatibility.

[0078] In this embodiment, a precise test construction device based on error correlation coefficient is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made are not repeated here. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0079] This embodiment provides a precise test construction device based on error correlation coefficient, such as Figure 4 As shown, including:

[0080] The injection module 401 is used to randomly inject errors into the code to be tested to obtain an error test code.

[0081] The running module 402 is used to run all test cases based on the error test code to obtain the error test case.

[0082] The first determining module 403 is used to repeat the process of error injection and obtaining error test cases for a preset number of test times, and obtain the number of errors each test case has when it becomes an error test case.

[0083] The second determination module 404 is configured to determine, for each test case, an error correlation coefficient of the test case based on the number of errors of the test case and a preset number of tests.

[0084] The construction module 405 is used to construct a precise test based on the error correlation coefficient corresponding to each test case.

[0085] In some optional implementations, the operation module 402 includes:

[0086] Compilation unit, used to compile error test code and deploy it to the test environment.

[0087] The running unit is used to run the full regression test in the test environment and identify the erroneous test cases that failed to run from all the test cases.

[0088] In some optional implementations, the second determining module 404 includes:

[0089] The first determining unit is used to determine, for each test case, a ratio of the number of errors of the test case to a preset number of tests as an error correlation coefficient of the test case.

[0090] In some optional implementations, the construction module 405 includes:

[0091] The second determining unit is used to determine a target error correlation threshold from the error correlation coefficient corresponding to each test case.

[0092] The third determining unit is used to determine at least one target test case whose error correlation coefficient is greater than a target error correlation threshold from all test cases.

[0093] The test unit is used to accurately test the code to be tested based on at least one target test case.

[0094] In some optional embodiments, the injection module 401 includes:

[0095] The injection unit is used to perform random error injection on the code to be tested based on the minimum function level of the code to be tested to obtain error test code.

[0096] In some optional implementations, the random error injection includes a syntax error in a line of code, a change in code logic at the function level, an input parameter error in the code, and an error in the return value of the code.

[0097] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0098] The precise test construction device based on the error correlation coefficient in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0099] The embodiment of the present invention also provides a computer device having the above Figure 4 The accurate test setup based on the error correlation coefficient is shown.

[0100] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.

[0101] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0102] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0103] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0104] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0105] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0106] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.

[0107] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0108] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0109] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for constructing an accurate test based on an error correlation coefficient, characterized in that: The method comprises: For a code to be tested, randomly injecting errors into the code to be tested to obtain an error test code; Based on the error test code, run all test cases to obtain error test cases; Repeat the above error injection and error test case obtaining process for a preset number of tests to obtain the number of errors each test case has when it becomes an error test case; For each test case, determining an error correlation coefficient of the test case based on the number of errors of the test case and the preset number of tests; Build accurate tests based on the error correlation coefficient corresponding to each test case.

2. The method according to claim 1, characterized in that The step of running all test cases based on the error test code to obtain the error test case includes: Compile the error test code and deploy it to the test environment; In the test environment, a full regression test is run to identify erroneous test cases that fail to run from all test cases.

3. The method according to claim 1, characterized in that The step of determining, for each test case, an error correlation coefficient of the test case based on the number of errors of the test case and the preset number of tests includes: For each test case, the ratio of the number of errors of the test case to the preset number of tests is determined as the error correlation coefficient of the test case.

4. The method according to claim 1, characterized in that The accurate test is constructed based on the error correlation coefficient corresponding to each test case, including: Determine a target error correlation threshold from the error correlation coefficient corresponding to each test case; Determine at least one target test case from all test cases whose error correlation coefficient is greater than the target error correlation threshold; Based on the at least one target test case, the code to be tested is accurately tested.

5. The method according to claim 1, characterized in that The step of injecting random errors into the code to be tested to obtain an error test code comprises: For the code to be tested, random error injection is performed based on the minimum function level of the code to be tested to obtain an error test code.

6. The method according to claim 5, characterized in that The random error injection includes syntax errors in a line of code, changes in code logic at the function level, errors in code input parameters, and errors in code return values.

7. A precise test construction device based on error correlation coefficient, characterized in that: The device comprises: An injection module is used for randomly injecting errors into the code to be tested to obtain an error test code; A running module, used to run all test cases based on the error test code to obtain error test cases; A first determination module is used to repeat the process of injecting errors and obtaining error test cases for a preset number of times, and obtain the number of errors each test case has become an error test case; A second determination module is used to determine, for each test case, an error correlation coefficient of the test case based on the number of errors of the test case and the preset number of tests; A building module is used to build accurate tests based on the error correlation coefficient corresponding to each test case.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the accurate test construction method based on the error correlation coefficient described in any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the accurate test construction method based on error correlation coefficient according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the accurate test construction method based on error correlation coefficient according to any one of claims 1 to 6.