WO2022176027A1 - テストケース生成装置、テストケース生成方法及びテストケース生成プログラム - Google Patents

テストケース生成装置、テストケース生成方法及びテストケース生成プログラム Download PDF

Info

Publication number
WO2022176027A1
WO2022176027A1 PCT/JP2021/005753 JP2021005753W WO2022176027A1 WO 2022176027 A1 WO2022176027 A1 WO 2022176027A1 JP 2021005753 W JP2021005753 W JP 2021005753W WO 2022176027 A1 WO2022176027 A1 WO 2022176027A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
boundary
test case
test
values
Prior art date
Application number
PCT/JP2021/005753
Other languages
English (en)
French (fr)
Inventor
まどか 馬場
Original Assignee
三菱電機株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 三菱電機株式会社 filed Critical 三菱電機株式会社
Priority to JP2022580134A priority Critical patent/JP7274063B2/ja
Priority to PCT/JP2021/005753 priority patent/WO2022176027A1/ja
Publication of WO2022176027A1 publication Critical patent/WO2022176027A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • This disclosure relates to the generation of software test cases.
  • Software installed in a communication device or the like may use as an input data whose structure changes during execution of the software.
  • the data whose structure changes is, for example, data of a link structure implemented using a C language self-referencing structure as shown in FIG.
  • data can be connected in a daisy chain by making certain data point to the address of the next data. "*next" of the final end data that does not have the next data becomes a null pointer.
  • Another example is binary tree data implemented in Java (registered trademark) language as shown in FIG.
  • a data structure can be constructed in which the root node is connected to the left and right child nodes.
  • "left" and “right” of terminal data (leaf nodes) that do not have the next data are null pointers.
  • Software that handles such a data structure adds or deletes data while dynamically allocating or releasing memory.
  • the data structure of the data handled by the software changes during execution of the software. For example, if the data structure of data handled by software is a link structure as shown in FIG. 12, the number (length) of connected data changes. Also, if the data structure of data handled by software is a binary tree structure as shown in FIG. 13, the depth and shape of connected data (nodes) change.
  • a test is usually performed in a program test process to check whether a module such as a function can output an expected output value from an input value given from the outside.
  • a module such as a function
  • it is not realistic to give all possible input values to the module and execute the test. Therefore, it is important in test design to select input values that can detect bugs contained in the program to be tested and perform the test. Therefore, as a test technique, it is common to use specific values obtained by, for example, boundary value analysis as test input values.
  • boundary value analysis the input range and/or the output range is partitioned into regions (equivalence classes) that can be assumed to behave the same by specification.
  • boundary value (boundary value) of an area that is expected to likely contain a software defect is extracted as a representative value of that area. It is said that the test can be executed efficiently by regarding the input boundary value as the representative value of the equivalence class and using the input boundary value as the test input value.
  • Patent Literature 1 discloses a method of automatically generating test cases for a program that uses hierarchical data as input. More specifically, Patent Document 1 discloses a method of determining a data structure according to the depth of a given hierarchy and using boundary values as test case values. Note that the term test case refers to both input values and expected output values, but generation of test cases usually means generation of test input data. Accordingly, hereinafter, a test case means input data to be given to a test object during test execution.
  • Patent Document 1 analyzes the program code to clarify the data structure type. Subsequently, information about the structure, such as the number of previously given links, is used to determine the structure of the particular data conforming to the type. A test case is generated by giving values such as random numbers and boundary values to the data structure thus determined.
  • Japanese Patent Application Laid-Open No. 2002-200003 does not mention how to give values considering the data structure. Therefore, even if a test is performed using test cases generated using boundary values, there is a possibility that defects contained in the program cannot be detected.
  • a program shown in FIG. 14 will be used to explain the reason why a defect cannot be detected when such a test case is used.
  • the program shown in FIG. 14 is a program that uses the data structure type shown in FIG. 13 for input.
  • test case 15 for example, can be considered as a test case given to the program in FIG.
  • the test case in FIG. 15 uses the boundary value as a value, the problem in line 5 of the program in FIG. 14 cannot be detected.
  • no invalid boundary value is assigned to the boundary node (the lowest layer node) that has no child node on the left side (effective boundary values of “254” and “0 ” is assigned).
  • the test case in FIG. 15 does not include the condition that the value of "Node n" is an invalid boundary value and the child node on the left does not exist. cannot be detected. Therefore, even if a test is performed using the test cases shown in FIG. 15, the program shown in FIG. 14 ends normally without causing an exception. In other words, the test case in FIG. 15 cannot detect the bug in the program in FIG.
  • Patent Document 1 has the problem that it is not possible to generate a test case in which the boundaries in the data structure of the input data and the boundaries in the values of the input data are appropriately combined.
  • the main purpose of this disclosure is to solve the above problems. More specifically, the present disclosure aims to generate test cases in which the boundaries in the data structure of the input data and the boundaries in the values of the input data are appropriately combined.
  • the test case generation device is a boundary value acquisition unit that acquires one or more boundary values of input data of a test target program to be tested; A plurality of data structures assumed as the data structure of the input data, each of which includes one or more data elements, and the connection of the one or more data elements included in each is different from each other a data structure generator for generating a data structure of a data element extraction unit for extracting, as a boundary data element, a data element positioned at a boundary of a connection among one or more data elements included in each of the plurality of data structures; Test case generation for assigning one of the one or more boundary values to the boundary data element in each of the plurality of data structures to generate a test case used for testing the program under test. and
  • FIG. 1 is a block diagram showing a configuration example of a test case generation device according to Embodiment 1;
  • FIG. 4 is a flowchart showing an operation example of the test case generation device according to the first embodiment;
  • 4 is a diagram showing an example of a test target program according to Embodiment 1;
  • FIG. 4 is a diagram showing an example of constraint information according to the first embodiment;
  • FIG. 4 is a diagram showing boundary value information according to the first embodiment;
  • FIG. 4A and 4B are diagrams showing examples of data patterns according to the first embodiment;
  • FIG. 4 is a diagram showing an example of a data object according to Embodiment 1;
  • FIG. 4 is a diagram showing an example of a data object according to Embodiment 1;
  • FIG. 4 is a diagram showing an example of a data object according to Embodiment 1;
  • FIG. 4A and 4B are diagrams showing examples of test cases according to the first embodiment
  • FIG. FIG. 2 is a block diagram showing a configuration example of a test case generation device according to a second embodiment
  • FIG. 9 is a flow chart showing an example of the operation of the test case generation device according to the second embodiment
  • FIG. 4 is a diagram showing an implementation example of binary tree structured data in the Java (registered trademark) language.
  • FIG. 4 is a diagram showing an example of a program including a faulty part; The figure which shows the example of the conventional test case.
  • Embodiment 1 a test case generation device for generating test cases that can detect defects related to the data structure and values of a program will be described.
  • the test cases generated by the test case generation device according to this embodiment can improve test quality and reduce the time required for software development.
  • test case generation device 1 is a computer.
  • a test case generation device 1 includes a processor 2 .
  • the test case generation device 1 further includes other hardware such as a memory 3 and an input/output device 4 .
  • the processor 2 is connected to other hardware through signal lines and controls these other hardware.
  • the test case generation device 1 includes, as functional elements, a data type acquisition unit 5, a constraint information acquisition unit 6, a boundary value acquisition unit 7, a data pattern generation unit 8, a boundary extraction unit 9, and a data object generation unit 10. and a test case output unit 11 .
  • Each functional element is implemented by a program.
  • the processor 2 is an IC (Integrated Circuit) that performs processing.
  • Processor 2 executes a test case generation program.
  • the test case generation program realizes the functions of the data type acquisition unit 5, the constraint information acquisition unit 6, the boundary value acquisition unit 7, the data pattern generation unit 8, the boundary extraction unit 9, the data object generation unit 10, and the test case output unit 11. It is a program that Processor 2 is, for example, a CPU.
  • CPU is an abbreviation for Central Processing Unit.
  • Memory 3 stores a test case generation program.
  • Memory 3 is, for example, RAM, flash memory or a combination thereof. "RAM” is an abbreviation for Random Access Memory.
  • the memory 3 also stores a program of software under test (hereinafter referred to as a program under test), specification information of the program under test, and generated test cases.
  • the input/output device 4 is connected to an input device operated by a user to input necessary information to the test case generation program. Further, the input/output device 4 is connected to a display for displaying data output from the test case generation program on the screen.
  • the input device may be, for example, a mouse, keyboard, touch panel, or a combination of some or all of these.
  • the display is, for example, an LCD. "LCD” is an abbreviation for Liquid Crystal Display. The display is used in particular by the test case output unit 11 to display test cases.
  • the test case generation program is read from the memory 3 into the processor 2 and executed by the processor 2 .
  • the memory 3 stores not only the test case generation program but also the OS. "OS” is an abbreviation for Operating System.
  • the processor 2 executes the test case generation program while executing the OS. Part or all of the test case generation program may be incorporated into the OS.
  • the test case generation program and OS may be stored in an auxiliary storage device.
  • the auxiliary storage device is, for example, an HDD, flash memory 3, or a combination thereof. "HDD” is an abbreviation for Hard Disk Drive.
  • the test case generation program and OS are loaded into the memory 3 and executed by the processor 2 if stored in the auxiliary storage device. Task management, memory management, file management, communication control, etc. are performed by the processor 2 executing the OS.
  • the test case generation device 1 may include multiple processors that substitute for the processor 2. These multiple processors share the execution of the test case generator. Each processor is, for example, a CPU.
  • the data, information, signal values and variable values that are used, processed or output by the test case generation program are stored in the memory 3, the auxiliary storage device, or the register or cache memory 3 in the processor 2.
  • test case generation program causes the computer to execute each process, each procedure, or each process by replacing the above “parts” with “processing", “procedure”, or “step”. Also, the test case generation method is a method performed by a computer executing a test case generation program.
  • test case generation program may be stored in a computer-readable recording medium and provided.
  • a "computer-readable recording medium” is, for example, a magnetic disk, a flexible disk, an optical disk, a compact disk, a Blu-ray (registered trademark) disk, a DVD, or the like.
  • the test case generation program may be provided as a program product.
  • the test case generation device 1 may be realized by a processing circuit.
  • the processing circuits are, for example, logic ICs (Integrated Circuits), GAs (Gate Arrays), ASICs (Application Specific Integrated Circuits), and FPGAs (Field-Programmable Gate Arrays).
  • logic ICs Integrated Circuits
  • GAs Gate Arrays
  • ASICs Application Specific Integrated Circuits
  • FPGAs Field-Programmable Gate Arrays
  • processors and processing circuits are each examples of "processing circuitry.”
  • test case generation device 1 may be composed of one computer, or may be composed of a plurality of computers.
  • a data type acquisition unit 5 When the test case generation device 1 is composed of a plurality of computers, a data type acquisition unit 5, a constraint information acquisition unit 6, a boundary value acquisition unit 7, a data pattern generation unit 8, a boundary extraction unit 9, and a data object generation unit
  • the functions of the unit 10 and the test case output unit 11 may be implemented by being distributed to each computer.
  • test case generation device 1 corresponds to the test case generation method according to this embodiment.
  • the test case generation device 1 generates test cases used for testing the test target program.
  • a test case is a set of input values to a test target program for testing the test target program.
  • the data type acquisition unit 5 reads the test target program from the outside via the memory 3 or the input/output device 4. Then, the data type acquisition unit 5 acquires the data type of the test case.
  • the constraint information acquisition unit 6 reads constraint information (hereinafter simply referred to as constraint information) regarding the data structure of the test case from the outside via the memory 3 or the input/output device 4 .
  • Constraint information about the data structure of the test case is, in other words, constraint information about the data structure of the input data used in the program under test.
  • Constraint information regarding the data structure of the test case is, for example, the number of links in the link structure.
  • the boundary value acquisition unit 7 reads boundary value information, which is the boundary value analysis result of the test target program, from the outside via the memory 3 or the input/output device 4 . More specifically, the boundary value acquiring unit 7 acquires one or more boundary values of input data used in the test target program.
  • the data pattern generation unit 8 determines the data structure of the test case based on the data type acquired by the data type acquisition unit 5 and the constraint information acquired by the constraint information acquisition unit 6 . Then, the data pattern generator 8 generates the determined data structure as a data pattern.
  • a data pattern is a plurality of data structures assumed in the input data of the program under test. That is, the data pattern generator 8 generates a plurality of data structures assumed as the data structure of the input data as a plurality of data patterns.
  • Each data pattern contains one or more data elements.
  • connection forms of one or more data elements included in each data pattern are different from each other.
  • the connection form of data elements is the number of data elements included in the data structure, the depth of hierarchy, and the form of connection between data elements.
  • the data pattern generator 8 corresponds to the data structure generator. Further, the processing performed by the data pattern generation unit 8 corresponds to data structure generation processing.
  • the boundary extraction unit 9 extracts data elements located at the boundary of the data structure in each of the plurality of data patterns generated by the data pattern generation unit 8 . That is, the boundary extracting unit 9 extracts data elements positioned at the boundaries of connections (hereinafter also referred to as boundary data elements) from among one or more data elements included in the data pattern. In addition to referring to the data structure of the data pattern, the boundary extracting unit 9 may also refer to the constraint information acquired by the constraint information acquiring unit 6 to extract data elements located at the boundaries.
  • the boundary extractor 9 corresponds to a data element extractor. Further, the processing performed by the boundary extraction unit 9 corresponds to data element extraction processing.
  • the data object generation unit 10 assigns the boundary value acquired by the boundary value acquisition unit 7 to the data element of the boundary acquired by the boundary extraction unit 9 to create a data object.
  • the data object generation unit 10 and the test case output unit 11 correspond to a test case generation unit. Further, the processing performed by the data object generation unit 10 corresponds to test case generation processing together with the processing performed by the test case output unit 11 .
  • the test case output unit 11 formats the data objects to which the data object generation unit 10 has assigned values into a predetermined format to generate test cases. Then, the test case output unit 11 outputs the generated test cases to the outside via the memory 3 or the input/output device 4 .
  • the test case output unit 11, together with the data object generation unit 10, corresponds to the test case generation unit. Further, the processing performed by the test case output unit 11 corresponds to test case generation processing together with the processing performed by the data object generation unit 10 .
  • step S ⁇ b>1 the data type acquisition unit 5 reads the test target program from the outside via the memory 3 or the input/output device 4 . Then, the data type acquisition unit 5 analyzes the test target program and acquires the type of input data to be a test case, that is, the information of the input data type of the test target program. The process then proceeds to step S2.
  • step S2 the constraint information acquisition unit 6 reads constraint information regarding the data structure.
  • the process then proceeds to step S3.
  • the format of the constraint information regarding the data structure depends on the type of input data. If the input data type of the program under test is, for example, the type of the link structure shown in FIG. 12, the constraint information indicates the number of links (also called link length or depth). If the input data type of the program under test is, for example, the binary tree type shown in FIG. 13, the constraint information indicates the maximum depth of the tree and/or the size (number of nodes) of the tree. Also, if the input data type of the program under test is, for example, an N-tree with 2 or more child nodes, the maximum number of child node connections is limited in addition to the value indicated in the binary tree type constraint information. indicated in the information.
  • the boundary value acquisition unit 7 acquires boundary value information of the test target program.
  • the process then proceeds to step S4.
  • the boundary value is the boundary value of the input data of the program under test.
  • the input data has a plurality of boundary values.
  • the boundary value depends on the specifications of the software under test. For example, the variable "value" contained in the link structure type of FIG. 12 may have multiple valid boundary values and multiple invalid boundary values. Also, if there are multiple variables included in the type, the boundary value is determined for each of those variables according to the specifications of the software to be tested.
  • step S4 the data pattern generation unit 8 generates a data pattern based on the input data type obtained in step S1 and the constraint information obtained in step S2. Then, the process proceeds to step S5.
  • the data pattern generator 8 generates one or more data patterns for one input data type. The number of data patterns generated for one input data type depends on the data type and constraint information. Also, at the time of step S4, the values of the variables involved in determining the data structure are determined. For example, an address or the like is stored in a variable that stores a pointer pointing to a child node of a binary tree. However, other variables are not assigned values.
  • step S5 the boundary extracting unit 9 extracts boundary data elements of each data pattern generated in step S4. Then, the process proceeds to step S6.
  • Boundary data element extraction conditions are determined in advance depending on the specifications of the software to be tested, such as the input data type. For example, if the type of input data is the link structure shown in FIG. 12, the top node that has no parent data and the terminal node that has no child data and stores a null pointer instead of the child address are bounded. can be defined to be a data element. Further, for example, when the type of input data is the binary tree of FIG. 13, it is possible to define the root node and nodes having at least one null child node as boundary data elements. Alternatively, extract the root node, the node with both null child nodes, the node with only the left child node with null, and the node with only the right child node with null as boundary data elements. can be determined.
  • step S6 the data object generation unit 10 assigns the boundary value obtained in step S3 to the boundary data element extracted in step S5.
  • the data pattern after the boundary values are assigned to the boundary data elements corresponds to the data object.
  • the process proceeds to step S7.
  • the data object generation unit 10 assigns a valid boundary value to the top node, which is the data element of the boundary.
  • the data object generation unit 10 also assigns an invalid boundary value to terminal nodes, which are also boundary data elements.
  • the data object generator 10 assigns to other nodes that are not boundary data elements a valid boundary value or any value within a valid range between any two valid boundary values.
  • a plurality of allocation methods may be prepared in advance, and the data object generation unit 10 may perform a plurality of allocations according to the plurality of allocation methods. That is, the data object generation unit 10 can generate a plurality of data objects from one data pattern generated in step S4.
  • step S7 the test case output unit 11 formats the data object generated in step S6 into a predetermined format to generate a test case. Then, the test case output unit 11 outputs the generated test cases.
  • test case generation device 1 ends the processing.
  • step S3 may be performed before step S5.
  • step S3 may be performed before steps S1 and S2.
  • step S3 may be performed after step S4.
  • step S1 the data type acquisition unit 5 may directly read the type information of the input data of the test target program written using the description language of the test target program instead of the entire test target program. Further, the data type acquisition unit 5 may directly read the type information of the input data of the test target program written using a language other than the description language of the test target program.
  • the boundary extraction unit 9 may extract boundary data elements using not only the structure of the data pattern but also the constraint information acquired by the constraint information acquisition unit 6 in step S2. For example, when information that the maximum number of nodes in a link structure is 5 is given as constraint information, the boundary extracting unit 9 extracts the 0th node that is the root node and the 5th node that is the terminal node. , can be extracted as a boundary data element.
  • test case generation device 1 Next, the operation of the test case generation device 1 will be explained using a specific example.
  • the test case generation device 1 reads the test target program, the constraint information about the data structure of the test cases, and the boundary value information from the outside via the input/output device 4 .
  • FIG. 3 shows part of a test target program according to this embodiment.
  • FIG. 4 shows constraint information regarding the data structure of test cases.
  • FIG. 5 shows boundary value information. Also, in the following description, the steps in parentheses correspond to the steps in FIG.
  • Step S1 The data type acquisition unit 5 reads the test target program. Further, the data type acquisition unit 5 confirms that there is a variable n of the test target method func as a variable to be included in the test case to be generated. Then, the data type obtaining unit 5 obtains the Node shown in the first to fifth lines in FIG. 3 as the input data type.
  • Step S2 the constraint information acquisition unit 6 acquires the constraint information shown in FIG.
  • the constraint information in FIG. 4 indicates that the maximum number of nodes is three.
  • Step S3 the boundary value acquisition unit 7 acquires the boundary value information shown in FIG.
  • the boundary value information in FIG. 5 indicates valid boundary values “0, 10, 11, 254” and invalid boundary values “ ⁇ 1, 255”.
  • Step S4 Next, based on the information that the type of the input data is Node type acquired in step S1 and the information that the maximum number of nodes is 3 acquired in step S2, the data pattern generation unit 8 , produces the data pattern shown in FIG. In FIG. 6, arrows are omitted for pointers having no child nodes (null pointers).
  • the data pattern generation unit 8 generates all of the multiple data structures assumed in the input data of the test target program as data patterns. As shown in FIG. 6, the data pattern generation unit 8 generates a plurality of data patterns each containing one or more data elements and having different connection forms of the one or more data elements contained in each. Generate.
  • the data pattern (a) corresponds to the primary data pattern.
  • Data patterns (b) and (c) correspond to secondary data patterns, respectively.
  • the data patterns (d) to (h) correspond to the tertiary data patterns.
  • Step S5 the boundary extracting unit 9 extracts boundary data elements positioned at the boundary of each data pattern generated in step S4.
  • the boundary extractor 9 extracts boundary data elements of the i-th data pattern. If there are j types of ith data patterns, the boundary extracting unit 9 extracts boundary data elements from each of the j types of ith data patterns. Note that the boundary extracting unit 9 extracts a single data element as the boundary data element in the data pattern shown in FIG. 6(a) which has only a single data element. As a result, the boundary extracting unit 9 extracts the hatched nodes in FIG. 6 as boundary data elements located on the boundary.
  • Step S6 the data object generator 10 assigns a specific value to each data element (value) of data patterns (a) to (h) to generate a data object.
  • the data object generation unit 10 assigns a specific value to each data element according to the following assignment rules (1) to (4).
  • (1) In a data pattern with the same number of nodes and the same depth, all given effective boundary values are assigned to the boundary data elements at least once, and the remaining data elements are assigned effective values (identifiable by the boundary values). effective class value). Note that the same depth means the depth of the hierarchy of data elements (the depth of connection).
  • each of the three or more effective boundary values is set so that the combinations of effective boundary values in each data pattern with the same number of nodes and the same depth are different from each other. Assign to any boundary data element of data patterns with the same number of nodes and same depth.
  • each of the two or more invalid boundary values is placed in the same node so that the invalid boundary values in each data pattern with the same number of nodes and the same depth are different from each other. Assign to any boundary data element of the number and data patterns of the same depth.
  • the data object generator 10 converts each of the four valid boundary values "0, 10, 11, 254" into four It is assigned to each of the data patterns in FIG. 6(a). That is, the data object generation unit 10 assigns each valid boundary value to each of the data patterns of (a) in the same number as the number of valid boundary values. As a result, the data object generation unit 10 generates data objects (a-1), (a-2), (a-3) and (a-4) in FIG. 7, for example.
  • the data object generation unit 10 assigns each of the two invalid boundary values of "-1, 255" to each of the two data patterns of (a) of FIG. assign. That is, the data object generation unit 10 assigns each invalid boundary value to each of the data patterns of (a) in the same number as the number of invalid boundary values. 5) Create data objects of (a-6). In FIG. 8, data elements to which invalid boundary values are assigned are represented by thick frames.
  • the data patterns in (b) and (c) of FIG. 6 both have the same depth. Therefore, the above allocation rules (1) to (4) can be applied as they are. Therefore, the data object generation unit 10 does not need to classify the data patterns of (b) and (c) of FIG. 6 into groups according to depth.
  • the data object generation unit 10 generates, for example, data objects (b-1) and (c-1) in FIG. 7 according to the allocation rules (1) and (3).
  • valid boundary values are assigned to the boundary data elements of each data object.
  • the data object generation unit 10 for example, data (b-2), (b-3), (c-2) and (c-3) in FIG. 8 according to the allocation rules (2) and (4) Create an object.
  • the data objects of (b-2), (b-3), (c-2) and (c-3) of FIG. 8 one of the boundary data elements of each data object is assigned an invalid boundary value and the other is assigned a valid boundary value.
  • the data object generation unit 10 classifies the data patterns of (d) to (h) in FIG. 6 into groups according to depth. That is, the data object generation unit 10 divides the data patterns (d) to (h) of FIG. 6 into groups of data patterns having three levels of depth ((d) to (g) of FIG. data pattern group ((h) in FIG. 6) having a step depth. Then, the data object generation unit 10 generates data objects for each group according to allocation rules (1) to (4).
  • the data object generation unit 10 from the data patterns (d) to (g) in FIG. 6, for example, (d-1), ( Create data objects for e-1), (f-1) and (g-1).
  • valid boundary values are assigned to the boundary data elements of each data object.
  • the data object generation unit 10 generates data objects (h-1) and (h-2) in FIG. 7 from the data pattern in (h) in FIG. to generate In the data objects (h-1) and (h-2) of FIG. 7, valid boundary values are assigned to the boundary data elements of each data object.
  • the data object generation unit 10 according to the allocation rules (2) and (4), from the data patterns (d) to (g) in FIG. 6, for example, (d-2), (e-2 ), (f-2) and (g-2).
  • the data objects (d-2), (e-2), (f-2) and (g-2) of FIG. 8 one of the boundary data elements of each data object is assigned an invalid boundary value and the other is assigned a valid boundary value.
  • the data object generation unit 10 generates, for example, the data objects (h-3) to (h-8) of FIG. 8 from the data pattern of (h) of FIG. to generate In the data objects (h-3) to (h-8) of FIG. 8, one boundary data element of each data object is assigned an invalid boundary value, and each of the other boundary data elements is assigned a valid boundary value. It is
  • the test case output unit 11 shapes all the data objects shown in FIGS. 7 and 8 into the format shown in FIG. 9, and outputs the shaped data objects as test cases.
  • Each row shown in FIG. 9 is a test case.
  • Data obtained by shaping the data object in FIG. 7 is called a valid boundary value test case. That is, the data in the rows of FIG. 9 describing the same identifiers as the data object identifiers ((a-1), (b-1), etc.) shown in FIG. 7 are valid boundary value test cases.
  • Data obtained by shaping the data object in FIG. 8 is called an invalid boundary value test case. That is, the data in the rows of FIG. 9 describing the same identifiers as the data object identifiers ((a-5), (b-2), etc.) shown in FIG. 8 are invalid boundary value test cases.
  • the restriction information acquisition unit 6 may acquire multiple types of restriction information.
  • the constraint information acquisition unit 6 may include a constraint indicating that "only one data pattern with the same number of nodes and the same depth shall be generated". Get information.
  • the number of data patterns generated by the data pattern generator 8 can be suppressed.
  • the constraint information acquisition unit 6 acquires constraint information indicating the constraint that "only one data pattern with the same number of nodes and the same depth shall be generated"
  • the data pattern generator 8 generates only one of the data patterns (d) to (f) in FIG. 6 and the data patterns (g) and (h) in FIG.
  • the boundary extracting unit 9 may extract the boundary data element using the constraint that the maximum number of nodes indicated in the constraint information acquired by the constraint information acquiring unit 6 is three. For example, the boundary extracting unit 9 extracts data elements of depth 0 (root node) and depth 2, which are the minimum and maximum possible depths, as boundary data elements from the maximum number of nodes of 3. good too.
  • the test case generation device 1 assigns the boundary value of the input data to the boundary data element positioned at the boundary of the data structure assumed in the input data of the program under test. Therefore, according to the present embodiment, it is possible to generate a test case in which the boundary in the data structure of the input data and the boundary in the value of the input data are appropriately combined.
  • the test case generation device 1 uses input data types, data structure constraints, and input data boundary value information according to a boundary value assignment method suitable for a program under test. , assigns boundary values to the boundary data elements. This allows boundary testing, both structural and value, which is particularly prone to software defects. As a result, it is possible to detect defects in the test target program that could not be detected by the conventional method.
  • the data object generation unit 10 assigns all valid boundary values to data elements on the boundary at least once in a data pattern that satisfies a specific condition. As a result, all valid equivalence classes in the domain are assigned to boundary data elements for testing, and test coverage can be increased. In addition, the number of test cases can be suppressed more than when all combinations of data boundary values are assigned to boundary data elements. As a result, test efficiency can be improved and test man-hours can be reduced.
  • the data object generation unit 10 assigns all invalid boundary values to boundary data elements at least once in a data pattern that satisfies a specific condition.
  • the data object generator 10 also assigns valid values or valid boundary values to the remaining data elements. This allows only one invalid boundary value to be assigned to the boundary data element per test case.
  • the test case generated by the test case generation device 1 according to the present embodiment can be used for testing that conforms to the principle of testing invalid boundary values one by one in the conventional test technique using the boundary value analysis result. It can be performed. As a result, even if a program under test contains a plurality of defects, it is highly likely that each defect can be detected separately. Further, according to the present embodiment, it is possible to prevent failure detection and/or correction failure, improve test efficiency, and reduce test man-hours.
  • Embodiment 2 a configuration will be described in which a combination of boundary values that achieves target coverage in the test of the program under test is selected for each data pattern, and the selected combination of boundary values is assigned to boundary data elements for each data pattern. do.
  • differences from the first embodiment will be mainly described. Matters not described below are the same as those in the first embodiment.
  • FIG. 10 shows a configuration example of the test case generation device 1 according to this embodiment.
  • the test case generation device 1 according to the present embodiment has a program structure acquisition unit 13 and a coverage condition generation unit 14 added to the configuration shown in FIG.
  • test case generation device 1 *** Function description *** An overview of the functions of the test case generation device 1 according to the present embodiment will be described with reference to FIG.
  • the program structure acquisition unit 13 reads the test target program from the outside via the memory 3 or the input/output device 4 . Also, the program structure acquisition unit 13 acquires targets for measurement of the structure coverage rate of the test, such as statement locations and branch locations of the test target program.
  • the coverage condition generation unit 14 generates the structure coverage conditions required to achieve a structure coverage rate of 100% from the structure coverage rate measurement target acquired by the program structure acquisition unit 13 .
  • the data object generation unit 10 assigns a value to each data element of the data pattern based on the structure coverage condition generated by the coverage condition generation unit 14 in addition to the boundary value information and the information on the data element on the boundary of the structure. Create an object. That is, in the present embodiment, the data object generation unit 10 selects, for each data pattern, a combination of boundary values necessary for achieving the target coverage rate (100%) in the test of the program under test. Then, in the present embodiment, the data object generation unit 10 generates a data object by assigning the selected combination of boundary values to boundary data elements for each data pattern.
  • test case generation device 1 Details of the operation of the test case generation device 1 according to the present embodiment will be described with reference to FIG. Note that the same step numbers are used for the same operations as in the first embodiment, and descriptions thereof are omitted.
  • step S5 the process proceeds to step S8.
  • step S ⁇ b>8 the program structure acquisition section 13 reads the test target program from the outside via the memory 3 or the input/output device 4 . Then, the program structure acquisition unit 13 acquires the measurement target of the structure coverage rate of the test target program. Then, the process proceeds to step S9.
  • step S ⁇ b>9 the coverage condition generation unit 14 generates a structure coverage condition necessary for achieving a structure coverage rate of 100% from the structure coverage rate measurement target acquired by the program structure acquisition unit 13 .
  • the process proceeds to step S10.
  • step S10 the data object generation unit 10 assigns a value to each data element of the data pattern based on the structural coverage condition generated by the coverage condition generation unit 14 in addition to the boundary value information and the information on the boundary data element. to create a data object. Then, the process proceeds to step S7.
  • assigning values by the data object generation unit 10 for example, the following method (1) and method (2) are conceivable.
  • the data object generation unit 10 inputs data object candidates generated by assigning values to each data element according to the first embodiment to the test target program, and executes the test of the test target program. Furthermore, the data object generation unit 10 confirms whether or not the test coverage satisfies the structural coverage condition.
  • the data object generator 10 assigns different values to each data element.
  • the data object generator 10 gives boundary value information, boundary data element information, and structural coverage conditions as constraint conditions for an analysis method based on symbolic execution such as bounded model checking, and generates the value of each data element. decide.
  • steps S5 and S9 may be performed before step S10, and may be performed before steps S1 to S8.
  • test case generation device 1 Next, an operation example of the test case generation device 1 according to the present embodiment will be described using a specific example.
  • FIG. 3 shows part of a test target program according to this embodiment.
  • the structure coverage criterion used as the test termination criterion is the branch coverage criterion.
  • FIG. 4 shows constraint information regarding the data structure of test cases.
  • FIG. 5 shows boundary value information. Also, in the following description, the steps in parentheses correspond to the steps in FIG.
  • Step S8 The program structure acquisition unit 13 acquires two if statements in the method func as measurement targets for the branch coverage rate in the test of the test target program in FIG.
  • Step S9 In order to make the branch coverage rate of the first if statement of the program under test acquired by the program structure acquisition unit 13 100%, the coverage condition generation unit 14 sets “n.value” to less than 255 and “n.left '' is not null and otherwise. Similarly, the coverage condition generating unit 14 generates two conditions for the second if statement, ie, when "n.value” is equal to 255 and when otherwise.
  • Step S10 The data object generation unit 10 considers the four conditions generated by the coverage condition generation unit 14 in addition to the constraint information on the data structure in FIG. 4 and the boundary value information in FIG. Select a boundary value to be 100% and assign the selected boundary value to the boundary data element of the data structure.
  • the test case generation device 1 provides input data types, data structure constraints, input data boundary value information, and information on the structural coverage rate used for testing the program under test. is used to assign boundary values according to the boundary value assignment method appropriate for the program under test, taking into account the boundary data elements of the data object.
  • This allows the generation of test cases that enable testing of the structural coverage of the program under test, as well as testing of boundaries, both structural and value.
  • the coverage rate of the structure of the program under test can be increased, and the fault detection rate can be improved.
  • test cases are generated separately for boundary tests in terms of both structures and values, and for tests for improving the structure coverage rate. generation time can be shortened.
  • since the number of test cases can be reduced, it is possible to reduce test execution time and expected value calculation time, thereby reducing test man-hours.
  • Embodiments 1 and 2 have been described above, these two embodiments may be combined for implementation. Alternatively, one of these two embodiments may be partially implemented. Alternatively, these two embodiments may be partially combined and implemented. Also, the configurations and procedures described in these two embodiments may be changed as required.
  • test case generation device 1 test case generation device, 2 processor, 3 memory, 4 input/output device, 5 data type acquisition unit, 6 constraint information acquisition unit, 7 boundary value acquisition unit, 8 data pattern generation unit, 9 boundary extraction unit, 10 data object generation 11 Test case output unit 13 Program structure acquisition unit 14 Coverage condition generation unit.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

境界値取得部(7)は、テスト対象プログラムの入力データの1つ以上の境界値を取得する。データパターン生成部(8)は、入力データのデータ構造として想定される複数のデータ構造であって、各々に1つ以上のデータ要素が含まれ、各々に含まれる1つ以上のデータ要素の接続形態が相互に異なっている複数のデータ構造を生成する。境界抽出部(9)は、複数のデータ構造の各々で、境界データ要素を抽出する。データオブジェクト生成部(10)及びテストケース出力部(11)は、複数のデータ構造の各々で、いずれかの境界値を境界データ要素に割り当てて、テストケースを生成する。

Description

テストケース生成装置、テストケース生成方法及びテストケース生成プログラム
 本開示は、ソフトウェアのテストケースの生成に関する。
 通信装置などに搭載されるソフトウェアでは、ソフトウェアの実行中に構造が変化するデータを入力として用いることがある。
 構造が変化するデータとは、例えば図12に示すようなC言語の自己参照型構造体を利用して実装されたリンク構造のデータである。図12の例では、あるデータが次のデータのアドレスを指し示すようにすることで、データを数珠つなぎに接続することが可能である。次のデータを持たない最終端のデータの「*next」はヌルポインタとなる。
 また、他の例として、例えば図13に示すようなJava(登録商標)言語で実装されたバイナリツリーのデータがある。図13の例では、ルートノードが左右の子ノードに接続されるデータ構造を構築することができる。図13の例でも、次のデータを持たない末端のデータ(リーフノード)の「left」及び「right」はヌルポインタとなる。
 このようなデータ構造を扱うソフトウェアは、動的にメモリを確保あるいは開放しながら、データの追加又は削除を行う。そして、ソフトウェアの実行中にソフトウェアが扱うデータのデータ構造が変化する。例えば、ソフトウェアが扱うデータのデータ構造が図12のようなリンク構造であれば、接続されるデータの数(長さ)が変化する。また、ソフトウェアが扱うデータのデータ構造が図13のようなバイナリツリー構造であれば、接続されるデータ(ノード)の深さ及び形状が変化する。
 ソフトウェアの開発では、通常、プログラムのテスト工程において、関数などのモジュールが、外部から与えられた入力値から、期待される出力値を出力することができるか否かを確認するテストが行われる。このようなテストでは、入力値となり得る全ての値をモジュールに与えてテストを実行することは現実的ではない。そのため、テスト対象のプログラムに含まれるバグを検出可能な入力値を選択してテストを行うことが、テスト設計において重要となる。
 そこで、テストの技法として、例えば境界値分析によって得られた特定の値を、テストの入力値として用いることが一般的である。境界値分析では、入力値域及び/又は出力値域が、仕様上、同じ振舞いをするとみなせる領域(同値クラス)に区切られる。そして、ソフトウェア不具合を含みやすいと予想される領域の境界の値(境界値)が、その領域の代表値として抽出される。そして、入力の境界値を同値クラスの代表値と見做し、入力の境界値をテストの入力値として用いることで効率的にテストを実行することができるといわれている。
 一方、ソフトウェアの実行中にデータ構造が変化するデータを入力として用いるプログラムに対しては、上記のような、入力値域の境界値だけを入力値としたテストでは十分ではない。
 このようなプログラムでは、入力されるデータのデータ構造に依存したプログラムの不具合がないことを確認するテストも必要となる。
 特許文献1では、階層構造のデータを入力として用いるプログラムを対象としたテストケースの自動生成方法が開示されている。より具体的には、特許文献1では、与えられた階層の深さ等に応じてデータ構造を決定し、テストケースの値として境界値を用いる方法が開示されている。
 なお、テストケースは入力値と出力期待値の両方を指す言葉であるが、通常、テストケースの生成は、テスト用の入力データの生成を意味する。これに従い、以下では、テストケースとは、テスト実行時にテスト対象に与える入力データを意味する。
特開平9-231103号公報
 特許文献1の方法では、プログラムコードを解析してデータ構造の型を明らかにする。続いて、予め与えられたリンクの数などの構造に関する情報を用いて、型に準拠した特定のデータの構造を決定する。そのようにして決定したデータの構造に、乱数、境界値などの値を与えることでテストケースを生成する。
 しかし、特許文献1では、データ構造を考慮した値の与え方については言及されていない。そのため、境界値を用いて生成されたテストケースでテストを行っても、プログラムに含まれる不具合を検出できない可能性がある。このようなテストケースを用いた場合に不具合が検出できない理由を、図14に示すプログラムを用いて説明する。なお、図14に示すプログラムは、図13に示したデータ構造の型を入力に用いるプログラムである。
 図14に示すプログラムにおいて、「Node n」の値「value」の有効境界値は「0、10、11、254」であり、無効境界値は「255」であるものとする。
 図14に示すプログラムでは、5行目の分岐条件において不具合が混入している。具体的には、5行目の分岐条件では、2行目にあるような、「Node n」に子が無く、「n.left」がヌルポインタである場合の処理が抜けているという不具合が混入している。従って、「Node n」の値が無効境界値で、左側の子ノードが存在しないデータが入力された場合には、例外が発生するという不具合が起こる。
 特許文献1の方法に依れば、図14のプログラムに与えるテストケースとして例えば図15に示すデータが考えられる。
 図15のテストケースは、境界値を値として用いているが、図14のプログラムの5行目の不具合を検出することができない。具体的には、図15のテストケースには、左側に子ノードが存在しない境界ノード(最下層のノード)には無効境界値が割り当てられていない(有効境界値である「254」と「0」が割り当てられている)。このため、図15のテストケースには、「Node n」の値が無効境界値であり、左側の子ノードが存在しないという条件が含まれておらず、図14のプログラムの5行目の不具合を検出することができない。
 従って、図15のテストケースを用いてテストを行っても、図14のプログラムは例外を発生させることなく正常に終了する。つまり、図15のテストケースでは、図14のプログラムのバグを検出することができない。
 このように、特許文献1の方法では、入力データのデータ構造における境界と入力データの値における境界とが適切に組み合わされたテストケースを生成することができないという課題がある。
 本開示は、上記の課題を解決することを主な目的とする。より具体的には、本開示は、入力データのデータ構造における境界と入力データの値における境界とが適切に組み合わされたテストケースを生成することを目的とする。
 本開示に係るテストケース生成装置は、
 テストの対象となるテスト対象プログラムの入力データの1つ以上の境界値を取得する境界値取得部と、
 前記入力データのデータ構造として想定される複数のデータ構造であって、各々に1つ以上のデータ要素が含まれ、各々に含まれる1つ以上のデータ要素の接続形態が相互に異なっている複数のデータ構造を生成するデータ構造生成部と、
 前記複数のデータ構造の各々で、各々に含まれる1つ以上のデータ要素のうち接続の境界に位置するデータ要素を境界データ要素として抽出するデータ要素抽出部と、
 前記複数のデータ構造の各々で、前記1つ以上の境界値のうちのいずれかの境界値を前記境界データ要素に割り当てて、前記テスト対象プログラムのテストに用いられるテストケースを生成するテストケース生成部とを有する。
 本開示によれば、入力データのデータ構造における境界と入力データの値における境界とが適切に組み合わされたテストケースを生成することができる。
実施の形態1に係るテストケース生成装置の構成例を示すブロック図。 実施の形態1に係るテストケース生成装置の動作例を示すフローチャート。 実施の形態1に係るテスト対象プログラムの例を示す図。 実施の形態1に係る制約情報の例を示す図。 実施の形態1に係る境界値情報を示す図。 実施の形態1に係るデータパターンの例を示す図。 実施の形態1に係るデータオブジェクトの例を示す図。 実施の形態1に係るデータオブジェクトの例を示す図。 実施の形態1に係るテストケースの例を示す図。 実施の形態2に係るテストケース生成装置の構成例を示すブロック図。 実施の形態2に係るテストケース生成装置の動作例を示すフローチャート。 C言語によるリンク構造のデータの実装例を示す図。 Java(登録商標)言語によるバイナリツリー構造のデータの実装例を示す図。 不具合箇所を含むプログラムの例を示す図。 従来のテストケースの例を示す図。
 以下、本発明の実施の形態について、図を用いて説明する。各図中、同一または相当する部分には、同一符号を付している。実施の形態の説明において、同一または相当する部分については、説明を適宜省略または簡略化する。
実施の形態1.
 本実施の形態では、プログラムのデータ構造と値に関わる不具合を検出可能とするテストケースを生成するテストケース生成装置を説明する。
 本実施の形態に係るテストケース生成装置により生成されたテストケースにより、テスト品質を向上させ、ソフトウェア開発にかかる時間を削減することができる。
***構成の説明***
 図1を参照して、本実施の形態に係るテストケース生成装置1の構成例を説明する。
 テストケース生成装置1は、コンピュータである。テストケース生成装置1は、プロセッサ2を備える。また、テストケース生成装置1は、更に、メモリ3、入出力装置4といった他のハードウェアを備える。
 プロセッサ2は、信号線を介して他のハードウェアと接続され、これら他のハードウェアを制御する。
 テストケース生成装置1は、機能要素として、データ型取得部5と、制約情報取得部6と、境界値取得部7と、データパターン生成部8と、境界抽出部9と、データオブジェクト生成部10と、テストケース出力部11とを備える。
 各機能要素は、プログラムにより実現される。
 プロセッサ2は、プロセッシングを行うIC(Integrated Circuit)である。
 プロセッサ2は、テストケース生成プログラムを実行する。
 テストケース生成プログラムは、データ型取得部5、制約情報取得部6、境界値取得部7、データパターン生成部8、境界抽出部9、データオブジェクト生成部10及びテストケース出力部11の機能を実現するプログラムである。
 プロセッサ2は、例えば、CPUである。「CPU」は、Central Processing Unitの略語である。
 メモリ3は、テストケース生成プログラムを記憶する。
 メモリ3は、例えば、RAM、フラッシュメモリまたはこれらの組み合わせである。
 「RAM」は、Random Access Memoryの略語である。メモリ3には、テスト対象ソフトウェアのプログラム(以下、テスト対象プログラムという)、テスト対象プログラムの仕様情報、および、生成されたテストケースも記憶される。
 入出力装置4は、テストケース生成プログラムへ必要な情報を入力するためにユーザにより操作される入力機器に接続される。更に、入出力装置4は、テストケース生成プログラムから出力されるデータを画面に表示するディスプレイに接続される。
 入力機器は、例えば、マウス、キーボード、タッチパネル、または、これらのうちいくつか、もしくは、すべての組み合わせである。
 ディスプレイは、例えば、LCDである。「LCD」は、Liquid Crystal Displayの略語である。ディスプレイは、特に、テストケース出力部11がテストケースを表示するために用いられる。
 テストケース生成プログラムは、メモリ3からプロセッサ2に読み込まれ、プロセッサ2によって実行される。
 メモリ3には、テストケース生成プログラムだけでなく、OSも記憶されている。「OS」は、Operating Systemの略語である。
 プロセッサ2は、OSを実行しながら、テストケース生成プログラムを実行する。なお、テストケース生成プログラムの一部または全部がOSに組み込まれていてもよい。
 テストケース生成プログラムおよびOSは、補助記憶装置に記憶されていてもよい。
 補助記憶装置は、例えば、HDD、フラッシュメモリ3またはこれらの組み合わせである。「HDD」は、Hard Disk Driveの略語である。
 テストケース生成プログラムおよびOSは、補助記憶装置に記憶されている場合、メモリ3にロードされ、プロセッサ2によって実行される。
 プロセッサ2がOSを実行することで、タスク管理、メモリ管理、ファイル管理、通信制御等が行われる。
 テストケース生成装置1は、プロセッサ2を代替する複数のプロセッサを備えていてもよい。これら複数のプロセッサは、テストケース生成プログラムの実行を分担する。それぞれのプロセッサは、例えば、CPUである。
 テストケース生成プログラムにより利用、処理または出力されるデータ、情報、信号値および変数値は、メモリ3、補助記憶装置、または、プロセッサ2内のレジスタまたはキャッシュメモリ3に記憶される。
 データ型取得部5、制約情報取得部6、境界値取得部7、データパターン生成部8、境界抽出部9、データオブジェクト生成部10、およびテストケース出力部11の各部の「部」を「処理」、「手順」、「工程」あるいは「サーキットリー」に読み替えてもよい。
 また各処理の「処理」を「プログラム」、「プログラムプロダクト」または「プログラムを記録したコンピュータ読取可能な記録媒体」に読み替えてもよい。
 テストケース生成プログラムは、上記の各部の「部」を「処理」、「手順」あるいは「工程」に読み替えた各処理、各手順あるいは各工程を、コンピュータに実行させる。また、テストケース生成方法は、コンピュータがテストケース生成プログラムを実行することにより行われる方法である。
 テストケース生成プログラムは、コンピュータ読取可能な記録媒体に格納されて提供されてもよい。「コンピュータ読取可能な記録媒体」は、例えば、磁気ディスク、フレキシブルディスク、光ディスク、コンパクトディスク、ブルーレイ(登録商標)ディスク、DVD等である。
 また、テストケース生成プログラムは、プログラムプロダクトとして提供されてもよい。
 また、テストケース生成装置1は、処理回路により実現されてもよい。処理回路は、例えば、ロジックIC(Integrated Circuit)、GA(Gate Array)、ASIC(Application Specific Integrated Circuit)、FPGA(Field-Programmable Gate Array)である。
 なお、本明細書では、プロセッサと処理回路との上位概念を、「プロセッシングサーキットリー」という。
 つまり、プロセッサと処理回路とは、それぞれ「プロセッシングサーキットリー」の具体例である。
 また、テストケース生成装置1は、1台のコンピュータで構成されていてもよいし、複数台のコンピュータで構成されていてもよい。テストケース生成装置1が複数台のコンピュータで構成されている場合は、データ型取得部5、制約情報取得部6、境界値取得部7、データパターン生成部8、境界抽出部9、データオブジェクト生成部10、テストケース出力部11の機能が、各コンピュータに分散されて実現されてもよい。
***機能の説明***
 図1を参照して、本実施の形態に係るテストケース生成装置1の機能の概要を説明する。
 テストケース生成装置1の動作は、本実施の形態に係るテストケース生成方法に相当する。
 テストケース生成装置1は、テスト対象プログラムのテストに用いられるテストケースを生成する。テストケースは、テスト対象プログラムをテストするための、テスト対象プログラムへの入力値の集合である。
 データ型取得部5は、テスト対象プログラムをメモリ3もしくは入出力装置4を介して外部から読み込む。そして、データ型取得部5は、テストケースのデータの型を取得する。
 制約情報取得部6は、テストケースのデータ構造に関する制約情報(以下、単に制約情報ともいう)をメモリ3もしくは入出力装置4を介して外部から読み込む。テストケースのデータ構造に関する制約情報は、換言すれば、テスト対象プログラムで用いられる入力データのデータ構造に関する制約情報である。
 テストケースのデータ構造に関する制約情報は、例えばリンク構造のリンク数である。
 境界値取得部7は、テスト対象プログラムの境界値分析結果である境界値情報をメモリ3もしくは入出力装置4を介して外部から読み込む。
 より具体的には、境界値取得部7は、テスト対象プログラムで用いられる入力データの1つ以上の境界値を取得する。
 データパターン生成部8は、データ型取得部5が取得したデータの型と、制約情報取得部6が取得した制約情報とに基づき、テストケースのデータ構造を決定する。そして、データパターン生成部8は、決定したデータ構造をデータパターンとして生成する。
 データパターンとは、テスト対象プログラムの入力データに想定される複数のデータ構造である。つまり、データパターン生成部8は、入力データのデータ構造として想定される複数のデータ構造を複数のデータパターンとして生成する。各データパターンには1つ以上のデータ要素が含まれる。また、各データパターンに含まれる1つ以上のデータ要素の接続形態が相互に異なっている。データ要素の接続形態とは、データ構造に含まれるデータ要素の個数、階層の深さ、データ要素間の接続の形状である。ツリー型のデータ構造を例にすれば、ツリーに含まれるデータ要素の個数、ツリーの階層の深さ、ツリーの形状がデータ要素の接続形態に相当する。
 データパターン生成部8は、データ構造生成部に相当する。また、データパターン生成部8により行われる処理は、データ構造生成処理に相当する。
 境界抽出部9は、データパターン生成部8が生成した複数のデータパターンの各々で、データ構造の境界に位置するデータ要素を抽出する。つまり、境界抽出部9は、データパターンに含まれる1つ以上のデータ要素のうち接続の境界に位置するデータ要素(以下、境界データ要素ともいう)を抽出する。
 また、境界抽出部9は、データパターンのデータ構造の参照に加えて、制約情報取得部6が取得した制約情報も参照して境界に位置するデータ要素を抽出してもよい。
 境界抽出部9は、データ要素抽出部に相当する。また、境界抽出部9により行われる処理はデータ要素抽出処理に相当する。
 データオブジェクト生成部10は、境界値取得部7が取得した境界値を、境界抽出部9が取得した境界のデータ要素に割り当ててデータオブジェクトを生成する。
 データオブジェクト生成部10はテストケース出力部11とともに、テストケース生成部に相当する。また、データオブジェクト生成部10により行われる処理は、テストケース出力部11により行われる処理とともにテストケース生成処理に相当する。
 テストケース出力部11は、データオブジェクト生成部10が値を割り当てたデータオブジェクトを予め定めた形式に整形してテストケースを生成する。そして、テストケース出力部11は、生成したテストケースを、メモリ3もしくは入出力装置4を介して外部へ出力する。
 テストケース出力部11はデータオブジェクト生成部10とともに、テストケース生成部に相当する。また、テストケース出力部11により行われる処理は、データオブジェクト生成部10により行われる処理とともにテストケース生成処理に相当する。
***動作の説明***
 次に、図2を参照して、本実施の形態に係るテストケース生成装置1の動作の詳細を説明する。
 ステップS1において、データ型取得部5は、テスト対象プログラムをメモリ3もしくは入出力装置4を介して外部から読み込む。そして、データ型取得部5は、テスト対象プログラムを解析し、テストケースとなる入力データの型、すなわち、テスト対象プログラムの入力データの型の情報を取得する。
 次に、処理はステップS2へ進む。
 ステップS2において、制約情報取得部6は、データ構造に関する制約情報を読み込む。
 次に、処理はステップS3へ進む。
 なお、データ構造に関する制約情報の形式は、入力データの型に依存する。
 テスト対象プログラムの入力データの型が、例えば図12のリンク構造の型である場合は、制約情報には、リンクの数(リンクの長さ、あるいは深さとも呼ぶ)が示される。
 また、テスト対象プログラムの入力データの型が、例えば図13のバイナリツリーの型の場合は、制約情報には、ツリーの最大深さ及び/又はツリーの大きさ(ノード数)が示される。
 また、テスト対象プログラムの入力データの型が、例えば子ノードの数が2以上のNツリーである場合は、バイナリツリー型の制約情報に示される値に加えて、子ノードの最大接続数が制約情報に示される。
 次に、ステップS3において、境界値取得部7は、テスト対象プログラムの境界値情報を取得する。
 次に、処理はステップS4へ進む。
 境界値は、テスト対象プログラムの入力データの境界値である。本実施の形態では、入力データの境界値は、複数ある。
 また、境界値は、テスト対象のソフトウェアの仕様に依存する。
 例えば、図12のリンク構造の型に含まれる変数「value」が、複数の有効境界値と複数の無効境界値を持っていてもよい。
 また、型に含まれる変数が複数存在する場合には、それらの変数ごとにテスト対象のソフトウェアの仕様に従って境界値が決定される。
 次に、ステップS4において、データパターン生成部8は、ステップS1で取得された入力データの型と、ステップS2で取得された制約情報とに基づき、データパターンを生成する。
 次に、処理がステップS5へ進む。
 データパターン生成部8は、1つの入力データの型に対して1つ以上のデータパターンを生成する。1つの入力データの型に対して生成されるデータパターンの個数は、データの型と制約情報に依存する。
 また、ステップS4の時点で、データ構造の決定に関わる変数の値が決定される。例えばバイナリツリーの子ノードを指すポインタを格納する変数には、アドレスなどが格納される。しかし、それ以外の変数には値は割り当てられていない。
 次に、ステップS5において、境界抽出部9は、ステップS4で生成された各データパターンの境界データ要素を抽出する。
 次に、処理がステップS6へ進む。
 境界のデータ要素の抽出条件は、入力データの型などのテスト対象のソフトウェアの仕様に依存して予め決定されている。
 例えば、入力データの型が図12のリンク構造である場合は、親のデータを持たない先頭ノードと、子のデータが無く子のアドレスの代わりにヌルポインタが格納されている末端ノードを境界のデータ要素とするように定めることができる。
 また、例えば、入力データの型が図13のバイナリツリーである場合は、ルートノードと、少なくとも一つの子ノードがヌルのノードを境界のデータ要素とするように定めることができる。あるいは、ルートノードと、両方の子ノードがヌルであるノード、左の子ノードだけがヌルであるノード、右の子ノードだけがヌルであるノードを一つずつ境界のデータ要素として抽出するように定めることができる。
 次に、ステップS6において、データオブジェクト生成部10は、ステップS3で取得された境界値を、ステップS5で抽出された境界のデータ要素に割り当てる。境界のデータ要素に境界値が割り当てられた後のデータパターンがデータオブジェクトに相当する。
 次に、処理がステップS7へ進む。
 例えば、入力データの型が図12のリンク構造である場合は、データオブジェクト生成部10は、境界のデータ要素である先頭ノードには有効境界値を割り当てる。また、データオブジェクト生成部10は、同じく境界のデータ要素である末端ノードには無効境界値を割り当てる。更に、データオブジェクト生成部10は、境界のデータ要素ではないそれ以外のノードには、有効境界値、あるいは、いずれか2つの有効境界値の間の有効範囲に含まれる任意の値を割り当てる。
 ステップS4で生成された1つのデータパターンに対し、値の割り当て方法は1つとは限らない。複数の割り当て方法を予め準備しておき、データオブジェクト生成部10が複数の割り当て方法に従って複数の割り当てを行ってもよい。すなわち、データオブジェクト生成部10は、ステップS4で生成された1つのデータパターンから複数のデータオブジェクトを生成することができる。
 次に、ステップS7において、テストケース出力部11は、ステップS6で生成されたデータオブジェクトを予め定めた形式に整形してテストケースを生成する。そして、テストケース出力部11は、生成したテストケースを出力する。
 以上により、テストケース生成装置1は処理を終了する。
 ステップS1、ステップS2の実施順序は、逆であってもよい。またステップS3は、ステップS5より前に実施すればよい。ステップS3を、ステップS1、ステップS2の前に実施してもよい。また、ステップS3をステップS4の後に実施してもよい。
 ステップS1において、データ型取得部5は、テスト対象プログラム全体ではなく、テスト対象プログラムの記述言語を用いて記述されたテスト対象プログラムの入力データの型の情報を直接読み込んでもよい。
 また、データ型取得部5は、テスト対象プログラムの記述言語以外の他の言語を用いて記述されたテスト対象プログラムの入力データの型の情報を直接読み込んでもよい。
 ステップS5において、境界抽出部9は、データパターンの構造だけでなく、ステップS2において制約情報取得部6が取得した制約情報も用いて境界のデータ要素を抽出してもよい。
 例えば、リンク構造においてノードの最大数が5であるという情報が制約情報として与えられた場合は、境界抽出部9は、ルートノードである0番目のノードと、末端ノードである5番目のノードを、境界のデータ要素として抽出することができる。
 次に、具体例を用いてテストケース生成装置1の動作を説明する。
 以下の例では、テストケース生成装置1は、テスト対象プログラム、テストケースのデータ構造に関する制約情報、境界値情報を、入出力装置4を介して外部から読み込むものとする。
 図3は、本実施の形態に係るテスト対象プログラムの一部を示す。
 図4は、テストケースのデータ構造に関する制約情報を示す。
 図5は、境界値情報を示す。
 また以下の説明において、カッコ内のステップは、図2のステップに対応する。
 (ステップS1)
 データ型取得部5が、テスト対象プログラムを読み込む。
 また、データ型取得部5は、生成するテストケースに含ませる変数として、テスト対象メソッドfuncの変数nがあることを確認する。
 そして、データ型取得部5は、入力データの型として、図3の1~5行目に示すNodeを取得する。
 (ステップS2)
 続いて、制約情報取得部6が、図4に示す制約情報を取得する。
 図4の制約情報は、ノードの最大数が3であることを示している。
 (ステップS3)
 次に、境界値取得部7が、図5に示す境界値情報を取得する。
 図5の境界値情報は、有効境界値「0、10、11、254」と無効境界値「-1、255」を示している。
 (ステップS4)
 次に、データパターン生成部8は、ステップS1で取得された入力データの型がNode型であるとの情報と、ステップS2で取得されたノードの最大数が3であるとの情報とに基づき、図6に示すデータパターンを生成する。
 図6では、子ノードを持たないポインタ(ヌルポインタ)については矢印を省略している。
 データパターン生成部8は、テスト対象プログラムの入力データに想定される複数のデータ構造の全てをデータパターンとして生成する。データパターン生成部8は、図6に示すように、各々に1つ以上のデータ要素が含まれ、各々に含まれる1つ以上のデータ要素の接続形態が相互に異なっている複数のデータパターンを生成する。
 具体的には、データパターン生成部8は、i個(1≦i≦max_size)のデータ要素の接続形態が示されるデータ構造を第i次データパターンとして生成する。また、データパターン生成部8は、i個のデータ要素にj種類(j≧2)の接続形態が存在する場合に、j種類の接続形態に対応させてj種類の第i次データパターンを生成する。j種類の接続形態は、それぞれ、接続深さ(例えばツリーの階層深さ)及び/又は接続の形状(例えばツリーの形状)が異なっている。なお、第i次データパターンは第i次データ構造の例である。
 図4に示すように、「max_size=3」であるため、データパターン生成部8は、1~3個のデータ要素に対応させて第1次データパターン~第3次データパターンを生成する。
 図6の例では、(a)のデータパターンは第1次データパターンに相当する。また、(b)及び(c)のデータパターンは、それぞれ、第2次データパターンに相当する。更に、(d)~(h)のデータパターンは、それぞれ、第3次データパターンに相当する。
 なお、第1次データパターン(i=1)は、単一データ構造に相当する。
 i=2では、2種類(j=2)の接続形態が存在する。このため、前述のように、データパターン生成部8は、2種類の第2次データパターンを生成する((b)及び(c)のデータパターン)。
 また、i=3では、5種類(j=5)の接続形態が存在する。このため、前述のように、データパターン生成部8は、5種類の第3次データパターンを生成する((d)~(h)のデータパターン)。
 (ステップS5)
 次に、境界抽出部9が、ステップS4で生成された各データパターンの境界に位置する境界データ要素を抽出する。
 本実施の形態では、境界に位置する境界データ要素の抽出条件として、ルートノードと、子ノードを持たないリーフノードが定められているものとする。
 境界抽出部9は、第i次データパターンの境界データ要素を抽出する。また、j種類の第i次データパターンが存在する場合は、境界抽出部9は、j種類の第i次データパターンの各々で、境界データ要素を抽出する。なお、境界抽出部9は、図6の(a)に示す単一のデータ要素のみのデータパターンでは、境界データ要素として、単一のデータ要素を抽出する。
 これにより、境界抽出部9は、図6において、斜線が付されたノードを境界に位置する境界データ要素として抽出する。
 (ステップS6)
 次に、データオブジェクト生成部10が、データパターン(a)~(h)の各データ要素(value)に具体値を割り当てて、データオブジェクトを生成する。
 具体的には、データオブジェクト生成部10は、以下の(1)~(4)の割り当てルールに従って、各データ要素に具体値を割り当てる。
 (1)同一ノード数及び同一深さのデータパターンにおいて、与えられた全ての有効境界値を少なくとも一回は境界のデータ要素に割り当て、残りのデータ要素には有効値(境界値により識別可能な有効クラスの値)を割り当てる。
 なお、同一深さとは、データ要素の階層の深さ(接続の深さ)を意味する。
 (2)同一ノード数及び同一深さのデータパターンにおいて、与えられた全ての無効境界値を少なくとも一回は境界のデータ要素であるルートノードとリーフノードにそれぞれ割り当て、また、1つのデータパターンの1つの境界のデータ要素にのみ無効境界値を割り当て、残りの境界のデータ要素には有効境界値を割り当て、残りのデータ要素には有効値を割り当てる。
 (3)有効境界値が3つ以上ある場合は、同一ノード数及び同一深さのデータパターンの各々での有効境界値の組み合わせが相互に異なるように、3つ以上の有効境界値の各々を同一ノード数及び同一深さのデータパターンのいずれかの境界データ要素に割り当てる。
 (4)無効境界値が2つ以上ある場合は、同一ノード数及び同一深さのデータパターンの各々での無効境界値が相互に異なるように、2つ以上の無効境界値の各々を同一ノード数及び同一深さのデータパターンのいずれかの境界データ要素に割り当てる。
 ここで、図6に示すデータパターンと図5に示す有効境界値と無効境界値を用いて、上記の(1)~(4)の割り当てルールを解説する。
 図6の(a)のデータパターンでは、データオブジェクト生成部10は、割り当てルール(1)及び(3)に従って、「0、10、11、254」の4つの有効境界値の各々を、4つの図6の(a)のデータパターンの各々に割り当てる。つまり、データオブジェクト生成部10は、有効境界値の数と同数の(a)のデータパターンの各々に各有効境界値を割り当てる。
 この結果、データオブジェクト生成部10は、例えば、図7の(a-1)、(aー2)、(a-3)及び(a-4)のデータオブジェクトを生成する。
 また、データオブジェクト生成部10は、割り当てルール(2)及び(4)に従って、「-1、255」の2つの無効境界値の各々を、2つの図6の(a)のデータパターンの各々に割り当てる。つまり、データオブジェクト生成部10は、無効境界値の数と同数の(a)のデータパターンの各々に各無効境界値を割り当てる
 この結果、データオブジェクト生成部10は、例えば、図8の(a-5)及び(a-6)のデータオブジェクトを生成する。
 なお、図8では、無効境界値が割り当てられているデータ要素を太枠で表現している。
 図6の(b)及び(c)のデータパターンは両者とも同一の深さを有する。このため、上記の(1)~(4)の割り当てルールをそのまま適用することができる。従って、データオブジェクト生成部10は、図6の(b)及び(c)のデータパターンを深さ別のグループに分類する必要はない。
 データオブジェクト生成部10は、割り当てルール(1)及び(3)に従い、例えば、図7の(b-1)及び(c-1)のデータオブジェクトを生成する。
 図7の(b-1)及び(c-1)のデータオブジェクトでは、それぞれのデータオブジェクトの境界データ要素に有効境界値が割り当てられている。
 また、データオブジェクト生成部10は、割り当てルール(2)及び(4)に従って、例えば、図8の(b-2)、(b-3)、(c-2)及び(c-3)のデータオブジェクトを生成する。
 図8の(b-2)、(b-3)、(c-2)及び(c-3)のデータオブジェクトでは、それぞれのデータオブジェクトの境界データ要素の一方に無効境界値が割り当てられ、他方に有効境界値が割り当てられている。
 図6の(d)~(h)のデータパターンでは、図6の(d)~(g)は3段階の深さを有するが、図6の(h)は2段階の深さを有する。このため、上記の(1)~(4)の割り当てルールをそのまま適用することができない。
 従って、データオブジェクト生成部10は、図6の(d)~(h)のデータパターンを深さ別のグループに分類する。
 つまり、データオブジェクト生成部10は、図6の(d)~(h)のデータパターンを、3段階の深さを有するデータパターンのグループ(図6の(d)~(g))と、2段階の深さを有するデータパターンのグループ(図6の(h))とに分類する。
 そして、データオブジェクト生成部10は、グループごとに、割り当てルール(1)~(4)に従い、データオブジェクトを生成する。
 具体的には、データオブジェクト生成部10は、割り当てルール(1)及び(3)に従い、図6の(d)~(g)のデータパターンから、例えば、図7の(d-1)、(e-1)、(f-1)及び(g-1)のデータオブジェクトを生成する。
 図7の(d-1)、(e-1)、(f-1)及び(g-1)のデータオブジェクトでは、それぞれのデータオブジェクトの境界データ要素に有効境界値が割り当てられている。
 また、データオブジェクト生成部10は、割り当てルール(1)及び(3)に従い、図6の(h)のデータパターンから、例えば、図7の(h-1)及び(h-2)のデータオブジェクトを生成する。
 図7の(h-1)及び(h-2)のデータオブジェクトでは、それぞれのデータオブジェクトの境界データ要素に有効境界値が割り当てられている。
 また、データオブジェクト生成部10は、割り当てルール(2)及び(4)に従い、図6の(d)~(g)のデータパターンから、例えば、図8の(d-2)、(e-2)、(f-2)及び(g-2)のデータオブジェクトを生成する。
 図8の(d-2)、(e-2)、(f-2)及び(g-2)のデータオブジェクトでは、それぞれのデータオブジェクトの境界データ要素の一方に無効境界値が割り当てられ、他方に有効境界値が割り当てられている。
 また、データオブジェクト生成部10は、割り当てルール(2)及び(4)に従い、図6の(h)のデータパターンから、例えば、図8の(h-3)~(h-8)のデータオブジェクトを生成する。
 図8の(h-3)~(h-8)のデータオブジェクトでは、それぞれのデータオブジェクトの1つの境界データ要素に無効境界値が割り当てられ、他の境界データ要素の各々に有効境界値が割り当てられている。
 次に、テストケース出力部11が、図7と図8に示す全データオブジェクトを、図9に示す形式に整形し、整形後のデータオブジェクトをテストケースとして出力する。
 図9に示す各行がテストケースである。
 なお、図7のデータオブジェクトを整形して得られるデータを有効境界値テストケースという。つまり、図7に示すデータオブジェクトの識別子((a―1)、(b-1)等)と同じ識別子が記述されている図9の行のデータが有効境界値テストケースである。
 また、図8のデータオブジェクトを整形して得られるデータを無効境界値テストケースという。つまり、図8に示すデータオブジェクトの識別子((a―5)、(b-2)等)と同じ識別子が記述されている図9の行のデータが無効境界値テストケースである。
 図3のテスト対象プログラムに含まれる不具合は、図9に示すテストケースのうち、「a-6」、「c-3」、「g-2」、「h-7」及び「h-8」のテストケースによって検出することが可能である。
 なお、本実施の形態では、制約情報取得部6は、ノードの最大数が示される制約情報を1つ取得する例を説明した。しかし、制約情報取得部6は、複数種の制約情報を取得してもよい。例えば、制約情報取得部6は、ノードの最大数が示される制約情報に加えて、「同一ノード数及び同一深さのデータパターンは1つしか生成してはならない」との制約が示される制約情報を取得する。
 これによって、データパターン生成部8が生成するデータパターンの数を抑制することができる。制約情報取得部6が「同一ノード数及び同一深さのデータパターンは1つしか生成してはならない」との制約が示される制約情報を取得した場合は、図6に示す第3次データパターンでは、データパターン生成部8は、図6の(d)~(f)のデータパターン及び図6の(g)及び(h)のデータパターンのいずれかのみを生成する。
 また、境界抽出部9は、制約情報取得部6が取得した制約情報に示されるノードの最大数が3であるという制約も用いて境界のデータ要素を抽出してもよい。
 例えば、境界抽出部9は、ノードの最大数3から、取りうる深さの最小値と最大値である深さ0(ルートノード)と深さ2のデータ要素を境界のデータ要素として抽出してもよい。
***本実施の形態の効果の説明***
 以上のように、本実施の形態に係るテストケース生成装置1は、テスト対象プログラムの入力データに想定されるデータ構造の境界に位置する境界データ要素に入力データの境界値を割り当てる。
 このため、本実施の形態によれば、入力データのデータ構造における境界と入力データの値における境界とが適切に組み合わされたテストケースを生成することができる。
 つまり、本実施の形態に係るテストケース生成装置1は、入力データの型と、データ構造の制約と、入力データの境界値の情報を用いて、テスト対象プログラムに適した境界値の割り当て方法に従って、境界のデータ要素に境界値を割り当てる。
 これにより、特にソフトウェアの不具合が混入しやすい、構造と値の両面での境界のテストが可能となる。この結果、従来手法では検出できなかったテスト対象プログラムの不具合を検出することができる。
 また、本実施の形態に係るテストケース生成装置1では、データオブジェクト生成部10が、特定の条件を満たすデータパターンにおいて、全ての有効境界値を、その境界のデータ要素に少なくとも一回は割り当てる。
 これにより、定義域の全有効同値クラスを境界のデータ要素に割り当ててテストしたことになり、テストのカバレッジを上げることができる。
 また、データの境界値の全ての組み合わせを境界のデータ要素に割り当てる場合よりも、テストケース数を抑制することができる。この結果、テストの効率を上げ、テストの工数を削減することができる。
 また、本実施の形態に係るテストケース生成装置1では、データオブジェクト生成部10が、特定の条件を満たすデータパターンにおいて、全ての無効境界値を、境界のデータ要素に少なくとも一回は割り当てる。また、データオブジェクト生成部10は、残りのデータ要素には有効値又は有効境界値を割り当てる。これにより、1つのテストケースにつき無効境界値が1つのみ境界のデータ要素に割り当てられる。
 このため、本実施の形態に係るテストケース生成装置1で生成されたテストケースにより、境界値分析結果を用いた従来のテスト技法の、無効境界値を1つずつテストするという原則に適合するテストを行うことができる。
 この結果、テスト対象プログラムに複数の不具合が混在している場合においても、各不具合を分離して検出できる可能性が高くなる。
 そして、本実施の形態によれば、不具合の検出漏れ及び/又は修正漏れを防止し、テストの効率を上げ、テストの工数を削減することができる。
実施の形態2.
 本実施の形態では、テスト対象プログラムのテストでの目標カバレッジが達成される境界値の組み合わせをデータパターンごとに選択し、選択した境界値の組み合わせをデータパターンごとに境界データ要素に割り当てる構成を説明する。
 本実施の形態では、主に実施の形態1との差異を説明する。
 なお、以下で説明していない事項は、実施の形態1と同様である。
***構成の説明***
 本実施の形態に係るテストケース生成装置1の構成例を図10に示す。
 本実施の形態に係るテストケース生成装置1は、図1に示した構成に、プログラム構造取得部13とカバレッジ条件生成部14が追加されている。
***機能の説明***
 図10を参照して、本実施の形態に係るテストケース生成装置1の機能の概要を説明する。
 プログラム構造取得部13は、テスト対象プログラムをメモリ3もしくは入出力装置4を介して外部から読み込む。
 また、プログラム構造取得部13は、テスト対象プログラムのステートメント箇所、分岐箇所といった、テストの構造カバレッジ率の計測対象を取得する。
 カバレッジ条件生成部14は、プログラム構造取得部13が取得した構造カバレッジ率の計測対象から、構造カバレッジ率を100%にするために必要な構造カバレッジ条件を生成する。
 データオブジェクト生成部10は、境界値情報と、構造の境界のデータ要素の情報に加えて、カバレッジ条件生成部14が生成した構造カバレッジ条件に基づき、データパターンの各データ要素に値を割り当ててデータオブジェクトを生成する。
 つまり、本実施の形態では、データオブジェクト生成部10は、テスト対象プログラムのテストで目標のカバレッジ率(100%)が達成されるために必要な境界値の組み合わせをデータパターンごとに選択する。そして、本実施の形態では、データオブジェクト生成部10は、選択した境界値の組み合わせをデータパターンごとに境界データ要素に割り当ててデータオブジェクトを生成する。
 プログラム構造取得部13、カバレッジ条件生成部14及びデータオブジェクト生成部10以外の構成要素は、実施の形態1に示したものと同じである。このため、説明を省略する。
***動作の説明***
 図11を参照して、本実施の形態に係るテストケース生成装置1の動作の詳細を説明する。
 なお、実施の形態1と同じ動作については同じステップ番号を用い、説明を省略する。
 本実施の形態では、ステップS5の後は処理がステップS8に進む。
 ステップS8では、プログラム構造取得部13は、テスト対象プログラムをメモリ3もしくは入出力装置4を介して外部から読み込む。そして、プログラム構造取得部13は、テスト対象プログラムの構造カバレッジ率の計測対象を取得する。
 次に、処理がステップS9へ進む。
 ステップS9において、カバレッジ条件生成部14は、プログラム構造取得部13が取得した構造カバレッジ率の計測対象から、構造カバレッジ率を100%にするために必要な構造カバレッジ条件を生成する。
 次に、ステップS10へ進む。
 ステップS10において、データオブジェクト生成部10は、境界値情報と、境界のデータ要素の情報に加えて、カバレッジ条件生成部14が生成した構造カバレッジ条件に基づき、データパターンの各データ要素に値を割り当ててデータオブジェクトを生成する。
 次に、処理がステップS7へ進む。
 なお、データオブジェクト生成部10による値の割り当て方法として、例えば、以下の(1)の方法と(2)の方法が考えられる。
 (1)データオブジェクト生成部10は、実施の形態1に従って各データ要素に値を割り当てて生成されたデータオブジェクトの候補をテスト対象プログラムに入力して、テスト対象プログラムのテストを実行する。更に、データオブジェクト生成部10は、テストでのカバレッジが構造カバレッジ条件を満たすか否かを確認する。テストでのカバレッジが構造カバレッジ条件を満たしていない場合は、データオブジェクト生成部10は、各データ要素に異なる値を割り当てる。
 (2)データオブジェクト生成部10は、境界値情報と、境界のデータ要素の情報と、構造カバレッジ条件を、有界モデル検査といった記号実行による解析手法の制約条件として与え、各データ要素の値を決定する。
 なお、ステップS5及びステップS9は、ステップS10より前に実施すればよく、ステップS1からステップS8の前に行ってもよい。
 次に、具体例を用いて、本実施の形態に係るテストケース生成装置1の動作例を説明する。
 以下の例では、テスト対象プログラム、テストケースのデータ構造に関する制約情報、境界値情報を、入出力装置4を介して外部から読み込むものとする。
 図3は、本実施の形態に係るテスト対象プログラムの一部を示す。
 また、テスト対象プログラムのテストにおいて、テストの終了判定基準として用いる構造カバレッジ基準は、分岐カバレッジ基準とする。
 図4は、テストケースのデータ構造に関する制約情報を示す。
 図5は、境界値情報を示す。
 また以下の説明において、カッコ内のステップは、図11のステップに対応する。
 (ステップS8)
 プログラム構造取得部13は、図3のテスト対象プログラムのテストにおいて、分岐カバレッジ率の計測対象として、メソッドfunc内の二つのif文を取得する。
 (ステップS9)
 カバレッジ条件生成部14は、プログラム構造取得部13が取得したテスト対象プログラムの1つ目のif文の分岐カバレッジ率を100%にするために、「n.value」が255未満かつ「n.left」がヌルではない場合と、それ以外の場合の2つの条件を生成する。
 また、カバレッジ条件生成部14は、2つ目のif文についても同様に、「n.value」が255に等しい場合と、それ以外の場合の2つの条件を生成する。
 (ステップS10)
 データオブジェクト生成部10は、図4のデータ構造に関する制約情報と、図5の境界値情報に加えて、カバレッジ条件生成部14が生成した4つの条件を考慮して、if文の分岐カバレッジ率を100%にするように境界値を選択し、選択した境界値をデータ構造の境界のデータ要素に割り当てる。
***本実施の形態の効果の説明***
 以上のように、本実施の形態に係るテストケース生成装置1は、入力データの型と、データ構造の制約と、入力データの境界値情報と、テスト対象プログラムのテストに用いる構造カバレッジ率に関する情報を用いて、データオブジェクトの境界のデータ要素を考慮して、テスト対象プログラムに適した境界値の割り当て方法に従って、境界値を割り当てる。
 これにより、構造と値の両面での境界のテストに加えて、テスト対象プログラムの構造を網羅するテストを可能にするテストケースを生成できる。
 その結果、テスト対象プログラムの構造のカバレッジ率を上げることができ、不具合の検出率を向上させることができる。
 また、本実施の形態によれば、構造と値の両面での境界のテスト用と、構造カバレッジ率を向上させるためのテスト用の、それぞれのテストケースを分けて生成する場合よりも、テストケースの生成時間を短縮することができる。
 さらに、本実施の形態によれば、テストケース数を減らすことができるため、テストの実行時間や、期待値の算出時間を減らし、テスト工数を削減することができる。
 以上、実施の形態1及び2を説明したが、これら2つの実施の形態を組み合わせて実施しても構わない。
 あるいは、これら2つの実施の形態のうち、1つを部分的に実施しても構わない。
 あるいは、これら2つの実施の形態を部分的に組み合わせて実施しても構わない。
 また、これら2つの実施の形態に記載された構成及び手順を必要に応じて変更してもよい。
 1 テストケース生成装置、2 プロセッサ、3 メモリ、4 入出力装置、5 データ型取得部、6 制約情報取得部、7 境界値取得部、8 データパターン生成部、9 境界抽出部、10 データオブジェクト生成部、11 テストケース出力部、13 プログラム構造取得部、14 カバレッジ条件生成部。

Claims (11)

  1.  テストの対象となるテスト対象プログラムの入力データの1つ以上の境界値を取得する境界値取得部と、
     前記入力データのデータ構造として想定される複数のデータ構造であって、各々に1つ以上のデータ要素が含まれ、各々に含まれる1つ以上のデータ要素の接続形態が相互に異なっている複数のデータ構造を生成するデータ構造生成部と、
     前記複数のデータ構造の各々で、各々に含まれる1つ以上のデータ要素のうち接続の境界に位置するデータ要素を境界データ要素として抽出するデータ要素抽出部と、
     前記複数のデータ構造の各々で、前記1つ以上の境界値のうちのいずれかの境界値を前記境界データ要素に割り当てて、前記テスト対象プログラムのテストに用いられるテストケースを生成するテストケース生成部とを有するテストケース生成装置。
  2.  前記データ構造生成部は、
     i個(i≧1)のデータ要素の接続形態が示されるデータ構造を第i次データ構造として生成し、
     前記データ要素抽出部は、
     前記第i次データ構造で前記境界データ要素を抽出し、
     前記テストケース生成部は、
     前記1つ以上の境界値のうちのいずれかの境界値を前記第i次データ構造の前記境界データ要素に割り当てて、前記第i次データ構造のテストケースを生成する請求項1に記載のテストケース生成装置。
  3.  前記境界値取得部は、
     前記1つ以上の境界値として、2つ以上の有効境界値と1つ以上の無効境界値とを取得し、
     前記データ要素抽出部は、
     前記複数のデータ構造の各々で、2つ以上の前記境界データ要素を抽出し、
     前記テストケース生成部は、
     前記複数のデータ構造の各々で、前記2つ以上の有効境界値のうちのいずれかの有効境界値を前記2つ以上の前記境界データ要素の各々に割り当てて、前記テストケースとして、有効境界値テストケースを生成し、
     前記複数のデータ構造の各々で、前記1つ以上の無効境界値のうちのいずれかの無効境界値を前記2つ以上の前記境界データ要素のうちの少なくともいずれかに割り当てて、前記テストケースとして、無効境界値テストケースを生成する請求項1に記載のテストケース生成装置。
  4.  前記データ構造生成部は、
     i個(i≧1)のデータ要素の接続形態が示されるデータ構造を第i次データ構造として生成し、
     前記データ要素抽出部は、
     前記第i次データ構造で2つ以上の前記境界データ要素を抽出し、
     前記テストケース生成部は、
     前記2つ以上の有効境界値のうちのいずれかの有効境界値を前記第i次データ構造の前記2つ以上の前記境界データ要素の各々に割り当てて、前記第i次データ構造の前記有効境界値テストケースを生成し、
     前記1つ以上の無効境界値のうちのいずれかの無効境界値を前記第i次データ構造の前記2つ以上の前記境界データ要素のうちの少なくともいずれかに割り当てて、前記第i次データ構造の前記無効境界値テストケースを生成する請求項3に記載のテストケース生成装置。
  5.  前記データ構造生成部は、
     i個のデータ要素にj種類(j≧2)の接続形態が存在する場合に、j種類の接続形態に対応させてj種類の前記第i次データ構造を生成し、
     前記データ要素抽出部は、
     前記j種類の前記第i次データ構造の各々で、2つ以上の前記境界データ要素を抽出し、
     前記テストケース生成部は、
     前記j種類の前記第i次データ構造が、データ要素の接続深さに応じて2つ以上のグループに分類される場合に、
     グループごとに、前記2つ以上の有効境界値の全てが当該グループの1つ以上の前記第i次データ構造の前記境界データ要素のいずれかに割り当てられるように、前記2つ以上の有効境界値の各々を当該グループの前記1つ以上の前記第i次データ構造の前記境界データ要素のいずれかに割り当てて、グループごとの前記有効境界値テストケースを生成し、
     グループごとに、前記1つ以上の無効境界値の全てが当該グループの1つ以上の前記第i次データ構造の前記境界データ要素の各々に割り当てられるように、前記1つ以上の無効境界値の各々を当該グループの前記1つ以上の前記第i次データ構造の前記境界データ要素のいずれかに割り当てて、グループごとの前記無効境界値テストケースを生成する請求項4に記載のテストケース生成装置。
  6.  前記テストケース生成部は、
     前記有効境界値が3つ以上である場合に、1つ以上の前記第i次データ構造の各々での有効境界値の組み合わせが相互に異なるように、3つ以上の有効境界値の各々を前記1つ以上の前記第i次データ構造の前記境界データ要素のいずれかに割り当て、
     前記無効境界値が2つ以上である場合に、1つ以上の前記第i次データ構造の各々での無効境界値の組み合わせが相互に異なるように、2つ以上の無効境界値の各々を前記1つ以上の前記第i次データ構造の前記境界データ要素のいずれかに割り当てる請求項4に記載のテストケース生成装置。
  7.  前記データ要素抽出部は、
     前記複数のデータ構造のうちの、単一のデータ要素のみのデータ構造である単一データ構造から、前記境界データ要素として、前記単一のデータ要素を抽出し、
     前記テストケース生成部は、
     前記2つ以上の有効境界値の各々を、前記2つ以上の有効境界値と同数の前記単一データ構造の前記単一のデータ要素に割り当てて、前記2つ以上の有効境界値と同数の、前記単一データ構造の前記有効境界値テストケースを生成し、
     前記1つ以上の無効境界値の各々を、前記1つ以上の無効境界値と同数の前記単一データ構造の前記単一のデータ要素に割り当てて、前記1つ以上の無効境界値と同数の、前記単一データ構造の前記無効境界値テストケースを生成する請求項3に記載のテストケース生成装置。
  8.  データ要素抽出部は、
     前記入力データのデータ構造における制約に基づいて、前記複数のデータ構造の各々で、前記境界データ要素を抽出する請求項1に記載のテストケース生成装置。
  9.  前記テストケース生成部は、
     前記テスト対象プログラムのテストで目標のカバレッジ率が達成されるために必要な境界値の組み合わせをデータ構造ごとに選択し、選択した境界値の組み合わせをデータ構造ごとに前記境界データ要素に割り当てる請求項1に記載のテストケース生成装置。
  10.  コンピュータが、テストの対象となるテスト対象プログラムの入力データの1つ以上の境界値を取得し、
     前記コンピュータが、前記入力データのデータ構造として想定される複数のデータ構造であって、各々に1つ以上のデータ要素が含まれ、各々に含まれる1つ以上のデータ要素の接続形態が相互に異なっている複数のデータ構造を生成し、
     前記コンピュータが、前記複数のデータ構造の各々で、各々に含まれる1つ以上のデータ要素のうち接続の境界に位置するデータ要素を境界データ要素として抽出し、
     前記コンピュータが、前記複数のデータ構造の各々で、前記1つ以上の境界値のうちのいずれかの境界値を前記境界データ要素に割り当てて、前記テスト対象プログラムのテストに用いられるテストケースを生成するテストケース生成方法。
  11.  テストの対象となるテスト対象プログラムの入力データの1つ以上の境界値を取得する境界値取得処理と、
     前記入力データのデータ構造として想定される複数のデータ構造であって、各々に1つ以上のデータ要素が含まれ、各々に含まれる1つ以上のデータ要素の接続形態が相互に異なっている複数のデータ構造を生成するデータ構造生成処理と、
     前記複数のデータ構造の各々で、各々に含まれる1つ以上のデータ要素のうち接続の境界に位置するデータ要素を境界データ要素として抽出するデータ要素抽出処理と、
     前記複数のデータ構造の各々で、前記1つ以上の境界値のうちのいずれかの境界値を前記境界データ要素に割り当てて、前記テスト対象プログラムのテストに用いられるテストケースを生成するテストケース生成処理とをコンピュータに実行させるテストケース生成プログラム。
PCT/JP2021/005753 2021-02-16 2021-02-16 テストケース生成装置、テストケース生成方法及びテストケース生成プログラム WO2022176027A1 (ja)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2022580134A JP7274063B2 (ja) 2021-02-16 2021-02-16 テストケース生成装置、テストケース生成方法及びテストケース生成プログラム
PCT/JP2021/005753 WO2022176027A1 (ja) 2021-02-16 2021-02-16 テストケース生成装置、テストケース生成方法及びテストケース生成プログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2021/005753 WO2022176027A1 (ja) 2021-02-16 2021-02-16 テストケース生成装置、テストケース生成方法及びテストケース生成プログラム

Publications (1)

Publication Number Publication Date
WO2022176027A1 true WO2022176027A1 (ja) 2022-08-25

Family

ID=82931232

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2021/005753 WO2022176027A1 (ja) 2021-02-16 2021-02-16 テストケース生成装置、テストケース生成方法及びテストケース生成プログラム

Country Status (2)

Country Link
JP (1) JP7274063B2 (ja)
WO (1) WO2022176027A1 (ja)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09231103A (ja) * 1996-02-20 1997-09-05 Nippon Steel Corp テストデータ生成装置
WO2020194455A1 (ja) * 2019-03-25 2020-10-01 三菱電機株式会社 テストケース生成装置、テストケース生成方法、およびテストケース生成プログラム

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09231103A (ja) * 1996-02-20 1997-09-05 Nippon Steel Corp テストデータ生成装置
WO2020194455A1 (ja) * 2019-03-25 2020-10-01 三菱電機株式会社 テストケース生成装置、テストケース生成方法、およびテストケース生成プログラム

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
KANGOYE SEKOU; TODOSKOFF ALEXIS; BARREAU MIHAELA: "Practical methods for automatic MC/DC test case generation of Boolean expressions", 2015 IEEE AUTOTESTCON, IEEE, 2 November 2015 (2015-11-02), pages 203 - 212, XP032832794, DOI: 10.1109/AUTEST.2015.7356490 *

Also Published As

Publication number Publication date
JP7274063B2 (ja) 2023-05-15
JPWO2022176027A1 (ja) 2022-08-25

Similar Documents

Publication Publication Date Title
US8621441B2 (en) System and method for software immunization based on static and dynamic analysis
US9990458B2 (en) Generic design rule checking (DRC) test case extraction
US6353904B1 (en) Method of automatically generating new test programs for mixed-signal integrated circuit based on reusable test-block templates according to user-provided driver file
CN111124479B (zh) 配置文件的解析方法、系统及电子设备
US20200151082A1 (en) Managing cloud-based hardware accelerators
US10936474B2 (en) Software test program generation
US20210191846A1 (en) Data processing method and apparatus, device and storage medium
CN115952758A (zh) 芯片验证方法、装置、电子设备及存储介质
US10823782B2 (en) Ensuring completeness of interface signal checking in functional verification
CN114691371A (zh) 多线程同时转换Pattern的方法及装置
US10901827B2 (en) Failover of a hardware accelerator to software
CN112597718B (zh) 集成电路设计的验证方法、验证装置以及存储介质
US10747920B2 (en) Semiconductor LSI design device and design method
JP7274063B2 (ja) テストケース生成装置、テストケース生成方法及びテストケース生成プログラム
JP6663801B2 (ja) 半導体lsi設計装置および設計方法
US10831975B2 (en) Debug boundaries in a hardware accelerator
US10747601B2 (en) Failure estimation in circuits
US20200004666A1 (en) Debug boundaries for hardware accelerators
CN116306392A (zh) 芯片仿真装置、方法、电子设备和存储介质
CN112232003B (zh) 对设计进行仿真的方法、电子设备及存储介质
JP2022124240A (ja) 診断パターン生成方法及び計算機
US11200126B2 (en) Utilizing translation tables for testing processors
US7277840B2 (en) Method for detecting bus contention from RTL description
US10523186B1 (en) Vulnerability determination in circuits
JP2009238176A (ja) 情報処理装置およびプログラムの検証方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21926467

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2022580134

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21926467

Country of ref document: EP

Kind code of ref document: A1