プログラムの単体テストに関する記述のうち, 適切なものはどれか。
平成22年度 春期 ITパスポート試験 問47
This question's explanation and your answers so far.
問 47
Incorrectア
Combining several programs and testing them all at once describes the integration test, the process that comes after unit testing. Unit testing, as its name says, is performed on each program by itself, so the statement that no test is performed for each individual program is the exact opposite of the definition. Moreover, if programs are combined without each one having been verified, then when a defect appears you cannot tell which program caused it, and the effort of fixing it grows instead.
Incorrectイ
The specification for a unit test is created on the basis of the program design (detailed design), the stage where the internal structure of the program is decided. In the V-model, what corresponds to system requirements definition is the system test (overall test), and what is created at the stage of defining the system requirements is the specification for the system test. This choice mixes up the correspondence that each test specification is created in the design process matching it.
Incorrectウ
Having the users of the system create the test data and check the results from the point of view of the users is the way the acceptance test (operational test) is carried out. Test data for a unit test is prepared by the developers themselves, who grasp the logic of the program and think about which statements and branches are to be exercised, that is, about coverage. Users normally do not know the logic inside the program, so they cannot create data aimed at coverage.
- エ
正解 The correct answer is エ. Unit testing (module testing) takes each created program one by one and checks whether that single program works as designed; it is the first test in the development process. The people who run it are the developers themselves, who know the inside of the program, so alongside black-box testing that looks only at inputs and outputs, white-box testing, which verifies the program while tracing its internal processing steps, is central. For that reason, coverage criteria are set, such as whether every statement has been executed at least once (statement coverage) and whether both the true side and the false side of a conditional branch have been taken (branch coverage), and test data is prepared so that even the completeness of the logic is covered. The description in エ states exactly this essence of unit testing, so it is appropriate. By closing the gaps in the internal logic here, the later integration test and the stages after it no longer have to chase simple coding mistakes inside each individual program, and can focus on defects in the joints between programs.
- Unit testing is the process of verifying internal logic on a per-program (per-module) basis, and developers carry it out mainly as white-box testing (combined with black-box testing). Its characteristic is that test data is created to satisfy coverage criteria such as statement coverage and branch (decision) coverage, so that even the completeness of the logic is checked.
- Learn the correspondence between test processes and design processes (the V-model): unit test to program design, integration test to software (architectural) design, system test to system requirements definition, acceptance test to the requirements of the users. Each test specification is created in the design process that corresponds to it, and the people who run the tests also shift from developers to users as the process advances.