Software verification device and software verification method
The software verification device addresses the challenge of generating test cases with both specification and code coverage by using a device with a specification-coverage test case generation unit and additional test case generation unit, leveraging interface specification information and machine learning to automate the process, resulting in efficient and high code coverage.
Patent Information
- Application Number
- PCT/JP2024/004807
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-14
- Filing Date
- 2024-02-13
- Publication Date
- 2024-09-19
AI Technical Summary
Existing software verification methods fail to automatically generate test cases that efficiently cover both software specification and code coverage, requiring significant manual effort and expertise, especially in creating UML activity diagrams for branch conditions.
A software verification device and method that includes a specification-coverage test case generation unit to create test cases covering software specifications, a test execution unit for code coverage analysis, and an additional test case generation unit to increase code coverage based on code coverage information, using a combination of interface specification information and machine learning techniques.
Automatically generates test cases that provide broad software specification coverage with high code coverage, reducing manual effort and expertise requirements while efficiently increasing code coverage.
Smart Images

Figure JP2024004807_19092024_PF_FP_ABST
Abstract
Description
Software verification device and software verification method
[0001] The present invention relates to a software verification device and a software verification method.
[0002] INCORPORATION BY REFERENCE This application claims priority to Japanese Patent Application No. 2023-039456, filed March 14, 2023, the contents of which are incorporated herein by reference. In order to discover software defects and improve its quality, it is necessary to verify the software by conducting tests on the software. As the number of software test cases increases, the time and computing resources required to conduct the tests increase. Therefore, it is desirable to prepare test cases that efficiently discover defects with a small number of cases. However, there is a problem in that designing and implementing such efficient test cases by software developers requires a large amount of man-hours. To solve this problem, a technology for automatically generating test cases for software verification has been disclosed.
[0003] Non-Patent Document 1 discloses a technique for automatically generating test cases using the Pairwise method (referred to as Covering Array in Non-Patent Document 1) from interface specification information described using OpenAPI, which is one of the specification description languages for APIs (Application Programming Interfaces). Non-Patent Document 1 discloses that by using the Pairwise method, test cases are generated that efficiently cover all combinations of Web API parameters defined in the interface specification information.
[0004] Furthermore, Patent Document 1 discloses a technique for extracting branch conditions from an activity diagram in UML (Uniformed Modeling Language) and generating test cases that cover all branches. Patent Document 1 also discloses generating test cases that increase code coverage, which indicates which paths in source code have been taken, by executing the test cases.
[0005] International Publication No. 2016 / 170937
[0006] Huayao Wu, Lixin Xu, Changhai Nie, “Combinatorial testing of RESTful APIs”, Proceedings of 44th International Conference on Software Engineering, May 2022, pp. 426-437.
[0007] When evaluating software quality, there are two ways to evaluate it: from the perspective of specification coverage, which is the extent to which combinations of software specifications have been covered through testing, and from the perspective of code coverage, which is the percentage of code in the source code that has been executed.
[0008] The above-mentioned techniques have a problem in that they are unable to automatically generate test cases that efficiently satisfy both the requirements for completeness of specifications and code coverage. For example, the technique disclosed in Non-Patent Document 1 does not take code coverage into consideration when generating test cases, and therefore is unable to generate test cases that efficiently increase code coverage.
[0009] Furthermore, the technology disclosed in Patent Document 1 requires the creation of a UML activity diagram that describes branching conditions within the source code, which has the problem that it can only be created by a developer who has a deep understanding of the contents of the source code.
[0010] The present invention has been made in consideration of the above circumstances, and its purpose is to provide a software verification device and a software verification method that can automatically generate test cases that cover a wide range of software specifications and have high code coverage.
[0011] One aspect of the present invention for solving the above-mentioned problems is a software verification device that includes: a specification coverage test case generation unit having a processor and a memory, which generates test cases that cover all combinations of factors extracted from specification information of the software to be tested; a test execution unit that runs tests on the software using the generated test cases and generates code coverage information of the software for the executed test cases; and an additional test case generation unit that generates additional test cases that increase code coverage more than the test cases related to the code coverage information, based on the relationship between the factors or levels of the factors in the test cases generated by the specification coverage test case generation unit and the generated code coverage information.
[0012] According to the present invention, it is possible to automatically generate test cases that cover a wide range of software specifications and have high code coverage. Other configurations and effects will become clear from the following description of the embodiments.
[0013] FIG. 1 is a diagram illustrating an example of the configuration of a software verification device according to a first embodiment of the present invention. FIG. 2 is a diagram illustrating an example of interface specification information. FIG. 3 is a diagram illustrating an example of a test case. FIG. 4 is a diagram illustrating an example of code coverage information. FIG. 5 is a diagram illustrating a flow of processing performed by the software verification device according to the first embodiment of the present invention. FIG. 6 is a diagram illustrating an example of the functional configuration of the software verification device according to a second embodiment of the present invention. FIG. 7 is a diagram illustrating an example of Pairwise generation parameters. FIG. 8 is a diagram illustrating an overview of processing performed by the software verification device. FIG. 9 is a process flow diagram illustrating an example of parameter update processing performed by a coverage learning unit. FIG. 10 is a process flow diagram illustrating another example of parameter update processing performed by the coverage learning unit. FIG. 11 is a diagram illustrating an example of a test result display screen generated by a test result display unit.
[0014] Embodiments of the present invention will be described in detail below with reference to the drawings. The following description and drawings are illustrative of the present invention, and appropriate omissions and simplifications have been made for clarity. The present invention can be implemented in various other forms. Unless otherwise specified, each component may be singular or plural. The position, size, shape, and range of each component shown in the drawings may not represent the actual position, size, shape, and range in order to facilitate understanding of the invention. Therefore, the present invention is not necessarily limited to the position, size, shape, and range disclosed in the drawings. In the following description, various information may be described using terms such as "table," "list," and "queue," but the information may be expressed using other data structures. To indicate independence from these data structures, "XX table," "XX list," and the like may be referred to as "XX information." When describing identification information, terms such as "identification information," "identifier," "name," "ID," and "number" are used, but these terms are interchangeable. When there are multiple components having the same or similar functions, the same reference numeral may be used with different subscripts. However, when it is not necessary to distinguish between these multiple components, the subscripts may be omitted. Furthermore, the following description may describe processing performed by executing a program. However, since the program is executed by a processor (e.g., a CPU or a GPU) to perform a predetermined process using storage resources (e.g., memory) and / or interface devices (e.g., communication ports) as appropriate, the processor may be the subject of the processing. Similarly, the subject of processing performed by executing a program may be a controller, device, system, computer, or node having a processor. The subject of processing performed by executing a program may be any computing unit and may include a dedicated circuit (e.g., an FPGA or an ASIC) that performs a specific process. A program may be installed into a device such as a computer from a program source. The program source may be, for example, a program distribution server or a computer-readable storage medium.If the program source is a program distribution server, the program distribution server may include a processor and a storage resource for storing the program to be distributed, and the processor of the program distribution server may distribute the program to be distributed to other computers. Also, in the following description, two or more programs may be realized as one program, and one program may be realized as two or more programs.
[0015] First Embodiment First, a software verification device and a software verification method according to a first embodiment of the present invention will be described.
[0016] FIG. 1 is a diagram showing an example of the configuration of a software verification device 100 according to a first embodiment of the present invention. The software verification device 100 is realized by an information processing device including one or more computers. In addition to a configuration example in which the software verification device 100 implements a user interface on its own, the software verification device 100 may also use a user terminal connected via an appropriate network as the user interface. In this case, the user terminal is a terminal device operated by a software developer, tester, or the like. Specifically, this user terminal may be a personal computer, a smartphone, a tablet terminal, or the like.
[0017] The software verification device 100 is an information processing device arranged in a test environment for software to be verified by testing (hereinafter referred to as "target software") The software verification device 100 automatically generates efficient test cases required for testing the target software and outputs the results of tests executed based on the generated test cases.
[0018] As shown in the figure, the software verification device 100 includes a storage device 200, an arithmetic device 250, a memory 260, and an input / output device 270. The storage device 200, the arithmetic device 250, the memory 260, and the input / output device 270 are communicatively connected to one another via a bus.
[0019] The arithmetic device 250 is a CPU (Central Processing Unit) that executes the program 210 stored in the storage device 200 by reading it into a memory 260, thereby controlling the entire device and performing various determinations, calculations, and control processes. The memory 260 is composed of a volatile memory element such as a RAM (Random Access Memory) or a ROM (Read Only Memory).
[0020] The input / output device 270 is a device that accepts key inputs and voice inputs from the user and displays processing data. For example, the input / output device 270 may include input devices such as a keyboard, mouse, touch panel, and microphone, and a display device such as a liquid crystal display (LCD) or an organic electroluminescence (EL) display, or a print output device such as a printer. The input / output device 270 may also include a network interface card that connects to an appropriate network and handles communication processing with a user terminal.
[0021] The storage device 200 is configured with an appropriate nonvolatile storage element such as an SSD (Solid State Drive), a hard disk drive, etc. The storage device 200 stores at least the source code 11 of the target software, interface specification information 12, test cases 111 (to be described later), test result information 121 (to be described later), code coverage information 122 (to be described later), and additional test cases 141 (to be described later), in addition to a program 210 for implementing the functions required for the software verification device 100 of this embodiment.
[0022] Inputs to the software verification device 100 include source code 11 of the target software and interface specification information 12. The interface specification information 12 is specification information that includes information necessary to generate factors and levels (factor values) used in testing the target software. Factors are the types of parameters and elements to be tested in the software. Levels are values or representative values that are allowed to be input to the factors.
[0023] 2 is a diagram showing an example of the interface specification information 12. The interface specification information 12 shown in the figure is information that describes each parameter ("ParamA" and "ParamB") that is a factor, the type of each parameter, the range of values that each parameter can take, the number of parameters, etc. For example, the parameter "ParamA" is an int type and has a value of 0 or greater.
[0024] For example, in the case of a web service, a specification description based on the OpenAPI specification description can be used as the interface specification information 12. The method disclosed in Non-Patent Document 1 can be used to generate factors and levels from the OpenAPI specification description.
[0025] Next, as shown in FIG. 1, the program 210 includes programs for realizing the specification coverage test case generation unit 110, the test execution unit 120, the test result display unit 130, and the additional test case generation unit 140, respectively.
[0026] The specification coverage test case generation unit 110 executes a specification coverage test case generation process to generate test cases 111 that cover the specifications of the target software based on the interface specification information 12 .
[0027] 3 is a diagram showing an example of the test case 111. In the test case 111 shown in the diagram, the factor "ParamA" is set to a level "0" and the factor "ParamB" is set to a level "a."
[0028] The test execution unit 120 executes a test execution process that executes tests on the target software using the source code 11 of the verification software and the test cases 111 generated by the specification coverage test case generation unit 110. When executing a test, the test execution unit 120 also acquires code coverage, which indicates which paths in the source code 11 were executed by the execution of the test case. As a result, the test execution unit 120 outputs test result information 121, which includes information on whether the test case was successful or not, and information including code coverage information 122 for the test case.
[0029] The test result information 121 includes information such as whether each test case 111 was successful (OK) or failed (NG), the number of successful test cases 111, and the number of failed test cases 111.
[0030] 4 is a diagram showing an example of code coverage information 122. The code coverage information 122 includes code coverage information for each file in the source code 11 and each function included in each file for each test case 111. The code coverage information 122 shown in the figure includes code coverage of file A of 70%, code coverage of file B of 50%, and code coverage of file C of 90%. Code coverage is the percentage of the source code 11 that has been tested. The code coverage measurement method may be any method, such as instruction coverage, branch coverage, condition coverage, complex condition coverage, or path combination coverage.
[0031] The test result display unit 130 displays the contents, including the test result information 121 and the code coverage information 122, output by the test execution unit 120 on a screen so that a user such as a developer can check them. Furthermore, if the user uses a project management tool for managing the development status of the project, the test result display unit 130 may send information to the project management tool.
[0032] The additional test case generation unit 140 performs an additional test case generation process to generate an additional test case 141 that increases code coverage even more than the test case 111 related to the code coverage information 122 by identifying the factors or levels that contribute to an increase in code coverage based on the relationship between the factors or levels of the factors in the test case 111 and the code coverage information 122 obtained using the test case 111.
[0033] In addition to a configuration example in which each of the constituent functions of the software verification device 100 is arranged within a single information processing device, the functions may also be distributed and arranged across multiple information processing devices connected via a network or across computing resources on the cloud.
[0034] 5 is a diagram illustrating the flow of processing performed by the software verification device 100 according to the first embodiment of the present invention. As shown in the figure, first, the specification coverage test case generation unit 110 generates test cases 111 that cover the specifications of the target software based on the interface specification information 12 (S11). This processing may be initiated, for example, when a user inputs a predetermined value to the software verification device 100, or at a predetermined timing (e.g., a predetermined time or a predetermined time interval). For example, the specification coverage test case generation unit 110 may initiate this processing when the user specifies the interface specification information 12 of the target software and has the software verification device 100 load the specified value.
[0035] For example, the specification coverage test case generation unit 110 may generate test cases that cover all combinations of factors and levels defined in the interface specification information 12, or may generate test cases by a method of randomly generating values for each factor. Also, known combinatorial testing techniques for generating test cases for effective combination testing include a method using an orthogonal array or a method using the Pairwise method (All-Pair method) described below, and the specification coverage test case generation unit 110 may generate test cases using these methods.
[0036] Next, the test execution unit 120 acquires the source code 11 of the target software (S12). Then, the test execution unit 120 executes a test on the target software using the test cases 111 generated in S11 and the source code 11 of the verification software acquired in S12 (S13). For example, the test execution unit 120 sets the combinations of factors and levels in the test cases 111 as initial values for the source code 11, and executes the source code 11 with these initial values set.
[0037] When executing a test, the test execution unit 120 also acquires the code coverage of the test case 111 and outputs the code coverage information 122 together with the test result information 121 .
[0038] One method for acquiring code coverage in the test execution unit 120 is to execute a test after performing a program conversion on the source code 11, such as inserting code that outputs information to a log about whether or not each line in the source code 11 has been executed. Alternatively, the test execution unit 120 may acquire code coverage by using a computing device 250 that has a function for acquiring information about the execution position of a program.
[0039] Next, the test result display unit 130 displays on the screen the contents including the test result information 121 and the code coverage information 122 output by the test execution unit 120 (S14).
[0040] Meanwhile, the additional test case generation unit 140 generates an additional test case 141 that further increases code coverage based on the test case 111 and the code coverage information 122 obtained using the test case 111 (S15). The additional test case generation unit 140 may use a technique of changing the generation parameters of the Pairwise method described below, or may generate an additional test case 141 that includes, as test targets, a level of the selected factor that contributes to an increase in code coverage, and a combination of other factors and the levels of the other factors. Alternatively, the additional test case generation unit 140 may identify factors and their levels that execute paths that have not been executed based on the code coverage information 122 that indicates which paths in the source code 11 have been executed, and generate an additional test case 141 that includes the identified factors and their levels as test targets.
[0041] Alternatively, the additional test case generation unit 140 may generate the additional test cases 141 using a trained model. For example, the additional test case generation unit 140 performs machine learning to create a model in which input values are factors and levels and output values are code coverage. The trained model is constructed based on, for example, a neural network, a decision tree, a random forest, or a support vector machine (SVM) algorithm.
[0042] When the additional test case generation unit 140 generates the additional test case 141, the test execution unit 120 executes a test on the generated additional test case 141 and generates test result information 121 and code coverage information 122. The test result display unit 130 also displays the contents of the execution result of the test on the additional test case 141.
[0043] Furthermore, the additional test case 141 and the code coverage information 122 generated for the additional test case 141 can be used to generate a further additional test case 141 in the additional test case generation unit 140. The generation of the additional test case 141 and the test execution of the generated additional test case 141 can be repeated until a desired code coverage is obtained. Furthermore, the software verification device 100 may repeat the generation and execution of the additional test case 141 until a specified test execution time is reached.
[0044] As described above, the software verification device 100 of this embodiment includes: a specification coverage test case generation unit 110 that generates test cases 111 that cover all combinations of factors extracted from interface specification information 12 of the software to be tested; a test execution unit 120 that executes tests on the software using the generated test cases 111 and generates code coverage information 122 of the software for the executed test cases 111; and an additional test case generation unit 140 that generates additional test cases that increase code coverage more than the test cases 111 related to the code coverage information 122, based on the relationship between the factors in the test cases 111 or the levels of the factors and the generated code coverage information 122.
[0045] That is, the software verification device 100 of this embodiment acquires code coverage information 122 based on test cases that cover all combinations of factors in accordance with the interface specifications, and can generate additional test cases that increase code coverage based on the acquired code coverage information 122 and the factors or levels of the test cases 111. This makes it possible to automatically generate test cases that widely cover the software specifications and have high code coverage.
[0046] Second Embodiment Next, a software verification device and a software verification method according to a second embodiment of the present invention will be described.
[0047] The configuration of the software verification device 100 in this embodiment is the same as that of the software verification device 100 in the first embodiment, and therefore a description thereof will be omitted. Also, in the software verification device 100 in this embodiment, as in the first embodiment, the arithmetic device 250 loads a program 210 stored in advance in the storage device 200 into the memory 260 and executes it, thereby realizing the respective functions of a pairwise test case generation unit 115, a test execution unit 120, a test result display unit 130, and a coverage learning unit 150, which will be described later. The pairwise test case generation unit 115 corresponds to the specification coverage test case generation unit 110, and the pairwise test case generation unit 115 and the coverage learning unit 150 correspond to the additional test case generation unit 140.
[0048] 6 is a diagram showing an example of the functional configuration of a software verification device 100 according to the second embodiment of the present invention. In this diagram, the same components as those in the software verification device 100 according to the first embodiment are denoted by the same reference numerals, and their description will be omitted.
[0049] As shown in the figure, the software verification device 100 is composed of a pairwise test case generation unit 115, a test execution unit 120, a test result display unit 130, and a coverage learning unit 150. As in the first embodiment, the input to the software verification device 100 includes source code 11 of the target software and interface specification information 12.
[0050] The Pairwise test case generation unit 115 generates test cases 111 by the Pairwise method using information on factors and levels obtained from the interface specification information 12 and Pairwise generation parameters 151 .
[0051] The Pairwise method is a technique for generating n-factor coverage test cases for a specified coverage level n. n-factor coverage means that the generated test cases execute a test at least once for each level of the n factors included in any n-factor combination of factors to be verified. For example, one-factor coverage means that the executed test cases execute a test at least once for each level of each factor to be tested. Similarly, two-factor coverage means that the executed test cases execute a test at least once for each level of each of the two factors included in a two-factor combination of factors to be verified.
[0052] In the Pairwise method, the coverage n can be specified as a common n for all factors, or a different coverage can be specified for each factor, thereby increasing or decreasing the coverage when a specific factor is included. A specific means for generating test cases using the Pairwise method can be the method disclosed in Japanese Patent No. 2882687, for example. For example, the Pairwise test case generation unit 115 generates test cases by a method such as listing test cases for each relationship between factors and combining test cases for different relationships to create a single test case.
[0053] 7 is a diagram illustrating an example of the pairwise generation parameters 151. The pairwise generation parameters 151 include information on the coverage and number of levels of each factor. In the pairwise generation parameters 151 illustrated in the figure, the number of levels is set to "4" and the coverage is set to "2" for each of the parameters (ParamA, ParamB, ParamC, and ParamD) that are factors.
[0054] As a method for setting the initial values of the Pairwise generation parameters 151, a method for setting a certain degree of coverage and number of levels for all factors in advance, or a method for the user to individually specify them may be used.
[0055] The coverage learning unit 150 updates the value of the pairwise generation parameter 151 based on the relationship between the test case 111 and the code coverage information 122 obtained using the test case 111 so as to increase the code coverage compared to the test case 111 related to the code coverage information 122. Details of the processing by the coverage learning unit 150 will be described later.
[0056] When the pairwise generation parameters 151 are updated, the pairwise test case generation unit 115 adds a test case 111 that reflects the updated pairwise generation parameters 151. The test execution unit 120 executes a test on the added test case 111 and generates test result information 121 and code coverage information 122.
[0057] The coverage learning unit 150 can further update the pairwise generation parameters 151 using the added test cases 111 and the code coverage information 122 for the added test cases 111. Addition of test cases 111, test execution of the generated test cases 111, and updating of the pairwise generation parameters 151 can be repeated until a desired code coverage is obtained. Furthermore, the software verification device 100 may repeat adding and executing test cases 111 until a specified test execution time is reached.
[0058] 8 and 9 are diagrams illustrating an overview of the processing performed by the software verification device 100. The software verification device 100 executes the processing shown in these figures, for example, when a predetermined input is made to the software verification device 100 by a user, or at a predetermined timing (for example, a predetermined time or a predetermined time interval). For example, the software verification device 100 may execute the processing shown in these figures when a user specifies the source code 11 and interface specification information 12 of the target software and causes them to be read into the software verification device 100.
[0059] First, the pairwise test case generation unit 115 of the software verification device 100 extracts factors to be tested and the levels of each factor from the interface specification information 12 (S90 in FIG. 9). In the example shown in FIG. 8, the pairwise test case generation unit 115 extracts the factors "paramA" and "paramB" from the interface specification information 12, extracts the levels "0", "50", and "100" of the factor "paramA", and extracts the levels "'', "'a'", and "'bc'" of the factor "paramB".
[0060] Next, the Pairwise test case generation unit 115 generates factor coverage test cases 111 by the Pairwise method using the Pairwise generation parameters 151 (S100 in FIG. 9). In the example shown in FIG. 8, the test cases 111 include test cases in which the factor "paramA" is set to level "0" and the factor "paramB" is set to level "'a'".
[0061] Next, the test execution unit 120 executes tests on the generated test cases 111 and generates test result information 121 and code coverage information 122 (S200 in FIG. 9). In the example shown in FIG. 8, the code coverage information 122 indicates that the code coverage of file A is "70%", the code coverage of file B is "50%, and the code coverage of file C is "90%".
[0062] Next, the test result display unit 130 displays information indicating the test execution results, including the generated test result information 121 and the code coverage information 122, on the screen (S300 in FIG. 9).
[0063] Next, the coverage learning unit 150 determines whether the test termination condition is met (S400 in FIG. 9 ). For example, the coverage learning unit 150 may refer to the code coverage information 122 and determine that the termination condition is met if the code coverage of all files or functions is equal to or greater than a preset threshold (e.g., 60%). The threshold for comparison with the code coverage is set in advance by the user. Alternatively, the coverage learning unit 150 may determine that the termination condition is met if a preset test execution time has elapsed since the first test was executed. The test execution time is set in advance by the user. Alternatively, the coverage learning unit 150 may determine that the termination condition is met if the number of updates to the Pairwise generation parameters 151 is equal to or greater than a preset threshold. The threshold for comparison with the number of updates is set in advance by the user. Alternatively, the coverage learning unit 150 may determine that the termination condition is met when a predetermined input is received from the user.
[0064] If the coverage learning unit 150 determines that the termination condition is not satisfied (S400: No in FIG. 9 ), it executes a parameter update process to update the values of the pairwise generation parameters 151 so as to increase the code coverage, using the relationship between the test case 111 and the code coverage information 122 obtained using the test case 111 (S500 in FIG. 9 ). For example, in the example shown in FIG. 8 , if changing the level of the factor "paramA" does not change the code coverage of file B, which has low code coverage, but changing the level of the factor "paramB" increases the code coverage of file B, the coverage learning unit 150 adds a level to the factor "paramB" in the pairwise generation parameters 151. Then, the software verification device 100 returns to the process of S100 in FIG. 9 .
[0065] On the other hand, if the coverage learning unit 150 determines that the termination condition is satisfied (S400 in FIG. 9: Yes), it terminates this processing.
[0066] In this way, it is possible to increase the code coverage in the test by updating the values of the Pairwise generation parameters 151. Next, the parameter update process executed by the coverage learning unit 150 will be described in detail.
[0067] 10 is a process flow diagram illustrating an example of the parameter update process S500 executed by the coverage learning unit 150. The process example shown in this figure illustrates an example of a method for updating the value of the number of levels in the Pairwise generation parameters 151 using the test cases 111 and the code coverage information 122. In this example, the coverage learning unit 150 identifies one or more factors that contribute to an increase in code coverage, and generates additional test cases by increasing the number of levels for the identified factors.
[0068] First, the coverage learning unit 150 determines a file or function (hereinafter referred to as a "target file or target function") for which code coverage is to be increased (S501). Methods for determining the target file or target function include, for example, a method in which a user such as a developer or tester specifies the file or function, or a method in which a file or function that does not satisfy a preset code coverage standard is automatically selected and determined.
[0069] Next, the coverage learning unit 150 selects one factor extracted from the interface specification information 12 (S502).
[0070] Next, the coverage learning unit 150 compares the changes (differences) in code coverage of the target file or target function between test cases that have different levels set for the selected factor, and then calculates the sum of the changes in code coverage for all combinations of test cases that have different levels set (S503).
[0071] Next, the coverage learning unit 150 determines whether there are any remaining factors for which the amount of change in code coverage has not been calculated (factors for which the process of S503 has not been executed) (S504).
[0072] If there are remaining factors (S504: Yes), the coverage learning unit 150 selects another factor and repeats the processes of S502 and S503 to calculate the amount of change in code coverage for each factor.
[0073] On the other hand, if there are no remaining factors (the change in code coverage for all factors has been calculated) (S504: No), the coverage learning unit 150 selects the factor that maximizes the sum of the change in code coverage calculated for each factor, and increases the number of levels for that factor in the pairwise generation parameters 151 by 1 (S505). After that, the coverage learning unit 150 ends this first parameter update process.
[0074] For factors that cause large changes in code coverage in a target file or target function when their values change, adding a test case with a new level for that factor is expected to increase the code coverage rate by providing code coverage that differs from the existing code coverage. Therefore, in the first parameter update process, the coverage learning unit 150 increases the number of levels for the factor with the largest change in code coverage and generates test cases with the new levels set, thereby efficiently increasing code coverage.
[0075] In the above processing example, the coverage learning unit 150 selects one factor for which to increase the number of levels, but this is not limited to this and the number of levels may be increased for multiple factors. For example, the coverage learning unit 150 may increase the number of levels for a predetermined number of factors in descending order of the amount of change in code coverage, or may increase the number of levels for all factors for which the amount of change in code coverage is equal to or greater than a predetermined value. Furthermore, the value by which the number of levels is increased is not limited to 1, but may be 2 or more.
[0076] <Second Parameter Update Process> Figure 11 is a process flow diagram illustrating another example of the parameter update process S510 executed by the coverage learning unit 150. This diagram illustrates a process example different from the first parameter update process illustrated in Figure 10. The process example illustrated in this diagram illustrates one method of updating the coverage value in the Pairwise generation parameters 151 using the test cases 111 and the code coverage information 122. In this example, the coverage learning unit 150 identifies a level of the selected factor at which the code coverage is greater than other levels, and generates additional test cases that include, as test targets, a combination of the selected factor and the identified level, and a combination of other factors and the levels of the other factors.
[0077] First, the coverage learning unit 150 determines a target file or a target function for which code coverage is to be increased (S511). The method for determining the target file or the target function is the same as that described above in S501, and therefore a description thereof will be omitted.
[0078] Next, the coverage learning unit 150 selects one of the factors defined in the interface specification information 12 (S512). The method of selecting a factor may be a method in which a user such as a developer or tester specifies the factor, a method similar to the method of selecting a factor whose level is to be updated in the first parameter update process, or a method of random selection.
[0079] Next, the coverage learning unit 150 selects one of the levels of the selected factor (S513), and calculates the sum of the code coverage of the target files or target functions for the test cases for which the selected level is set (S514).
[0080] Next, the coverage learning unit 150 determines whether or not there are any remaining levels for which the sum of code coverage has not been calculated (levels for which the process of S514 has not been executed) for the selected factors (S515).
[0081] If there are remaining levels (S515: Yes), the coverage learning unit 150 selects another level and repeats the processes of S513 and S514 to calculate the sum of code coverage for each level.
[0082] On the other hand, if there are no remaining levels (the sum of code coverages for all levels of the selected factor has been calculated) (S515: No), the coverage learning unit 150 selects the level that maximizes the sum of the code coverages calculated for each level. Then, for the factor having the selected level, the coverage in the Pairwise generation parameters 151 is increased by 1 under the constraint that the level is the selected level (S516). The coverage learning unit 150 then terminates this second parameter update process.
[0083] For example, in source code that changes the function to be called depending on the value of a factor, if a specific value is specified for that factor, changing the values of other factors often does not increase the code coverage of the called function at all. On the other hand, for existing test cases with a relatively high level of code coverage, changing the values of other factors while maintaining that level is expected to increase the coverage. Therefore, in this second parameter update process, the coverage learning unit 150 fixes the level with the largest total code coverage and then increases the coverage, adding test cases with that level and efficiently increasing the code coverage.
[0084] In the above-described processing example, the coverage learning unit 150 increases the coverage of the factor having the level that maximizes the sum of code coverages, but this is not limiting. The coverage of multiple factors (for example, all factors) may be increased under the constraint that the level that maximizes the sum of code coverages is fixed. Furthermore, the value by which the coverage is increased is not limited to 1, but may be 2 or more.
[0085] The first parameter update process shown in Fig. 10 and the second parameter update process shown in Fig. 11 are examples of processes executed by the coverage learning unit 150, and are not limited to these. For example, the process in the coverage learning unit 150 may include both the first parameter update process and the second parameter update process.
[0086] In addition, the processing in the coverage learning unit 150 may determine parameters to be updated using a machine learning algorithm including a random forest, a deep neural network, a support vector machine, or the like.
[0087] 12 is a diagram showing an example of a test result display screen 600 generated by the test result display unit 130. The display example shown in this figure displays the results when the number of levels is set to 4 and the coverage is set to 2 for all factors as the initial pairwise generation parameters 151 for software having an interface with four types of factors (paramA to paramD).
[0088] The test result display screen 600 includes a basic test case result display area 610 and an additional test case result display area 620 .
[0089] The basic test case result display area 610 is an area that displays the results of tests on basic test cases generated by the Pairwise method using the initial Pairwise generation parameters 151. As shown in the figure, the basic test case result display area 610 includes a parameter display area 611, a test result display area 612, and a code coverage display area 613.
[0090] The parameter display area 611 is an area that displays the number of levels and coverage of each factor (parameter) of the initial Pairwise generated parameters 151. In this display example, the number of levels of all factors is "4" and the coverage is "2".
[0091] The test result display area 612 displays the number of successful (OK) test cases and the number of failed (NG) test cases as a result of executing tests on each basic test case. In this example, 50 basic test cases are generated, and the test result display area 612 displays that all of the test cases are successful.
[0092] The code coverage display area 613 is an area that displays the code coverage (in percentages) for each file and function that constitutes the source code 11 of the target software. In this display example, the code coverage target is set to 60%, and the test result display unit 130 highlights in bold the code coverage of files and functions that do not meet the code coverage target in the code coverage display area 613. This allows the user to easily identify files or functions whose code coverage does not meet the target.
[0093] In this example, the coverage learning unit 150 automatically selects files or functions that do not meet the code coverage target as target files and target functions for increasing code coverage. In the case of a method in which the user is allowed to select target files or target functions for increasing code coverage, the coverage learning unit 150 may receive a selection input of the target files or target functions from the user on the test result display screen 600.
[0094] The additional test case result display area 620 is an area that displays the test results for additional test cases that are newly generated by the Pairwise method using the Pairwise generation parameters 151 updated by the coverage learning unit 150. As shown in the figure, the additional test case result display area 620 includes an updated parameter display area 621, an additional test result display area 622, and an updated code coverage display area 623.
[0095] The updated parameter display area 621 is an area that displays the number of levels and coverage of each factor (parameter) of the updated pairwise generation parameters 151. The test result display unit 130 displays the number of levels or coverage that has been changed from the initial pairwise generation parameters 151 in bold and underlined. This allows the user to easily check the values of the updated pairwise generation parameters 151. In this example, the display in the updated parameter display area 621 shows that the number of levels of the factor "paramB" has increased from "4" to "5," and that the coverage of the factor "paramC" has increased from "2" to "3."
[0096] The additional test result display area 622 is an area that displays the number of successful (OK) test cases and the number of failed (NG) test cases as a result of executing each additional test case. In this display example, 30 additional test cases have been added, and the additional test result display area 622 displays that all of the test cases have passed.
[0097] The updated code coverage display area 623 is an area that displays the code coverage for each file and each function that constitutes the source code 11 of the target software, combining the basic test cases and the additional test cases. In this display example, the updated code coverage display area 623 shows that the additional test cases have increased the code coverage of the file "fileA" and the functions in that file, achieving a code coverage of 60% or more.
[0098] The information displayed on the test result display screen 600 is not limited to the above, and may include, for example, line-by-line code coverage information indicating whether each line of a function has been executed by a test case.
[0099] Furthermore, the information contained in the test result display screen 600 may be displayed on the screen via the input / output device 270, or may be printed on paper as a report, or may be notified to users such as developers by sending it as an email via a network, etc.
[0100] Furthermore, the manner in which each item is highlighted on the test result display screen 600 is not limited to the above. For example, the test result display unit 130 may highlight each item by changing the background color or text color.
[0101] As described above, the software verification device 100 of this embodiment extracts each factor of the software and the level of each factor from the interface specification information 12, and generates test cases 111 of a factor coverage test in which a test is executed at least once for each level of each factor included in the extracted combination of factors.
[0102] With this configuration, it is possible to automatically generate test cases 111 that efficiently cover all possible combinations of values for a combination of multiple factors.
[0103] Furthermore, the software verification device 100 of this embodiment generates additional test cases by identifying factors or levels that contribute to an increase in code coverage based on the generated code coverage information 122.
[0104] With this configuration, additional test cases can be generated based on factors or levels that contribute to an increase in code coverage, thereby enabling more efficient generation of additional test cases that increase code coverage.
[0105] Furthermore, the software verification device 100 of this embodiment identifies one or more factors that contribute to an increase in code coverage, and generates additional test cases by increasing the number of levels for the identified factors.
[0106] As described above, for factors that contribute to an increase in code coverage, adding test cases with new levels is expected to increase code coverage. Therefore, by increasing the number of levels of factors that contribute to an increase in code coverage, additional test cases that increase code coverage can be generated more efficiently.
[0107] Furthermore, the software verification device 100 of this embodiment selects a file or function for which code coverage is to be increased, and identifies, among test cases 111 with different levels set, factors that cause a larger change in code coverage for the selected target than other factors, as factors that contribute to the increase in code coverage.
[0108] This configuration allows for more accurate identification of factors that contribute to an increase in code coverage of a target file or function, thereby enabling efficient generation of additional test cases that increase the code coverage of the target file or function.
[0109] Furthermore, the software verification device 100 of this embodiment identifies a level of the selected factor at which code coverage is greater than other levels, and generates additional test cases that include, as test targets, a combination of the selected factor and the identified level, and a combination of other factors and the levels of the other factors.
[0110] As described above, for a relatively high level of code coverage, changing the values of other factors while keeping the level fixed is expected to increase the code coverage. Therefore, by generating additional test cases that include a high level of code coverage, additional test cases that increase the code coverage can be generated more efficiently.
[0111] Furthermore, the software verification device 100 of this embodiment selects a file or function for which code coverage is to be increased, identifies a level of code coverage for the selected target that is greater than other levels, and generates additional test cases that include a combination of the selected factor and the identified level, as well as a combination of other factors and the levels of the other factors, as test targets.
[0112] This configuration allows for more accurate identification of the level that contributes to increasing the code coverage of the target file or function, thereby enabling efficient generation of additional test cases that increase the code coverage of the target file or function.
[0113] The present invention is not limited to the above-described embodiments, and can be implemented using any components within the scope of the present invention. The above-described embodiments and modifications are merely examples, and the present invention is not limited to these contents as long as the characteristics of the invention are not impaired. Furthermore, although various embodiments and modifications have been described above, the present invention is not limited to these contents. Other aspects conceivable within the scope of the technical idea of the present invention are also included within the scope of the present invention.
[0114] For example, part of the hardware provided in each device of this embodiment may be provided in another device.
[0115] Furthermore, each program of the software verification device may be provided in another device, a program may consist of multiple programs, or multiple programs may be integrated into one program.
[0116] 11 Source code 12 Interface specification information 100 Software verification device 110 Specification coverage test case generation unit 111 Test case 115 Pairwise test case generation unit 120 Test execution unit 121 Test result information 122 Code coverage information 130 Test result display unit 140 Additional test case generation unit 141 Additional test case 150 Coverage learning unit 151 Pairwise generation parameters 200 Storage device 210 Program 250 Arithmetic unit 260 Memory 270 Input / output device 600 Test result display screen
Claims
1. A software verification device having a processor and memory, comprising: a specification coverage test case generation unit that generates test cases that cover combinations of factors extracted from specification information of the software to be tested; a test execution unit that executes tests on the software using the generated test cases and generates code coverage information of the software for the executed test cases; and an additional test case generation unit that generates additional test cases that increase code coverage more than the test cases related to the code coverage information, based on the relationship between the factors or levels of the factors in the test cases generated by the specification coverage test case generation unit and the generated code coverage information.
2. The software verification device according to claim 1, wherein the specification coverage test case generation unit extracts each factor of the software and the level of each factor from the specification information, and generates a test case in which a test is performed at least once for each level of each factor included in the extracted combination of factors.
3. The software verification device according to claim 2, wherein the additional test case generation unit generates additional test cases by identifying factors or levels that contribute to an increase in the code coverage based on the generated code coverage information.
4. The software verification device according to claim 3, wherein the additional test case generation unit generates additional test cases by identifying one or more factors that contribute to an increase in code coverage and increasing the number of levels for the identified factors.
5. The software verification device according to claim 4, wherein the additional test case generation unit selects a file or function for which code coverage is to be increased, and identifies, between test cases with different levels set, factors that cause a greater change in code coverage for the selected target than other factors as factors that contribute to the increase in code coverage.
6. The software verification device according to claim 3, wherein the additional test case generation unit identifies a level of the selected factor at which code coverage is greater than other levels, and generates additional test cases that include a combination of the selected factor and the identified level, as well as a combination of other factors and the levels of the other factors, as test targets.
7. The software verification device according to claim 6, wherein the additional test case generation unit selects a file or function for which code coverage is to be increased, identifies a level of code coverage for the selected target that is greater than other levels, and generates additional test cases that include a combination of the selected factor and the identified level as well as a combination of other factors and levels of the other factors as test targets.
8. A software verification method in which an information processing device executes: a specification coverage test case generation process that generates test cases that cover all combinations of factors extracted from specification information of the software to be tested; a test execution process that executes tests on the software using the generated test cases and generates code coverage information of the software for the executed test cases; and an additional test case generation process that generates additional test cases that increase code coverage more than the test cases related to the code coverage information, based on the relationship between the factors or levels of the factors in the generated test cases and the generated code coverage information.
9. The software verification method according to claim 8, wherein the information processing device, in the specification coverage test case generation process, extracts each factor of the software and the level of each factor from the specification information, and generates a test case in which a test is performed at least once for each level of each factor included in the extracted combination of factors.
10. The software verification method according to claim 9, wherein the information processing device, in the additional test case generation process, generates additional test cases by identifying factors or levels that contribute to an increase in the code coverage based on the generated code coverage information.
11. The software verification method according to claim 10, wherein the information processing device, in the additional test case generation process, identifies one or more factors that contribute to an increase in code coverage, and generates additional test cases by increasing the number of levels for the identified factors.
12. The software verification method according to claim 11, wherein the information processing device, in the additional test case generation process, selects a file or function for which code coverage is to be increased, and identifies, between test cases with different levels set, a factor that causes a greater change in code coverage for the selected target than other factors, as a factor contributing to the increase in code coverage.
13. The software verification method according to claim 10, wherein the information processing device, in the additional test case generation process, identifies a level of the selected factor at which code coverage is greater than other levels, and generates additional test cases that include a combination of the selected factor and the identified level, as well as a combination of other factors and the levels of the other factors, as test targets.
14. The software verification method according to claim 13, wherein the information processing device, in the additional test case generation process, selects a file or function for which code coverage is to be increased, identifies a level of code coverage for the selected target that is higher than other levels, and generates additional test cases that include a combination of the selected factor and the identified level as well as a combination of other factors and levels of the other factors as test targets.
Citation Information
Patent Citations
Test case generation device and test case generation method
JP2021163111A
Test design assistance device, test design assistance method, program, and computer read medium
WO2014141510A1
Test automation device, test automation method, and test automation program
WO2016170937A1
