software testing iseb foundation certificate course · iseb foundation certificate course. contents...

38
Static Testing 1 Principles 2 Lifecycle 4 Dynamic test techniques 3 Static testing 5 Management 6 Tools Software Testing ISEB Foundation Certificate Course

Upload: others

Post on 11-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Static Testing

1 Principles 2 Lifecycle

4 Dynamic testtechniques

3 Static testing

5 Management 6 Tools

Software Testing ISEB Foundation Certificate Course

Page 2: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Contents

Reviews and the test processTypes of reviewStatic analysis

ISEB Foundation Certificate Course

Static testing

1 2

4 5

3

6

Page 3: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

People techniques

individual:-- deskdesk--checking, datachecking, data--stepping, proofstepping, proof--readingreading

group:-- Reviews (informal & formal): for consensusReviews (informal & formal): for consensus-- Walkthrough: for educationWalkthrough: for education-- Inspection (most formal): to find faultsInspection (most formal): to find faults

Static techniques do not execute codeStatic techniques do not execute code

Page 4: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Benefits of reviews

Development productivity improvement Reduced development timescales Reduced testing time and cost Lifetime cost reductions Reduced fault levels Improved customer relations etc.

Page 5: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews are cost-effective

10 times reduction in faults reaching test, testing cost reduced by 50% to 80%-- Freedman & Freedman & WeinbergWeinberg, Handbook of , Handbook of

Walkthroughs, Inspections & Technical ReviewsWalkthroughs, Inspections & Technical Reviews reduce faults by a factor of 10

-- YourdonYourdon, Structured Walkthroughs, Structured Walkthroughs 25% reduction in schedules, remove 80% -

95% of faults at each stage, 28 times reduction in maintenance cost, many others-- Gilb Gilb & Graham, Software Inspection& Graham, Software Inspection

Page 6: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

What can be Inspected?

policy, strategy, business plans, marketing or advertising material, contracts

system requirements, feasibility studies, acceptance test plans

test plans, test designs, test cases, test results

system designs, logical & physical software code user manuals, procedures, training material

Anything written downcan be Inspected

Anything written downcan be Inspected

Page 7: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

What can be reviewed?

anything which could be Inspected-- i.e. anything written downi.e. anything written down

plans, visions, “big picture”, strategic directions, ideas

project progress-- work completed to schedule, etc.work completed to schedule, etc.

“Should we develop this” marketing options

Page 8: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

What to review / Inspect?

Tests

Tests

Tests

Tests

RequirementsRequirements

DesignDesign

CodeCode

FunctionsFunctions

Integration TIntegration T

Unit TestUnit Test

Accept. TestAccept. Test

System TestSystem Test

Page 9: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Costs of reviews

Rough guide: 5%-15% of development effort-- half day a week is 10%half day a week is 10%

Effort required for reviews-- planning (by leader / moderator)planning (by leader / moderator)-- preparation / selfpreparation / self--study checkingstudy checking-- meetingmeeting-- fixing / editing / followfixing / editing / follow--upup-- recording & analysis of statistics / metricsrecording & analysis of statistics / metrics-- process improvement (should!)process improvement (should!)

Page 10: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Contents

Reviews and the test processTypes of reviewStatic analysis

ISEB Foundation Certificate Course

Static testing

1 2

4 5

3

6

Page 11: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Types of review of documentsInformal Review undocumented

•• widely viewed as useful and cheap (but no one can widely viewed as useful and cheap (but no one can prove it!) A helpful first step for chaotic prove it!) A helpful first step for chaotic organisations.organisations.

Technical Review: (or peer review)•• includes peer and technical experts, no includes peer and technical experts, no

management participation. Normally documented, management participation. Normally documented, faultfault--finding. Can be rather subjective.finding. Can be rather subjective.

Decision-making Review:•• group discusses document and makes a decision group discusses document and makes a decision

about the content, e.g. how something should be about the content, e.g. how something should be done, go or nodone, go or no--go decision, or technical commentsgo decision, or technical comments

Page 12: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Types of review of documentsWalkthrough

•• author guides the group through a document and author guides the group through a document and his or her thought processes, so all understand the his or her thought processes, so all understand the same thing, consensus on changes to makesame thing, consensus on changes to make

Inspection:•• formal individual and group checking, using sources formal individual and group checking, using sources

and standards, according to generic and specific and standards, according to generic and specific rules and checklists, using entry and exit criteria, rules and checklists, using entry and exit criteria, Leader must be trained & certified, metrics requiredLeader must be trained & certified, metrics required

Page 13: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews in general 1

Objectives / goals-- validation & verification against specifications & validation & verification against specifications &

standardsstandards-- achieve consensus (excluding Inspection)achieve consensus (excluding Inspection)-- process improvement (ideal, included in Inspection)process improvement (ideal, included in Inspection)

Page 14: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews in general 2

Activities-- planningplanning-- overview / overview / kickoff kickoff meeting (Inspection)meeting (Inspection)-- preparation / individual checkingpreparation / individual checking-- review meeting (not always)review meeting (not always)-- followfollow--up (for some types)up (for some types)-- metrics recording & analysis (Inspections and metrics recording & analysis (Inspections and

sometimes reviews)sometimes reviews)

Page 15: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews in general 3

Roles and responsibilities-- Leader / moderator Leader / moderator -- plans the review / Inspection, plans the review / Inspection,

chooses participants, helps & encourages, conducts chooses participants, helps & encourages, conducts the meeting, performs followthe meeting, performs follow--up, manages metricsup, manages metrics

-- Author of the document being reviewed / InspectedAuthor of the document being reviewed / Inspected-- Reviewers / Inspectors Reviewers / Inspectors -- specialised faultspecialised fault--finding finding

roles for Inspectionroles for Inspection-- Managers Managers -- excluded from some types of review, excluded from some types of review,

need to plan project time for review / Inspectionneed to plan project time for review / Inspection-- Others: e.g. Inspection/ review CoOthers: e.g. Inspection/ review Co--ordinatorordinator

Page 16: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews in general 4

Deliverables-- Changes (edits) in review productChanges (edits) in review product-- Change requests for source documents (predecessor Change requests for source documents (predecessor

documents to product being reviewed / Inspected)documents to product being reviewed / Inspected)-- Process improvement suggestionsProcess improvement suggestions

•• to the review / Inspection processto the review / Inspection process•• to the development process which produced the to the development process which produced the

product just reviewed / Inspectedproduct just reviewed / Inspected

-- Metrics (Inspection and some types of review)Metrics (Inspection and some types of review)

Page 17: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews in general 5

Pitfalls (they don’t always work!)-- lack of training in the technique (especially lack of training in the technique (especially

Inspection, the most formal)Inspection, the most formal)-- lack of or quality of documentation lack of or quality of documentation -- what is being what is being

reviewed / Inspectedreviewed / Inspected-- Lack of management support Lack of management support -- ““lip servicelip service”” -- want want

them done, but donthem done, but don’’t allow time for them to happen t allow time for them to happen in project schedulesin project schedules

-- Failure to improve processes (gets disheartening just Failure to improve processes (gets disheartening just getting better at finding the same thing over again)getting better at finding the same thing over again)

Page 18: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews vs. InspectionA typical review?Inspection is different• the document to be reviewed is given out in advance• typically dozens of pages to review• instructions are "please review this"• some people have time to look through it and make

comments before the meeting (which is difficult to arrange)

• the meeting often lasts for hours• "I don't like this" • much discussion, some about technical approaches,

some about trivia• don't really know if it was worthwhile, but we keep doing

it

chunk or sample

training, roles

entry criteria to meeting, may not be worth holding

Rule violations, objective, not subjective

no discussion, highly focused, anti-trivia

only do it if value is proven (continually)

not just product, sources

2 max., often much shorter

Page 19: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Inspection is more and better

entry criteria training optimum checking rate prioritising the words standards

process improvement exit criteria quantified estimates of

remaining major faults per page

typical reviewearly Inspection

mature Inspection

effectiveness return on investment

10 - 20% unknown

30 - 40% 6 - 8 hrs / Insp hr

80 - 95% 8 - 30 hrs / Insp hr

Page 20: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

The Inspection ProcessSoftware

DevelopmentStage

.

.

Planning

Kickoff

IndChk Meet Edit

ChangeRequest

Process Improvement

Entry

Next SoftwareDevelopment

Stage

Exit

Page 21: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

At first glance ..

Here’s a document: review this (or Inspect it)

Page 22: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Reviews: time and size determine rate

Time

CheckingRate

Size

2 hrs?

100 pages?

50 pages per hour

CheckingRate

Page 23: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Review “Thoroughness”?

ordinary “review” - finds some faults, one major, fix them,consider the document now corrected and OK

majorminor

minor

Page 24: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Inspection: time and rate determine size

Time

CheckingRate

Size

2 hrs?

Optimum:1 page*per hour

2 pages (at optimum rate)

Size

* 1 page = 300 important words

Page 25: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Inspection Thoroughness

Inspection can find deep-seated faults: • all of that type can be corrected• but needs optimum checking rate

Page 26: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Inspection surprises

Fundamental importance of Rules-- democratically agreed as applyingdemocratically agreed as applying-- define major issues / faultsdefine major issues / faults

Slow checking rates Strict entry & exit criteria Fast logging rates Amount of responsibility given to author

Page 27: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Contents

Reviews and the test processTypes of reviewStatic analysis

ISEB Foundation Certificate Course

Static testing

1 2

4 5

3

6

Page 28: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

What can static analysis do?

A form of automated testing-- check for violations of standardscheck for violations of standards-- check for things which may be a faultcheck for things which may be a fault

Descended from compiler technology-- a compiler statically analyses code, and a compiler statically analyses code, and ““knowsknows”” a a

lot about it, e.g. variable usage; finds syntax faultslot about it, e.g. variable usage; finds syntax faults-- static analysis tools extend this knowledgestatic analysis tools extend this knowledge-- can find unreachable code, undeclared variables, can find unreachable code, undeclared variables,

parameter type parameter type mismis--matches, uncalled functions & matches, uncalled functions & procedures, array bound violations, etc.procedures, array bound violations, etc.

Remember: static techniques do

not executethe code

Remember: static techniques do

not executethe code

Page 29: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Data flow analysis

This is the study of program variables-- variable defined* where a value is stored into itvariable defined* where a value is stored into it-- variable used where the stored value is accessedvariable used where the stored value is accessed-- variable is undefined before it is defined or when it variable is undefined before it is defined or when it

goes out of scopegoes out of scope

*defined should not be confused with declared

x = y + zIF a > b THEN read(S)

x is defined, y and z are used

a and b are used, S is defined

Page 30: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Data flow analysis faults

n := 0read (x)n := 1while x > y do

beginread (y)write( n*y)x := x - n

end

Data flow anomaly: n isre-defined without being used

Data flow fault: y is usedbefore it has been defined(first time around the loop)

Page 31: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Control flow analysis

Highlights:-- nodes not accessible from start nodenodes not accessible from start node-- infinite loopsinfinite loops-- multiple entry to loopsmultiple entry to loops-- whether code is well structured, i.e. reduciblewhether code is well structured, i.e. reducible-- whether code conforms to a flowchart grammarwhether code conforms to a flowchart grammar-- any jumps to undefined labelsany jumps to undefined labels-- any labels not jumped toany labels not jumped to-- cyclomatic complexity and other metricscyclomatic complexity and other metrics

Page 32: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Unreachable code example

Macro definitions (different for different platforms the code runs on)

Buffsize: 1000Mailboxmax: 1000IF Buffsize < Mailboxmax THEN

Error-ExitENDIF

Static Analysis finds the THEN clause unreachable, so will flag a fault

Page 33: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Cyclomatic complexity

cyclomatic complexity is a measure of the complexity of a flow graph-- (and therefore the code that the flow graph (and therefore the code that the flow graph

represents)represents) the more complex the flow graph, the greater

the measure it can most easily be calculated as:

-- complexity = number of decisions + 1complexity = number of decisions + 1

Page 34: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Which flow graph is most complex?

1

2 3 5

What is the cyclomatic complexity?

Page 35: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Example control flow graph

Result = 0Right = 0DO WHILE more Questions

IF Answer = Correct THENRight = Right + 1

ENDIFEND DOResult = (Right / Questions)IF Result > 60% THEN

Print "pass"ELSE

Print "fail”ENDIF

do

if r=r+1

end

init

if

res

pass

fail

end

Pseudo-code:

Page 36: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Other static metrics

lines of code (LOC) operands & operators (Halstead’s metrics) fan-in & fan-out nesting levels function calls OO metrics: inheritance tree depth, number of

methods, coupling & cohesion

Page 37: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Limitations and advantages

Limitations:-- cannot distinguish "failcannot distinguish "fail--safe" code from safe" code from

programming faults or anomalies (often creates programming faults or anomalies (often creates overload of spurious error messages)overload of spurious error messages)

-- does not execute the code, so not related to does not execute the code, so not related to operating conditionsoperating conditions

Advantages:-- can find faults difficult to "see"can find faults difficult to "see"-- gives objective quality assessment of codegives objective quality assessment of code

Page 38: Software Testing ISEB Foundation Certificate Course · ISEB Foundation Certificate Course. Contents Reviews and the test process Types of review Static analysis ISEB Foundation Certificate

Summary: Key Points

Reviews help to find faults in development and test documentation, and should be applied early

Types of review: informal, walkthrough, technical / peer review, Inspection

Static analysis can find faults and give information about code without executing it

ISEB Foundation Certificate Course

Static testing

1 2

4 5

3

6