Testing

13
Testing Chapter 23 IB103 Week 12 (part 3)

description

Testing. Chapter 23 IB103 Week 12 (part 3). Verify that a complex (any) program works correctly, that the program meets specifications. The chapter reviews different approaches – to check (verification) and notes deficiencies. Approaches to verification. Black box (functional) - PowerPoint PPT Presentation

Transcript of Testing

Page 1: Testing

Testing

Chapter 23

IB103 Week 12 (part 3)

Page 2: Testing

Verify that a complex (any) program works correctly, that the program meets specifications

The chapter reviews different approaches – to check (verification) and notes deficiencies

Page 3: Testing

Approaches to verification

Black box (functional)White box (structural)Reviews (walkthroughs)Stepping through code with debuggerFormal methods

Page 4: Testing

In Java the classes are a natural size piece to work with

A class at a time (to check/debug)After every class has been tested (unit testing) the complete system is tested (integration or system testing)Example specifications“ input to the program is a series of numbers via a text field, terminated by a negative number. Display the sum.”

Page 5: Testing

After review:

Are the numbers integer or floating point?What is the range and precision?Is the terminating negative number to be included in the sum?

Page 6: Testing

Clarification to the specifications:

Integer numbers to be usedRange from 0 to 10000Button “End of Data” now terminates (so no need to worry about a terminating negative number)

Page 7: Testing

Tests:

Black box – we assume no knowledge of the programs inner workings – we only consider in/output (functional) Select representative data

Key in 8 12 [End of Data] buttonKey in just [End of Data] buttonKey in 8 0 12 [End of Data] button what was expected in each trial?Note discrepanciesUse equivalence partitions, identify common features

Page 8: Testing

White box:

Make use of knowledge of how program works, it’s structureTest all possible paths (with simple data)

Page 9: Testing

Inspections and walkthroughs

Study source code listingsTry to detect bugs (before the compiler does) Have another person (pair of eyes) check your program – sometimes we cannot see forest for the trees. Others can see our errors and we can bring a fresh viewpoint looking at their program

Page 10: Testing

To inspect:

Need specificationsText of source codeSome checks to be made Variables initialized? Loops initialized and terminated? Methods invoked and are passed correct

parameters?

Desk check (play computer) line by lineDoes the method achieve its desired purpose?

Page 11: Testing

Other considerations

Are variable names meaningful?Indentation consistent?Logic clear and correct? Step through the code a line at a time

check the value held by variables (use debugger if possible)

Formal verification – using mathematicsDoes program meet the specifications

Page 12: Testing

Z and VDM languages that check specifications (not commonly used)

1. Write program and verify it meets specifications2. Derive program from specifications be means of transformations (favored more common approach)

Page 13: Testing

Unit testing and integration (system) testing

May use all approaches or combination(black, white – boxes, inspection and debugger, step through)Create a test bed (check each method, display output independent of program)Then if method runs put it into the systemIncremental developmentWrite small piece of code: key it in, compile,run

debug add to program the tested piece,Repeat until program is complete