Test case effectiveness evaluation method, computer equipment and storage medium

By evaluating the code coverage and assertion validity of test cases, the effectiveness of test cases is comprehensively judged, which solves the problem of inability to accurately evaluate test cases in existing technologies and improves test efficiency and accuracy.

CN115033470BActive Publication Date: 2025-09-23PING AN BANK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210735485.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-27
Publication Date
2025-09-23
Estimated Expiration
2042-06-27

AI Technical Summary

Technical Problem

Existing software testing tools cannot accurately judge the effectiveness of test cases, affecting the accuracy and efficiency of the software code testing process.

Method used

By evaluating the code effectiveness of the business code coverage based on test cases and combining it with the assertion effectiveness evaluation of the assertion content, the effectiveness of the test cases can be comprehensively judged.

Benefits of technology

It improves the availability and accuracy of test cases, reduces the time for troubleshooting test code or business code, provides reference information for developers to evaluate the effectiveness, and ensures that test cases are written in a more standardized and standardized manner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033470B_ABST
    Figure CN115033470B_ABST
Patent Text Reader

Abstract

This application discloses a test case validity assessment method, computer device, and storage medium. The method includes: performing a code validity assessment based on the coverage of business code in the test case to obtain a code validity assessment result; performing an assertion validity assessment based on the assertion content of the test case to obtain an assertion validity assessment result; and determining the case validity of the test case by combining the code validity assessment result and the assertion validity assessment result. This approach can accurately determine the validity of the test case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a test case effectiveness evaluation method, a computer device, and a computer-readable storage medium. Background Art

[0002] In current software applications, after the software is developed, it is not used directly. Usually, the software code needs to be tested. Software testing is mainly used to analyze the correctness of the software and detect software vulnerabilities.

[0003] When testing software code, it is usually necessary to determine the completeness of the test case execution, evaluate the testing work based on the completeness of the test case execution, and then make adjustments to the test case, etc., and improve the software code on this basis.

[0004] Currently, some software testing tools can perform software code testing based on automated test cases. However, they cannot determine whether the written test cases are valid, and the validity of the test cases will affect the testing process of the software code. Summary of the Invention

[0005] The main technical problem solved by this application is to provide a test case effectiveness evaluation method, computer equipment and storage medium, which can accurately obtain the effectiveness of the test case.

[0006] In order to solve the above problems, the first aspect of the present application provides a test case validity evaluation method, which includes: performing code validity evaluation on the coverage of business code based on the test case to obtain a code validity evaluation result; performing assertion validity evaluation based on the assertion content of the test case to obtain an assertion validity evaluation result; and determining the case validity of the test case by comprehensively combining the code validity evaluation result and the assertion validity evaluation result.

[0007] In order to solve the above problems, the second aspect of the present application provides a computer device, which includes a memory and a processor coupled to each other, wherein the memory stores program data, and the processor is used to execute the program data to implement any step of the above-mentioned test case effectiveness evaluation method.

[0008] In order to solve the above problems, the third aspect of the present application provides a computer-readable storage medium, which stores program data that can be executed by a processor, and the program data is used to implement any step of the above-mentioned test case effectiveness evaluation method.

[0009] The above solution performs code validity evaluation on the coverage of business code based on test cases to obtain code validity evaluation results, performs assertion validity evaluation based on the assertion content of the test case to obtain assertion validity evaluation results, and combines the code validity evaluation results and assertion validity evaluation results to determine the case validity of the test case. It can comprehensively consider code validity and assertion validity, more accurately judge the validity of the test case, and improve the usability and accuracy of the test case, thereby reducing the user's troubleshooting time for test code or business code. In addition, case validity can provide developers with reference information for validity evaluation, making the writing of test cases more standardized and normative. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions of this application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be derived from these drawings without inventive effort. Among them:

[0011] Figure 1 This is a flow chart of an embodiment of a method for evaluating the effectiveness of a test case of the present application;

[0012] Figure 2 This application Figure 1 A flow chart of an embodiment of step S11;

[0013] Figure 3 This is a schematic diagram of an embodiment of the test case coverage of the business code of the present application;

[0014] Figure 4 This application Figure 1 A flow chart of an embodiment of step S12;

[0015] Figure 5 This application Figure 1 A flow chart of an embodiment of step S13;

[0016] Figure 6 It is a structural diagram of an embodiment of a validity evaluation device for a test case of the present application;

[0017] Figure 7 This is a schematic structural diagram of an embodiment of a computer device of the present application;

[0018] Figure 8 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0020] The terms "first" and "second" in this application are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0021] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0022] This application provides the following embodiments, and each embodiment is described in detail below.

[0023] See also Figure 1 , Figure 1 1 is a flow chart of an embodiment of a method for evaluating the effectiveness of a test case of the present application. The method may include the following steps:

[0024] S11: Perform code effectiveness evaluation on the coverage of the business code based on the test cases to obtain the code effectiveness evaluation results.

[0025] Software testing (English: Software Testing) describes a process used to facilitate the verification of the correctness, integrity, security, and quality of software. In other words, software testing is the process of reviewing or comparing actual output with expected output. The classic definition of software testing is: the process of operating a program under specified conditions to detect program errors, measure software quality, and evaluate whether it meets design requirements.

[0026] In some embodiments, a test case can be a group of test cases, for example, it can include multiple minimum unit test cases of unit testing. The minimum unit test case can be used to detect and verify the corresponding minimum testable unit in the business code. The minimum testable unit can be a module, a function or a class in the business code.

[0027] In some implementations, the coverage of the business code can be executed using test cases to evaluate code effectiveness, where the coverage is described as code coverage. Code coverage (English: Code Coverage) is a measurement in software testing that describes the proportion or degree of source code in the business code that is tested. The resulting proportion or degree is called code coverage.

[0028] In some implementations, a code coverage statistics tool such as Jacoco may be used to test the business code using test cases to collect the code coverage of the business code, and based on the code coverage, the code effectiveness of the business code may be evaluated.

[0029] In some implementations, a coverage statistics tool may be used to set tracking data in the business code, so as to use the tracking data to obtain the code coverage when the test case executes the business code.

[0030] In some implementations, the number of valid lines of code executed in the acquired business code can be used to determine the code coverage of the business code based on the number of valid lines of code executed. The concept of valid lines of code is relative to the concept of lines of code; valid lines of code can be lines of code in the business code that are actually executable. The higher the proportion of valid lines of code executed in the business code, the higher the code coverage, i.e., the better the code effectiveness.

[0031] S12: Perform assertion validity evaluation based on the assertion content of the test case to obtain an assertion validity evaluation result.

[0032] Assertion is a first-order logic statement in a program (e.g., a logical statement with a true or false result). Its purpose is to express and verify the results expected by software developers.

[0033] In some implementations, assertion validity can be determined based on the writing of the test case. The content of the test case can be judged to determine whether the test case makes a valid assertion.

[0034] Test cases contain case values. After testing the business code using the case values ​​in the test case, the execution result is obtained, which is also the value to be asserted. Before this, you can pre-set the expected value corresponding to the business code when the case value executes the business code. This will result in the assertion content, namely the value to be asserted and the expected value.

[0035] In some embodiments, the assertion value and the expected value in the assertion content are compared. If the data values, data types, logical validation, etc. of the assertion value and the expected value are equal, the assertion validity evaluation result can be set to valid. Otherwise, the assertion validity is set to invalid.

[0036] Through the above method, the assertion validity evaluation results can be used to determine whether valid assertions are written in the business code and / or test cases, thereby improving the quality of business code during business code development and improving the quality of test case writing during software testing, thereby providing developers with reference information for validity evaluation.

[0037] S13: Integrate the code validity evaluation results and the assertion validity evaluation results to determine the case validity of the test case.

[0038] Test cases can be used to perform software testing on business codes. When a problem occurs in the business code, if the test case can discover the problem, the test case is considered valid; conversely, if the test case cannot discover the problem, the test case is considered invalid.

[0039] In this step, the code effectiveness evaluation results and assertion effectiveness evaluation results can be combined to comprehensively determine the effectiveness of the test case based on code coverage and assertion effectiveness. If the test case effectiveness is determined to be invalid, the test case can be adjusted to obtain a more effective and accurate test case.

[0040] In this step, code validity evaluation is performed on the coverage of the business code based on the test case to obtain the code validity evaluation result, and assertion validity evaluation is performed based on the assertion content of the test case to obtain the assertion validity evaluation result. The code validity evaluation result and the assertion validity evaluation result are combined to determine the case validity of the test case. The code validity and assertion validity can be comprehensively considered to more accurately judge the validity of the test case, and the usability and accuracy of the test case can be improved, thereby reducing the user's troubleshooting time for test code or business code. In addition, case validity can provide developers with reference information for validity evaluation, making the writing of test cases more standardized and normative.

[0041] In some embodiments, see Figure 2, step S11 of the above embodiment can be further expanded. Based on the test case, the code validity evaluation is performed on the coverage of the business code to obtain the code validity evaluation result. This embodiment may include the following steps:

[0042] S111: Obtain the ratio of the number of lines of code of the business code used in the test case during the test process to the total number of lines of the business code.

[0043] In the process of testing the business code using test cases, the number of code lines of the business code that use the test cases during the test process is obtained, that is, the number of code lines of the business code that are executed or tested during the test process, so as to obtain the line ratio between the number of code lines using the test cases and the total number of lines of business code. The line ratio can represent the code coverage rate of the business code, that is, the coverage degree.

[0044] In some implementations, the total number of business code lines includes all code lines of the business code, that is, the number of all code lines written by a programmer during programming, which may include, for example, blank lines, comment lines, and code lines.

[0045] In some implementations, the total number of lines of business code may be represented as actually executable code in the business code, such as lines of code or valid lines of code.

[0046] In some implementations, when there are multiple business codes, the ratio of the number of lines of code used in test cases to the total number of lines of code in each business code can be obtained. For example, when the business code includes team, system, and case layers, the code coverage of each team, system, and case layer can be obtained separately.

[0047] In some embodiments, when the business code includes multiple test units, the number of lines of code used in the test case by each of the multiple test units in the business code can be obtained. For example, the number of lines of code used in the test case by each of the multiple test units in the business code can be obtained, that is, the number of lines of code tested or executed by each of the multiple test units can be obtained, and the ratio of the number of lines of code used in the test case to the total number of lines of code in the business code test units can be obtained, so that the code coverage of each test unit can be obtained later. The test unit can be a module, a function, or a class in the business code.

[0048] In some implementations, before using test cases to test the business code, embedded data can be set in the business code. This is called embedding the business code. The embedded data can be a section of code used for information collection and can be set according to actual needs. Embedding can insert code for embedding, also known as embedded data, into the business code without destroying the original logical integrity of the business code. The embedded data can collect information and output characteristic data of the business code program execution. The embedded data can be used to obtain the proportion of lines of business code executed by the test case to obtain code coverage.

[0049] In some embodiments, the row ratio or coverage can be expressed as a percentage, and the accuracy can be selected according to the application scenario, such as an accuracy of 0.001%, 0.01%, 0.1%, etc., which is not limited in this application.

[0050] In some implementations, the service code may be further divided into a primary service code and an auxiliary service code.

[0051] In some application scenarios, when there are multiple business code data, at least one business code can be selected from the multiple business codes as the main business code, and the other business codes can be selected as auxiliary business codes.

[0052] In some application scenarios, valid lines or lines of code (excluding blank lines and comment lines) of the business code can be used as the main business code, and blank lines and comment lines can be used as auxiliary business code. In addition, the embedded data of the business code can also be used as auxiliary business code.

[0053] The main business code and auxiliary business code of this application can be set based on the specific application scenario of the business code. This application does not limit the main business code and auxiliary business code of the above business code.

[0054] In some implementations, the business code can be further divided into primary business code and auxiliary business code. The ratio of the number of lines of code in the primary business code used in the test case during the testing process to the total number of lines of code in the primary business code can be obtained. Alternatively, the ratio of the number of lines of code in the primary business code used in the test case during the testing process to the total number of lines of code in the business code can be obtained.

[0055] In some implementations, the business code can be further divided into primary business code and auxiliary business code. The ratio of the number of lines of code used in the test case to the total number of lines of business code can be obtained for each of the primary business code and the auxiliary business code during the test process.

[0056] In some implementations, the above process is to obtain full coverage of the business code by the test cases, that is, to test all lines of code in the business code. In some application scenarios, after completing the software testing of the business code, the programmer modifies the business code, adds some module functions and methods, etc., and can use the test cases to test the business code again. In this case, the incremental coverage of the business code can be obtained, that is, the function methods of the added modules, that is, the test units, are tested. This method can refer to the specific implementation method of full coverage mentioned above and will not be repeated here.

[0057] See also Figure 3 , you can execute the business code based on the test case to obtain the coverage of the business code, that is, the ratio of the number of lines of code in the business code that use the test case during the test process to the total number of lines of business code. If there are multiple business codes, you can obtain the coverage of multiple business codes separately. In the software test execution interface, you can determine the global coverage or incremental coverage of the business code executed by the test case in response to the user's selection on the display interface. Taking global coverage as an example, you can obtain the coverage of business codes 1-10 separately.

[0058] During the testing process of the business code, the coverage of tests in multiple time periods can be counted, such as representing the coverage of business code tests in multiple test times from 22-01 to 22-06 in the form of a curve. It can be understood that the representation and statistics of coverage are not limited to this.

[0059] In addition, in the execution interface, you can also sort based on the coverage of the business code to get the coverage of each business code. The coverage is as follows:

[0060] Ranking 1 is business code 1, and the corresponding coverage is 46.46%;

[0061] Ranking 2 is business code 5, with a corresponding coverage of 44.43%;

[0062] Ranking 3 is business code 3, and the corresponding coverage is 41.94%;

[0063] Ranking 4 is business code 2, with a corresponding coverage of 40.30%;

[0064]

[0065] Ranking 9 is business code 7, with a coverage of 36.27%;

[0066] Ranking 10 is business code 10, and the corresponding coverage is 36.20%.

[0067] In this way, the coverage of multiple business codes can be clarified, so as to determine whether a business code among multiple business codes needs to select other test cases for testing, modify the test cases or adjust the business code.

[0068] S112: Obtain code effectiveness evaluation results based on the line number ratio.

[0069] The code effectiveness evaluation result can be obtained by comparing the line ratio with the preset ratio threshold.

[0070] In some embodiments, the code validity evaluation result can be set as valid in response to the line ratio being greater than or equal to a preset ratio threshold. The preset ratio threshold can be an empirical statistical value based on historical software testing. The preset ratio threshold can be set according to the specific application scenario requirements, and this application does not impose any restrictions on this.

[0071] In some embodiments, when there are multiple business codes, that is, when multiple business codes are included, the number of business codes whose line ratio is greater than or equal to a preset ratio threshold can be obtained, that is, the number of business codes whose code validity is valid among the multiple business codes is obtained. If the number is greater than or equal to the preset number threshold, it can be determined that the business code is valid, wherein the preset number threshold is a value less than or equal to the total number of business codes. At this time, in response to the number of business codes whose line ratio is greater than or equal to the preset ratio threshold being greater than or equal to the preset number threshold, the code validity evaluation result can be set to valid.

[0072] In some embodiments, the business code can be further divided into a primary business code and an auxiliary business code. In this case, the number of primary business code lines whose ratio is greater than or equal to a preset ratio threshold can be obtained. If the number is greater than the preset number threshold, the code validity evaluation result is set to valid in response to the number of primary business codes whose ratio is greater than or equal to the preset ratio threshold being greater than or equal to the preset number threshold.

[0073] In some implementations, the validity of multiple test units of a business code can refer to the case where the number of the business codes is multiple, which will not be repeated here.

[0074] In this embodiment, the ratio of the number of lines of code used in the test case during the test process of the business code to the total number of lines of business code can be obtained, and the code validity evaluation result can be obtained based on the line ratio. This can accurately obtain the validity of the business code and save users time in excluding the business code. In addition, if the coverage of the business code is too low, the test case can be adjusted to improve the availability and accuracy of the test case.

[0075] In some embodiments, see Figure 4 , step S12 of the above embodiment can be further expanded. Based on the assertion content of the test case, the assertion validity evaluation is performed to obtain the assertion validity evaluation result. This embodiment may include the following steps:

[0076] S121: In response to the to-be-asserted value and the expected value in the assertion content being equal to each other, setting the assertion validity evaluation result as valid.

[0077] In some embodiments, the value to be asserted and the expected value in the assertion content are compared. If the data values, data types, logical validation, etc. of the value to be asserted and the expected value are equal to each other, the assertion validity evaluation result can be set to valid in response to the value to be asserted and the expected value in the assertion content being equal to each other.

[0078] In some implementations, when the value to be asserted of the assertion content is equal to the expected value in terms of numerical value and data type, a logical check may be performed. When performing the logical check, the return result of the business code or the business code may be referenced.

[0079] In some embodiments, at least one of the value to be asserted and the expected value in the assertion content references the return result of the business code, and the referenced return result of the business code can be an expression corresponding to the assertion content in the business code. By having at least one of the value to be asserted and the expected value in the assertion content reference the return result of the business code, the actual result of the assertion content of the test case can be asserted. Therefore, when the value to be asserted and the expected value are equal to each other, the assertion validity evaluation result is set to valid.

[0080] S122: In response to the return result that neither the to-be-asserted value nor the expected value in the assertion content references the business code, the assertion validity evaluation result is set to invalid.

[0081] In some embodiments, if neither the value to be asserted nor the expected value in the assertion content references the return result of the business code, it can indicate that the actual result of the test case, that is, the assertion content, is not asserted. In response to the fact that neither the value to be asserted nor the expected value in the assertion content references the return result of the business code, the assertion validity evaluation result can be set to invalid.

[0082] In some embodiments, if the asserted value and the expected value in the assertion content are not equal, and / or the asserted value and the expected value in the assertion content do not reference the return result of the business code, the assertion validity evaluation result is set to invalid.

[0083] In this embodiment, by determining that the value to be asserted and the expected value in the assertion content are equal to each other, the assertion validity evaluation result is set to valid. If neither the value to be asserted nor the expected value in the assertion content references the return result of the business code, the assertion validity evaluation result is set to invalid. This allows for more accurate assertion validity evaluation of the test case, and allows the actual result of the test case to be asserted.

[0084] In some embodiments, see Figure 5 , step S13 of the above embodiment can be further expanded. Combining the code validity evaluation results and the assertion validity evaluation results to determine the case validity of the test case, this embodiment may include the following steps:

[0085] S131: In response to the code validity evaluation result and the assertion validity evaluation result both being valid, the test case is determined to be a valid case.

[0086] If both the code validity evaluation result and the assertion validity evaluation result are valid, the test case can be determined to be valid. In response to both the code validity evaluation result and the assertion validity evaluation result being valid, the test case can be determined to be a valid case.

[0087] S132: In response to at least one of the code validity evaluation result and the assertion validity evaluation result being invalid, determine the test case as an invalid case.

[0088] If at least one of the code validity evaluation result and the assertion validity evaluation result is invalid, the test case can be judged to be invalid. In response to at least one of the code validity evaluation result and the assertion validity evaluation result being invalid, the test case can be judged as an invalid case.

[0089] For example, if the code validity evaluation result is invalid; or the assertion validity evaluation result is invalid; or, the code validity evaluation result is invalid and the assertion validity evaluation result is invalid; then the test case can be judged as an invalid case.

[0090] Regarding the above embodiment, the present application provides a test case effectiveness evaluation device as follows. The details are as follows:

[0091] See also Figure 6 , Figure 6 2 is a schematic diagram of an embodiment of a test case validity evaluation device provided by the present application. The test case validity evaluation device 20 includes a code validity evaluation module 21, an assertion validity evaluation module 22 and a case validity evaluation module 23.

[0092] The code validity evaluation module 21 is used to perform code validity evaluation on the coverage of the business code based on the test cases to obtain a code validity evaluation result.

[0093] The assertion validity evaluation module 22 is used to perform assertion validity evaluation based on the assertion content of the test case to obtain an assertion validity evaluation result.

[0094] The case validity evaluation module 23 is used to integrate the code validity evaluation results and the assertion validity evaluation results to determine the case validity of the test case.

[0095] In some embodiments, the code validity evaluation module 21 is used to perform code validity evaluation on the coverage of the business code based on the test cases, including: obtaining the line ratio between the number of lines of code of the test cases used in the business code during the testing process and the total number of lines of the business code; and obtaining the code validity evaluation result based on the line ratio.

[0096] In some embodiments, the code validity evaluation module 21 is configured to set the code validity evaluation result as valid in response to the line ratio being greater than or equal to a preset ratio threshold.

[0097] In some embodiments, when there are multiple business codes, the code validity evaluation module 21 is used to set the code validity evaluation result to be valid in response to the number of business codes whose line ratio is greater than or equal to a preset ratio threshold being greater than or equal to a preset number threshold.

[0098] In some embodiments, the business code is further divided into main business code and auxiliary business code; the code validity evaluation module 21 is used to set the code validity evaluation result to valid in response to the number of main business codes whose line ratio is greater than or equal to a preset ratio threshold being greater than or equal to a preset number threshold.

[0099] In some embodiments, the assertion validity evaluation module 22 is configured to perform assertion validity evaluation based on the assertion content of the test case, including: setting the assertion validity evaluation result to valid in response to the assertion value and the expected value in the assertion content being equal to each other; and setting the assertion validity evaluation result to invalid in response to the return result that neither the assertion value nor the expected value in the assertion content references business code.

[0100] In some embodiments, the case validity evaluation module 23 is used to integrate the code validity evaluation results and the assertion validity evaluation results, and the steps of determining the case validity of the test case include: in response to both the code validity evaluation results and the assertion validity evaluation results being valid, determining the test case as a valid case; and in response to at least one of the code validity evaluation results and the assertion validity evaluation results being invalid, determining the test case as an invalid case.

[0101] The specific implementation of this embodiment can refer to the implementation process of the above embodiment, which will not be repeated here.

[0102] For the above embodiment, this application provides a computer device, see Figure 7 , Figure 7 3 is a schematic diagram of the structure of an embodiment of a computer device of the present application. The computer device 30 includes a memory 31 and a processor 32, wherein the memory 31 and the processor 32 are coupled to each other, the memory 31 stores program data, and the processor 32 is configured to execute the program data to implement the steps of any embodiment of the test case effectiveness evaluation method described above.

[0103] In this embodiment, the processor 32 may also be referred to as a CPU (Central Processing Unit). The processor 32 may be an integrated circuit chip having signal processing capabilities. The processor 32 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor, or the processor 32 may be any conventional processor.

[0104] The specific implementation of this embodiment can refer to the implementation process of the above embodiment, which will not be repeated here.

[0105] The method of the above embodiment can be implemented in the form of a computer program, so this application proposes a computer readable storage medium, please refer to Figure 8 , Figure 8 1 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention. The computer-readable storage medium 40 stores program data 41 that can be executed by a processor. The program data 41 can be executed by the processor to implement the steps of any embodiment of the above-mentioned test case effectiveness evaluation method.

[0106] The computer-readable storage medium 40 in this embodiment can be a medium that can store program data 41, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or it can also be a server that stores the program data 41. The server can send the stored program data 41 to other devices for execution, or it can also execute the stored program data 41 by itself.

[0107] The specific implementation of this embodiment can refer to the implementation process of the above embodiment, which will not be repeated here.

[0108] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation methods described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0109] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0110] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0111] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium, which is a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the various embodiments of the present application.

[0112] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be implemented using a general-purpose computing device. They can be concentrated on a single computing device or distributed across a network consisting of multiple computing devices. Alternatively, they can be implemented using program code executable by the computing device, so that they can be stored in a computer-readable storage medium and executed by the computing device, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0113] The above description is merely an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for evaluating the effectiveness of a test case, characterized in that: The method comprises: Perform code validity evaluation on the coverage of the business code based on the test case to obtain a code validity evaluation result; wherein, the coverage is full coverage or incremental coverage, the full coverage represents the coverage of all business codes, and the incremental coverage represents the coverage of the added business codes; if there are multiple business codes, including: respectively obtaining the line ratio between the number of code lines of the test case used in the test process of multiple business codes and the total number of lines of the business code; in response to the number of business codes being greater than or equal to a preset ratio threshold and the number of business codes being greater than or equal to a preset number threshold, setting the code validity evaluation result to be valid; Performing an assertion validity evaluation based on the assertion content of the test case to obtain an assertion validity evaluation result, including: in response to the to-be-asserted value and the expected value in the assertion content being equal to each other, further performing a logic check, and if at least one of the to-be-asserted value and the expected value in the assertion content references a return result of the business code, setting the assertion validity evaluation result to be valid; Determining the case validity of the test case by combining the code validity evaluation result and the assertion validity evaluation result; If the case validity of the test case is invalid, the test case is adjusted.

2. The method according to claim 1, characterized in that If the number of the business code is single, the step of evaluating the coverage of the business code based on the test case includes: Obtaining the ratio of the number of lines of code of the test case used in the business code during the test process to the total number of lines of the business code; The code effectiveness evaluation result is obtained based on the line number ratio.

3. The method according to claim 2, characterized in that The step of obtaining the code validity evaluation result based on the line number ratio includes: In response to the line number ratio being greater than or equal to a preset ratio threshold, the code validity evaluation result is set as valid.

4. The method according to claim 1, wherein The service code is further divided into a primary service code and an auxiliary service code; In response to the number of the business codes having the line number ratio being greater than or equal to a preset ratio threshold being greater than or equal to a preset number threshold, the step of setting the code validity evaluation result as valid comprises: In response to the number of main business codes whose row number ratio is greater than or equal to a preset ratio threshold and the number of main business codes being greater than or equal to a preset number threshold, the code validity evaluation result is set to valid.

5. The method according to claim 1, wherein The step of determining the case validity of the test case by integrating the code validity evaluation result and the assertion validity evaluation result comprises: In response to both the code validity evaluation result and the assertion validity evaluation result being valid, determining the test case as a valid case; In response to at least one of the code validity evaluation result and the assertion validity evaluation result being invalid, the test case is determined to be an invalid case.

6. A computer device, characterized in that: The method comprises a memory and a processor coupled to each other, wherein the memory stores program data, and the processor is configured to execute the program data to implement the steps of the method according to any one of claims 1 to 5.

7. A computer-readable storage medium, characterized in that Program data that can be executed by a processor is stored, and the program data is used to implement the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Quality evaluation method and device for automatic test case

    CN114297071A