CS 351 Unit Testing As each program module








- Slides: 8
CS 351 Unit Testing As each program module is coded, it can be tested in isolation. Black Box ● ● Tests are conducted at the module interface. Used to demonstrate ● ● ● ● software functions are operational input is properly accepted outputs are properly produced integrity of external information (e. g. database) is maintained examines some fundamental aspect of a system with little regard to internal logic. © 2003 Ray S. Babcock
CS 351 cont. White Box ● A test case design method that uses the control structure of the procedural design to derive tests cases that ● ● ● guarantee all independent paths within a module have been exercised at least once, exercise all logical decisions on their true and false sides, execute all loops at their boundaries and within their operational bounds, and exercise internal data structures to ensure their validity. © 2003 Ray S. Babcock
CS 351 Nature of Software Defects ● ● ● Logic errors and incorrect assumptions are inversely proportional to the probability that a program path will be executed. We often believe that a logical path is not likely to be executed when, in fact, it may be executed on a regular basis. Typographical errors are random. © 2003 Ray S. Babcock
CS 351 Unit Test Environment DRIVER MODULE TO BE TESTED STUB © 2003 Ray S. Babcock
CS 351 Driver Levels ● ● Driver level 1 – Simply call the module under test. Driver level 2 – Send parameter(s) from a table (or external file) Driver level 3 – Display parameter(s) Driver level 4 – Send parameter(s) from a table (or external file) and display parameters. © 2003 Ray S. Babcock
CS 351 Stub Levels ● ● Stub level 1 – Display a trace message. Stub level 2 – Display passed parameters. Stub level 3 – Return a value from a table (or external file) Stub level 4 – Do a table search for input parameter and return associated output parameter. © 2003 Ray S. Babcock
CS 351 Good Test Cases ● ● A good test case has a high probability of finding an error. A good test is not redundant. There is no point in conducting a test that has the same purpose as another test. A good test should be “best of breed”. The test that has the highest likelihood of uncovering a whole class of errors. A good test should be neither too simple nor too complex. © 2003 Ray S. Babcock
CS 351 Basis Path Testing (to next set of slides) © 2003 Ray S. Babcock