Sunteți pe pagina 1din 34

CSC207 Lecture 24

Lecture 24
Testing Strategies and Debugging g g gg g

CSC207 Lecture 24

Test Strategies
1. 2. 3. 4. 4

Unit Testing Integration Testing g g Validation Testing System Testing

TEST PLAN

Each Task uses 1 test technique

CSC207 Lecture 24

1.

Unit Testing
Focuses on unit (e.g. object (class) & module) May use static/dynamic testing techniques Static e.g. desk checking, compilation Dynamic - white/black box testing

CSC207 Lecture 24

Unit Testing for Objects:


Object (Unit) Object Driver

Object (n/a)

Object (n/a)

Object Stub

Test harness (scaffolding)

CSC207 Lecture 24

What forms the test harness?


:e-Retail Central
2:Check so enir souvenir i info

:Customer C Customer C tt 1:Order

3:Check antique info

4:Issue invoice :Invoice Manager Invoice Manager

:Souvenirs Souvenirs Retail

:Antiques Antiques Retail

TransactionTransaction-based

CSC207 Lecture 24

Another Example:
Register for exam candidate
2:Verify AU reqmts 3:Check attendance

:Candidate Administration 1:Register

:AU system

Use case determines test harness

:Attendance Monitor M it

CSC207 Lecture 24

Examples of Object Drivers:


Driver 1 Object A B.OperationB OperationB Object B

Driver 2 Object Obj t C attribC OperationD D.OperationD DO ti D (attribC) Object D

CSC207 Lecture 24

Driver 3 Object E fileE OperationE OperationF F.OperationF F OperationF (rec-n) Object F

CSC207 Lecture 24

Examples of Object Stubs:


Stub 1 Object A A.OperationA OperationA
table validated

Stub St b 3 Object C p C.OperationC fileC OperationC


Returns record n

Stub 2 Object B B.OperationB attributeB OperationB


Returns attributeB

CSC207 Lecture 24

Unit Testing for g Modules:

DRIVER

COMPILER FLOW ANALYZER

MODULE

WHITE BOX TESTING BLACK BOX TESTING

STUB

STUB

Test harness depends on modules location

CSC207 Lecture 24

Pros & Cons of Unit Testing


ADVANTAGES DISADVANTAGES

Narrows focus of test

Requires test harness

Easier debugging

Function tests late

Parallel test efforts

Requires scheduling

CSC207 Lecture 24

2.

Integration Testing

Non-incremental Incremental

CSC207 Lecture 24

Non-incremental Non incremental (Big-Bang Approach)


Components are first unit tested Assembly of every components at the same time Suitable for small to moderate sized systems

CSC207 Lecture 24

Disadvantages: Di d

Excessive use of test harness Debugging is harder Concentrated use of limited resources No flexibility in scheduling

CSC207 Lecture 24

Incremental Approach I t lA h (OO Systems)


Stimulus Order (use-based) (useRegression tests may be needed Prioritise if necessary Determine bottlenecks if any Use test schedule to synchronise

CSC207 Lecture 24

Example 1:
1:Register

:Candidate Administration

2:Verify AU reqmts

3:Check attendance

:AU system

:Attendance Monitor

CSC207 Lecture 24

Example 2: p
:e-Retail Central 1:Order
2:Check souvenir info

:Customer Customer

3:Check 3 Ch k antique info

4:Issue invoice :Invoice Manager Invoice Manager

:Souvenirs Souvenirs Retail

:Antiques Antiques Retail

CSC207 Lecture 24

Example 3:

:HotelMS

bottleneck

:Guests

:Booking

:Rooms

3:update

2:check status

:Walk-ins

:Tourists
1:enquire 1:block book

CSC207 Lecture 24

Incremental Approach (FO Systems)


Guided by Structure Chart Top-Down (Depth or Breadth) Bottom-Up (Depth, Breadth or Cluster) Sandwich Approach

CSC207 Lecture 24

Top-Down (D th Fi t) T D (Depth-First)

A TOPB C D DOWN

CSC207 Lecture 24

TopTop Down (B dth-First) T -D (Breadth(Breadth Fi t)

A TOPB C D DOWN

CSC207 Lecture 24

BottomBottom-Up (Depth-First) (Depth-

A BOTTOMUP B C D

CSC207 Lecture 24

BottomBottom-Up (Breadth-First) (Breadth-

A BOTTOMUP B C D

CSC207 Lecture 24

BottomBottom-Up (Cluster)

A BOTTOMUP B C D

CSC207 Lecture 24

Sandwich (Breadth-First) (Breadth-

SANDWICH B C D

CSC207 Lecture 24

Sandwich (Depth-First) (Depth-

SANDWICH B C D

CSC207 Lecture 24

3.

Validation Testing
Black box testing SQA checks conformance to SRS h k f t Acceptance tests
alpha

testing: 1 client (bespoke system) beta testing: many clients

CSC207 Lecture 24

4.

System Testing
After installation and commissioning i i i Focus on daily operations Black box testing
e.g. g

stress testing, sensitivity testing g, y g

CSC207 Lecture 24

Debugging D b i
1. 2. 2 3.

Brute force Backtracking Cause Elimination

CSC207 Lecture 24

1.

Brute force

Memory Dumps WRITE or PRINT statements Least efficient (used when all else fails)

CSC207 Lecture 24

2.

Backtracking

Begin at error discovery point Manually trace source code backwards Suitable for small to moderate-sized programs

CSC207 Lecture 24

3.

Cause Elimination
By induction or deduction Devise cause hypothesis cause hypothesis Organise test cases to isolate potential causes Suitable for larger programs or subsystems

CSC207 Lecture 24

Interactive Debugging Environment


Program being debugged

breakpoints, b k i t stepping
Program symbol table

User interaction manager

Execution Controller

Records program fl flow


Trace Package Symbol Value Recorder

Records data contents

CSC207 Lecture 24

Summary

Test Strategy organization of tasks Tasks: unit, integration, validation, system Unit testing: requires test harness Integration for OO systems: stimulus order Integration for FO systems: SC guides order Validation & Sys e Testing a da o System es g

Next lecture Software Maintenance

S-ar putea să vă placă și