Unit test device and unit test method
The unit testing device addresses inefficiencies in manual checklist creation by automatically generating test programs and data, enhancing testing efficiency and reducing errors.
Patent Information
- Application Number
- JP2024069367
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-04-22
- Publication Date
- 2025-11-04
AI Technical Summary
Existing unit testing methods require manual creation of checklists and test programs, leading to transcription errors and reduced efficiency.
A unit testing device that automatically generates test programs and data based on checklists, using a control unit to create and execute tests, and a memory unit to store expected input and output values.
Improves the efficiency of unit testing by reducing rework due to transcription errors and automating the creation of test programs and data.
Smart Images

Figure 2025165320000001_ABST
Abstract
Description
[Technical Field]
[0001] The present invention relates to a unit test device and a unit test method. [Background technology]
[0002] A report program that creates reports such as insurance policy documents is made up of multiple programs. When creating such a report program, each of the programs that make up the report program is created based on a design document, and unit tests are often performed to confirm that each program has been created appropriately according to the design document.
[0003] Unit testing involves preparing a checklist of expected input values and output values for the program under test, inputting test data created based on the checklist into a test program that includes the program under test and programs before and after it, and running the program to verify that the output values match the expected output values, thereby verifying that the program under test has been written according to the design document.
[0004] Because checklists, test programs, and test data are created manually by developers for each program, errors in their creation can lead to rework. Therefore, creating a mechanism or system to prevent this rework is an urgent issue.
[0005] A technology for automatically generating test programs is disclosed in Patent Document 1. Patent Document 1 describes a method for storing asset program components in association with test scenarios, and for executing tests based on program components for specific applications generated from a selected asset program and the corresponding test scenarios. [Prior art documents] [Patent documents]
[0006] [Patent Document 1] Japanese Patent Application Laid-Open No. 2007-128456 Summary of the Invention [Problem to be solved by the invention]
[0007] However, although Patent Document 1 proposes a technique for automatically generating a test program, it does not propose automatically generating a test program from a checklist.
[0008] Comprehensive testing is essential to ensure program quality, and it is common to create a checklist and check the comprehensiveness before conducting the test.
[0009] In the method of Patent Document 1, when a test program is automatically generated from a checklist, the developer must read the checklist and transcribe it into the logic for automatically generating the test program. However, in this case, transcription errors can cause rework and reduce the efficiency of unit testing.
[0010] Therefore, an object of the present invention is to provide a technique that can improve the efficiency of unit testing. [Means for solving the problem]
[0011] In order to solve the above problems, one representative unit testing device of the present invention is a unit testing device that has a control unit and a memory unit and performs unit testing of each program that makes up a report program.The memory unit stores a checklist containing the expected input values and expected output values of the program to be tested, and the control unit creates test data and a test program based on the checklist, inputs the test data and runs the test program, determines whether the output value of the test program matches the expected output value, and outputs the result of the determination. [Effects of the Invention]
[0012] According to the present invention, the efficiency of unit testing can be improved.
[0013] Problems, configurations, and effects other than those described above will become apparent from the following description of the embodiments. [Brief explanation of the drawings]
[0014] [Figure 1] FIG. 1 is a functional block diagram illustrating an example of a unit test device according to an embodiment of the present invention. [Figure 2] 1 is a block diagram showing an example of a hardware configuration of a computer to which a unit test device according to an embodiment of the present invention is applied; [Figure 3A] FIG. 10 is a diagram illustrating an example of a checklist. [Figure 3B] FIG. 10 is a diagram illustrating an example of a test data template. [Figure 3C] FIG. 10 illustrates an example of a test program template. [Figure 4] FIG. 2 is a diagram illustrating a form program that is a target of unit testing in this embodiment. [Figure 5] FIG. 2 is a block diagram showing an example of the hardware configuration of a computer on which a form program is executed. [Figure 6] FIG. 10 is a diagram showing an example of an insurance plan form Dto. [Figure 7] 10 is a flowchart illustrating an example of processing of a form program. [Figure 8] 10 is a flowchart showing an example of processing of a form function (individual) program. [Figure 9] 10 is a flowchart illustrating an example of a process performed by a test program creating unit. DETAILED DESCRIPTION OF THE INVENTION
[0015] Hereinafter, an embodiment will be described with reference to the drawings. [Example]
[0016] First, the creation of a form program in this embodiment will be described.
[0017] A report program that creates reports such as insurance application forms consists of multiple programs. The developer who creates the report program creates a design document for each program that makes up the report program, and then creates the program that corresponds to the design document. Unit testing is performed to verify that this program has been created according to the design document.
[0018] Unit testing involves preparing a checklist of expected input values and output values for the program under test, inputting test data created based on the checklist into a test program that includes the program under test and programs before and after it, and running the program to verify that the output values match the expected output values, thereby verifying that the program under test has been written according to the design document.
[0019] The unit test device of this embodiment automatically creates a test program and test data based on a checklist.
[0020] FIG. 1 is a functional block diagram showing an example of a unit test device according to this embodiment.
[0021] The unit test device 100 of this embodiment executes unit tests on programs that constitute a form program.
[0022] The unit test device 100 includes a test program creation unit 101 , an execution unit 102 , an output result comparison unit 103 , an output unit 104 , and a storage unit 105 .
[0023] The storage unit 105 stores a checklist 111, a test data template 112, and a test program template 113.
[0024] The checklist 111 is created by a developer in accordance with the design document of the program to be tested. Details of the checklist 111 will be described later with reference to FIG. 3A.
[0025] The test data template 112 and the test program template 113 are stored in advance in the storage unit 105. Details of the test data template 112 and the test program template 113 will be described later with reference to FIGS. 3B and 3C.
[0026] The test program creation unit 101 acquires the input values and expected output values contained in the checklist 111 from the storage unit 105, and creates a test program and test data using a test data template 112 and a test program template 113.
[0027] The execution unit 102 receives the test data created by the test program creation unit 101, executes the test program, and outputs an output value.
[0028] The output result comparison unit 103 compares the output value output from the execution unit 102 with the expected output value acquired from the checklist 111 .
[0029] The output unit 104 outputs the comparison result of the output result comparison unit 103 by displaying it on a display or the like.
[0030] The unit test apparatus 100 is executed on a computer 200 having a hardware configuration as will be described later with reference to FIG. 2, thereby realizing each process.
[0031] FIG. 2 is a block diagram showing an example of the hardware configuration of a computer to which the unit test apparatus 100 of this embodiment is applied.
[0032] The calculator 200 is a server or computer configured by a CPU (Central Processing Unit) 201, a memory 202, a storage device 203, a communication unit 204, an input unit 205, and an output unit 206, which are interconnected via a bus 207.
[0033] The CPU 201 is a central processing unit and a control unit of the unit test apparatus 100. The CPU 201 implements necessary functions by executing a program stored in the memory 202 (or the storage device 203).
[0034] The memory 202 is a main storage device used when the CPU 201 executes processing, and is configured with a volatile storage element such as a RAM (Random Access Memory).
[0035] The storage device 203 is an auxiliary storage device for storing input data provided to the CPU 201 and output data output from the CPU 201, and is configured with a non-volatile storage element such as an HDD (Hard Disk Drive) or an SSD (Solid State Drive).
[0036] The communication unit 204 is an interface used by the computer 200 to communicate with external devices, and is configured by a NIC (Network Interface Card) etc. The communication unit 204 is connected to a network (e.g., the Internet) and communicates with external devices via the network.
[0037] The input unit 205 is an interface that accepts input from a user (operator), and is configured with a keyboard, a touch panel, a card reader, a voice input device, or the like.
[0038] The output unit 206 is an interface that outputs data to an operator, and is composed of a display, a speaker, a printer, etc. The bus 207 is an internal communication path of the computer 200.
[0039] In this embodiment, the unit test apparatus 100 is executed on one or more computers 200 having the hardware configuration illustrated in FIG. 2, thereby realizing the processes described below.
[0040] FIG. 3A is a diagram showing an example of the checklist 111. As shown in FIG.
[0041] A checklist 111 is created for each program under test. The program name under test 301 is a program name that identifies the program under test.
[0042] The input conditions 302 include expected input values of the program under test, as well as the sheet name and item name.
[0043] The confirmation content 303 includes an expected output value when the input value of the input condition 302 is input to the program under test, and a line number assigned to the expected output value.
[0044] A unit test is performed multiple times on a single program under test using test cases with different conditions. The test case ID 304 is an ID that identifies each test case.
[0045] The developer who creates the checklist 111 enters input values and expected output values in the input conditions 302 and confirmation details 303 columns of the checklist in accordance with the contents of the design document of the program to be tested.
[0046] The input values for the report program are edited as a common insurance plan report Dto (Data Transfer Object) for each program that makes up the report program. Therefore, the sheet names and item names of the input values must be unified.
[0047] In the sheet name and item name fields of input conditions 302, a pull-down menu is displayed based on the data input sheet, and the developer selects the sheet name and item name from the pull-down menu. This prevents incorrect input of sheet names and item names and ensures that the sheet names and item names entered are consistent.
[0048] The data entry sheet is a list of item names that displays a pull-down menu for developers to enter sheet and item names when creating a checklist. The data entry sheet has multiple sheets for each Dto of the input values for the report program, and the sheet names are names that identify these sheets.
[0049] The data entry sheet also includes a sheet with English item names corresponding to Japanese item names, allowing the entered Japanese item names to be converted into the English used in the program.
[0050] By standardizing the sheet names and item names of input values and creating a common insurance plan report Dto for each program that makes up the report program, it is possible to automate the creation of test data and test programs.
[0051] The developer also selects the input conditions 302 and confirmation details 303 to be used in the test case of each test case ID 304, and enters a circle in the corresponding field.
[0052] FIG. 3B is a diagram showing an example of the test data template 112.
[0053] The test data template 112 has an item name 311 for each item of the input value of the form program, and a default input value 312 for each item. The item name is a standardized item name for the insurance policy form Dto.
[0054] The test program creation unit 101 creates test data for each test case ID by transcribing the input values of the input conditions 302 that have been marked with a circle in the checklist 111 into the input value column for the corresponding item name in the test data template 112.
[0055] FIG. 3C is a diagram showing an example of the test program template 113.
[0056] The test program template 113 includes a pre-processing program 321 for the program under test, a test data reading program 322 for reading test data, a calling program 323 for calling the program under test, and an expected value determination processing program 324 for determining whether the output value of the program under test matches the expected output value by referring to a test result expected value determination code 325.
[0057] The test program creation unit 101 creates a test program by transcribing the test target program name 301 as the program to be called by the calling program 323, and transcribing the line number and output expected value of the confirmation content 303 into the test result expected value judgment code 325 used by the expected value judgment processing program 324 for judgment.
[0058] Next, the form program to be subjected to the unit test in this embodiment will be described with reference to FIG.
[0059] FIG. 4 is a diagram for explaining a form program that is the subject of unit testing in this embodiment.
[0060] The form program is executed on a computer 500 having a hardware configuration as shown in FIG. 5, which will be described later, to realize each process.
[0061] The form program is made up of a screen function program group 401, a form function (common) program 402, and a form function (individual) program group 403.
[0062] The screen function program group 401 checks the input values entered by the user on the input screen displayed on the terminal device 510 (FIG. 5). The input values include, for example, the customer's age, hospitalization, and insurance amount in case of death, and have upper and lower limits. Here, it is checked whether the input values are logically correct, for example, whether the input values exceed the upper and lower limits, and whether anything other than numbers has been entered in the amount column.
[0063] In addition, an input field for input values is provided for each preset Dto item name on the input screen displayed on the terminal device 510 by the screen function program group 401. This allows the insurance plan form Dto to be edited from the input value, and the interface can be standardized.
[0064] If there is no problem with the input values, the screen function program group 401 calls the form function (common) program 402 and passes the input values to the form function (common) program 402 as Dto.
[0065] The form function (common) program 402 checks the input values in the same way as the screen function program group 401, and if there are no problems with the input values, edits the insurance policy form Dto from the input values. The insurance policy form Dto is stored in memory 502 (FIG. 5).
[0066] In the insurance plan, multiple reports are created for multiple insurance products, special provisions, etc. based on input values. Each report is created by the report function (individual) program group 403, but the input values required for each report are different. By editing the insurance plan form Dto from the input values and using the insurance plan form Dto in common across all report function (individual) program groups 403, the interface can be standardized regardless of product or report.
[0067] After editing the insurance plan document Dto, the document function (common) program 402 calls a document function (individual) program in the document function (individual) program group 403 that creates the document required for the insurance product selected by the user, and passes the insurance plan document Dto to the document function (individual) program.
[0068] The report function (individual) programs of the report function (individual) program group 403 are programs that create each report. The report function (individual) programs edit the variable items of the variable-length data of the report based on the input values included in the insurance policy form Dto, output the variable-length character string, and return to the processing of the report function (common) program 402.
[0069] The form function (common) program 402 calls the print function, prints the form created by the form function (individual) program group 403 in the output unit 506 (FIG. 5), and returns to the processing of the screen function program group 401.
[0070] FIG. 5 is a block diagram showing an example of the hardware configuration of a computer that executes the form program of FIG.
[0071] The computer 500 is connected to a terminal device 510 via a network. The terminal device 510 is configured by a mobile terminal, an information processing device, or the like, and performs input by the user, screen display, and the like.
[0072] The calculator 500 is a server or computer configured by a CPU (Central Processing Unit) 501, a memory 502, a storage device 503, a communication unit 504, an input unit 505, and an output unit 506, which are interconnected by a bus 507.
[0073] The CPU 501 is a central processing unit that implements necessary functions by executing a program stored in the memory 502 (or the storage device 503).
[0074] The memory 502 is a main storage device used when the CPU 501 executes processing, and is configured with a volatile storage element such as a RAM (Random Access Memory).
[0075] The storage device 503 is an auxiliary storage device for storing input data provided to the CPU 501 and output data output from the CPU 501, and is configured with a non-volatile storage element such as an HDD (Hard Disk Drive) or an SSD (Solid State Drive).
[0076] The communication unit 504 is an interface used by the computer 500 to communicate with external devices, and is configured by a NIC (Network Interface Card) etc. The communication unit 504 is connected to a network (e.g., the Internet) and communicates with external devices via the network.
[0077] The input unit 505 is an interface that accepts input from a user (operator), and is configured with a keyboard, a touch panel, a card reader, a voice input device, or the like.
[0078] The output unit 506 is an interface that outputs data to the operator, and is composed of a display, a speaker, a printer, etc. The bus 507 is an internal communication path of the computer 500.
[0079] In this embodiment, the form program is executed on one or more computers 500 having a hardware configuration such as that shown in FIG. 5, thereby realizing the processes described below.
[0080] Next, the insurance policy form Dto will be described with reference to FIG.
[0081] FIG. 6 is a diagram showing an example of the insurance policy form Dto.
[0082] As described above with reference to FIG. 4, the form programs to be tested by the unit test device 100 of this embodiment share a common input interface for the form functions.
[0083] The Dto passed from the screen function program group 401 is edited as a group of insurance plan forms Dto by the form function (common) program 402 and passed to the form function (individual) program group 403.
[0084] The form function (common) program 402 unifies Dto such as common variables Dto and policyholder / insured information Dto input as one piece of customer information, and creates an insurance plan form Dto.
[0085] By integrating the input values entered by the user into the insurance policy form Dto as a data group, the data used to create each form can be unified.
[0086] Furthermore, by standardizing the data used to create each report, the checklists used in unit testing can be standardized, and the creation of test programs and test data can be automated.
[0087] In addition, by using the insurance plan form Dto, the logic for automatically creating test programs and test data can be unified, making it easy to make specification changes such as adding or deleting forms.
[0088] Fig. 7 is a flowchart showing an example of processing of the form program in Fig. 4. This processing is realized by the CPU 501 of the computer 500 executing a program stored in the memory 502 (or the storage device 503).
[0089] When the user selects an insurance product and inputs input values using the terminal device 510, the screen function program group 401 checks the input values and calls the form function (common) program (step S701). The input values are passed to the form function (common) program 402 with Dto as an argument.
[0090] Next, the form function (common) program 402 checks the value input by the user and determines whether the input value is within the range of the upper and lower limits (step S702).
[0091] If no input value other than the default input value has been entered (NO in step S702), the report function (common) program 402 executes error processing such as displaying an error on the terminal device 510 (step S703) and terminates this processing.
[0092] On the other hand, if the default input value has been entered (YES in step S702), the report function (common) program 402 edits the insurance plan report Dto based on the Dto passed from the screen function program group 401 (step S704).
[0093] Next, the form function (common) program 402 acquires a list of form codes for forms required for the insurance product selected by the user by referring to the form code master table (step S703). The form code master table is a list of form codes that uniquely identify forms corresponding to each insurance product.
[0094] Next, the form function (common) program 402 repeatedly executes the processes of steps S706 and S707 until the processes for all forms in the form code list are completed.
[0095] First, the form function (common) program 402 refers to the form code list and acquires the form name of the required form (step S706).
[0096] Next, the form function (common) program 402 calls the corresponding form function (individual) program based on the form name acquired in step S706 (step S707), and passes the insurance policy form form Dto to the called form function (individual) program. The form function (individual) program creates each form based on the insurance policy form form Dto. The processing of the form function (individual) program will be described later with reference to FIG. 8.
[0097] When processing of steps S706 and S707 is completed for all reports in the report code list, the report function (common) program 402 calls the print function (step S708), prints the report created by the report function (individual) program on the output unit 506, and terminates this processing.
[0098] FIG. 8 is a flowchart showing an example of processing of the form function (individual) program.
[0099] The form function (individual) program sets values to variable items of variable-length data of the form based on the values of the insurance policy form Dto (step S801).
[0100] Next, the form function (individual) program stores the variable-length data of the form for which the value has been set in the form function (common) program 402 (step S802), and ends this processing.
[0101] The report function (common) program 402 and the report function (individual) program group 403 are in a parent-child relationship. Therefore, the report function (individual) program group 403 must always have the insurance plan report Dto as an argument. This makes it easy to change specifications by creating a report based on the insurance plan report Dto even when a report is added or deleted.
[0102] 9 is a flowchart showing an example of processing by the test program creating unit 101. This processing is realized by the CPU 201 of the computer 200 executing a program stored in the memory 202 (or the storage device 203).
[0103] The test program creating unit 101 determines whether the checklist 111, the test data template 112, and the test program template 113 are stored in a specified folder in the storage device 203 (step S901).
[0104] If the checklist 111, test data template 112, and test program template 113 are not stored in the specified folder (NO in step S901), the test program creation unit 101 executes error processing such as displaying an error on the output unit 206 (step S902), and terminates this processing.
[0105] On the other hand, if the checklist 111, the test data template 112, and the test program template 113 are stored in the specified folder (YES in step S901), the test program creation unit 101 reads the checklist 111 (step S903).
[0106] Next, the test program creating unit 101 stores in the memory 202 the sheet names, item names, and input values for which a circle has been entered in the input conditions 302 of the checklist 111 (step S904).
[0107] Next, the test program creating unit 101 uses the data input sheet to convert Japanese into English in the input conditions 302 of the checklist 111 held in step S904 (step S905).
[0108] Next, the test program creating unit 101 stores in the memory 202 the line numbers and output expected values for which a circle has been entered in the confirmation content 303 of the checklist 111 (step S906).
[0109] Next, the test program creating unit 101 repeatedly executes the processes of steps S907 to S909 until the processes for all test case IDs 304 in the checklist 111 are completed.
[0110] First, the test program creating unit 101 copies the test data template 112 stored in a specified folder in the storage device 203 to the memory 202 (step S907).
[0111] Next, the test program creating unit 101 changes the file name of the copied test data template 112 (step S908). The file name is set based on the test case ID 304.
[0112] Next, the test program creating unit 101 transcribes the input value held in step S904 into the input value 312 corresponding to the relevant item name 311 in the test data template 112 (step S909).
[0113] When the processes of S907 to S909 are completed for all test case IDs 304 in the checklist, the test program creation unit 101 copies the test program template 113 stored in the specified folder of the storage device 203 to the memory 202 (step S910).
[0114] Next, the test program creating unit 101 changes the file name of the copied test program template 113 (step S911). The file name is set based on the name 301 of the program to be tested.
[0115] Next, the test program creating unit 101 repeatedly executes the processes of steps S912 and S913 until the processes for all test cases in the checklist are completed.
[0116] First, the test program creation unit 101 creates a test method that calls the program to be tested with an input value read from the test data (step S912).
[0117] The test program creation unit 101 creates a test method by transferring the test target program name 301 to the test target program called by the calling program 323 of the test program template 113 .
[0118] Next, the test program creating unit 101 transcribes the line number and the output expected value stored in step S906 into the test result expected value determination code 325 of the test program template 113 (step S913).
[0119] When the processing of steps S912 and S913 is completed for all test cases in the checklist, the test program creation unit 101 outputs the created test data and test program to a specified folder in the storage device 203 (step S914), and ends this processing.
[0120] According to this embodiment, test programs and test data are automatically created from checklists, which reduces the workload of creating test programs and test data and prevents rework due to input errors, thereby improving the efficiency of unit testing.
[0121] In addition, in the form program, by editing the insurance plan form Dto from the input values using the form function (common) program 402, the interface can be standardized regardless of the product or form.
[0122] Furthermore, by standardizing the interface, it is possible to automate the creation of test programs and test data for unit testing.
[0123] Although the present embodiment has been described using the unit test of an insurance form program as an example, the present invention is not limited to this and can be applied to other form programs that create multiple forms.
[0124] It should be noted that the present invention is not limited to the above-described embodiment, and includes various modifications. For example, the above-described embodiment has been described in detail to clearly explain the present invention, and the present invention is not necessarily limited to an embodiment having all of the described configurations. [Explanation of symbols]
[0125] 100: Unit test equipment 101: Test Program Creation Department 102: Executive Department 103: Output result comparison section 104: Output section 105: Storage section 111: Checklist 112: Test data template 113: Test program template
Claims
1. A unit test device that includes a control unit and a storage unit and performs unit tests on each program that constitutes a form program, The storage unit storing a checklist having possible input values and expected output values of the program under test; The control unit Creating test data and a test program based on the checklist; inputting the test data and executing the test program; determining whether an output value of the test program matches an expected output value; A unit test device outputs the result of the determination.
2. 2. The unit test apparatus according to claim 1, The form program The input values entered by the user are stored in memory as a Dto (Data Transfer Object) common to each program that makes up the form program. A unit test device that is a program that edits the variable-length data of each form based on the Dto.
3. 3. The unit test device according to claim 2, The form program A unit testing device that is a program that inputs input values corresponding to the item names of the Dto that have been set in advance.
4. 3. The unit test device according to claim 2, The storage unit Store a test data template having the item name of the Dto; The control unit a unit test device that creates the test data by transcribing the input values of the checklist so that they correspond to the corresponding item names of the test data template;
5. 3. The unit test device according to claim 2, The storage unit storing a test program template having a test data reading program for reading the test data, a calling program for calling the program to be tested, and an expected value judgment processing program for referring to a test result expected value judgment code and judging whether an output value of the program to be tested matches the output expected value; The control unit a unit test device that creates the test program by transcribing the program name of the program to be tested as a program to be called by the calling program and transcribing the output expected value into the test result expected value determination code;
6. A unit testing method for a unit testing device that includes a control unit and a storage unit and performs unit testing of each program that constitutes a form program, comprising: The storage unit storing a checklist having possible input values and expected output values of the program under test; The control unit Creating test data and a test program based on the checklist; inputting the test data and executing the test program; determining whether an output value of the test program matches an expected output value; A unit testing method that outputs the result of the determination.
Citation Information
Patent Citations
Program management device
JP2007128456A