code testing

18
CODE TESTING Principles and Alternatives

Upload: whoopi-clayton

Post on 31-Dec-2015

42 views

Category:

Documents


0 download

DESCRIPTION

CODE TESTING. Principles and Alternatives. Testing - Basics. goal - find errors focus is the source code (executable system) test team wants to achieve an appropriate level of confidence in the product style - run test-cases input: specification and source code - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CODE TESTING

1

CODE TESTING

Principles and Alternatives

Page 2: CODE TESTING

2

Testing - Basics• goal - find errors

– focus is the source code (executable system)– test team wants to achieve an appropriate level

of confidence in the product• style - run test-cases

– input: specification and source code– action: derive test-cases & evaluate results– have enough test-cases been executed?

Page 3: CODE TESTING

3

How “complete” is Testing?

• If testing includes all possible input combinations, it is equivalent to a proof.

• In all other cases, testing establishes only a measure of confidence, a belief, that the systems works according to specification and within quality parameters.

Page 4: CODE TESTING

4

The Art of Testing

• Find a good set of test-cases– cover all aspects of the system– derive test-cases in a structured way

• Know when to stop testing– trade-off between completeness & cost– “measure” relative completeness

Page 5: CODE TESTING

5

When to Stop

• “completeness”:– You have established test-cases which

cover all aspects in sufficient quantity– You have executed all test-cases and

achieved valid results• “test the test”

– e.g. Monte Carlo method

Page 6: CODE TESTING

6

Test-Cases - Basics

• test-cases are derived during all phases of the development cycle

• determine expected results before running a test-case

• never throw away test-cases & results• look for errors where you found errors

before• allocate time and money

Page 7: CODE TESTING

7

Types of Test-Cases

• derive test-cases for– valid, expected inputs– invalid unexpected inputs (garbage)– test, if the system does less than

specified– test, if the system does more than

specified

Page 8: CODE TESTING

8

Two Major Stages of Testing

• module (unit) testing

• system & integration testing

Page 9: CODE TESTING

9

Module Testing

• part of the implementation phase• establish confidence (correctness) in single,

isolated module• test module’s functionality• test module’s interface from the perspective of

the module (from the internal perspective)• Two major forms:

– black box & white box testing

Page 10: CODE TESTING

10

Integration Testing

• major task of the testing phase• establish confidence (correctness) in the

complete, assembled system• test the system structure (design)• focus on control, communication, interfaces,

performance (other system qualities)• use of stubs, test-beds, data generators

Page 11: CODE TESTING

11

0

1 2 3

1.1 1.2 1.3 2.1 2.2 3.1 3.2

crt db prt crt

IntegrationTesting

Page 12: CODE TESTING

12

Black Box Testing - The Concept

• module level• no knowledge of actual implementation

– “black box”• driven by the module’s external

“appearance”– based on specification & interface

Page 13: CODE TESTING

13

Black Box Testing - Discussion

• advantages:– finds missing functionality– independent from code-size and

complexity (?)– finds some coding errors (by chance)

• constraints:– no systematic search for low level errors– specification errors not found

Page 14: CODE TESTING

14

Black Box Testing - Handling

• partition test-cases into functional groups• follow the suggestions for “types of test-cases”• examine unusual cases

– boundary values– null values– extremes

• generate additional random test-cases

Page 15: CODE TESTING

15

White Box Testing - The Concept

• module level• focus on structure of the actual

implementation (source code)– “white box”

• does not take into account the specification of the module’s external behaviour

Page 16: CODE TESTING

16

White Box Testing - Discussion• advantages:

– finds errors on the code level– typically based on a very systematic

approach, covering the complete internal module structure

• constraints:– does not find missing / additional functionality– does not really check the interface– difficult for large and complex modules

Page 17: CODE TESTING

17

White box and black box testing complement each other.

Always use both forms of module testing for a complete test.

Page 18: CODE TESTING

18

End of Section 4e