• No results found

Softenr-10

N/A
N/A
Protected

Academic year: 2020

Share "Softenr-10"

Copied!
53
0
0

Loading.... (view fulltext now)

Full text

(1)

Software Engineering

Software Testing

(2)

Chapter-14: Testing

Objectives

— To understand the role of testing in ensuring software quality

—To discuss issues relevant to software testing —To describe the different techniques used for

(3)

The Process of Coding, Testing

and Installation

Coding

Physical design specifications are turned into

working computer code.

Testing

Tests are performed using various strategies.

Testing can be performed in parallel with

coding.

Installation

The current system is replaced by the new

(4)

4

Validation & Verification

Validation

“Are we building the product right?”

Ensure software meets customer’s needs

Verification

“Are we building the right product?”

(5)
(6)

6

Why We Need Software Testing?

Reveal faults/failures/errorsLocate faults/failures/errorsShow system correctness

Improved confidence that system performs as specified (verification)

Improved confidence that system performs as desired (validation)

(7)

Importance of Testing

Critical Element of Software Quality AssuranceWell-planned and thorough testing are

important in reducing the high cost of software failure

Can take up to 40% of development effort

In systems that require high reliability, testing

(8)

8

Who Should Test The Software?

Developer (individual units)

Independent test group (ITG)

removes conflict of interest

(9)

User Acceptance Testing

Actual users test a completed information

system.

End result is the users’ final acceptance of the

system.

Alpha testing: use simulated data

Beta testing: use real data in real user

(10)

Test Cases

Test case: a scenario of transactions,

queries or navigation paths

Can represent either:

– Typical system use

Critical system use

Abnormal system use

Test cases and results should be thoroughly

(11)

Test Cases (cont)

Test case : unit of testing activityTest cases have 3 parts

:-– Goal

Aspect of the system being tested

Input and system state

• Data provided to the system under stated condition

Expected behavior

(12)
(13)

Unit testing

Unit testing is the process of testing individual

components in isolation.

It is a defect testing process.Units may be:

Individual functions or methods within an object Object classes with several attributes and methods Composite components with defined interfaces

(14)

Manual Testing Techniques

Inspection

– A testing technique in which participants examine program code for predictable language-specific errors • Walkthrough

A peer group review of any product created during

the systems development process; also called a structured walkthrough

• Desk Checking

A testing technique in which the program code is

(15)

White Box Testing

Derived from knowledge of program’s

structure & implementation

Structural testing - analyse code & use

knowledge of the structure of a component to derive test data

Logical paths are tested by providing test

(16)

18

White Box Testing

(Continued)

Thorough white box testing would lead to

“100 percent correct programs”

Exhaustive testing are impractical - too many

tests!

A limited number of logical paths can be

selected and exercised

Important data structures can be probed for

(17)

White Box Test Cases

Guarantee that all independent paths 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

Exercise internal data structures to ensure

(18)

Decision Coverage

Decision (Branch) Coverage Method

Causes every decision (if, switch, while, etc.) in the

program to be made both ways (or every possible way for switch)

System: Design a test case to exercise each decision in

the program each way (true / false)

Completion criterion: A test case for each side of each

decision

(19)
(20)

Condition Coverage

Condition Coverage Method

Like decision coverage, but causes every condition expression to be

exercised both ways (true / false)

A condition is any true / false subexpression in a decision

– Example:

if (( x == 1 || y > 2) && z < 3)

Requires separate condition coverage tests for each of:

x == 1 true / falsey > 2 true / falsez < 3 true / false

More effective than simple decision coverage since exercises the

(21)

Loop Coverage Method

Most programs do their real work in do, while and for loops

This method makes tests to exercise each loop in the program in four different states execute body zero times (do not enter loop)

execute body once (i.e., do not repeat)execute body twice (i.e., repeat once)execute body many times

Usually used as an enhancement of a statement, block, decision or condition coverage

method

System: Devise test cases to exercise each loop with zero, one, two and many

repetitions

(22)
(23)

Loop Coverage Method

if there is an upper bound, n, on the number of times the loop body can be executed, then the following cases should also be applied.

Design a test in which the loop body is executed exactly n-1

times.

Design a test in which the loop body is executed

exactly n times.

Try to design a test causing the loop body to be executed

(24)

Loop Coverage Method

Apply the following guidelines to ensure that each loop is tested at its boundaries (that is, with both minimal and maximal numbers of iterations of the loop body) while using a number of tests that is only linear in the number of loops:

•Conduct the ``simple loop tests'' for the innermost loop (which is a simple loop), while keeping the number of iterations of the outer loops at their minimal

nonzero values.

•Work outward, conducting tests (as described above) for each loop, while holding the number of iterations of outer loops at the minimal nonzero values possible (that is, the minimal values that can be used when the inner loop body is to be executed the desired number of times), and holding the number of

(25)

Execution Paths

An execution path is a sequence of executed

statements starting at the entry to the unit (usually the first statement) and ending at the exit from the unit (usually the last statement)

Two paths are independent if there is at least one

statement on one path which is not executed on the other

Path analysis (also know as cyclomatic complexity

(26)

28

Flow Graph Notation

(27)

Converting Code to Graph

if expression1 then

statement2

else

statement3 end if

statement4

switch expr1 case 1:

statement2 case 2:

statm3 case 3: statm4 end switch statm5 (a) (b) do statement1

CODE FLOWCHART GRAPH

T expr1 F ?

statm4

statm2 statm3

2

1 expr1 3 ? statm5 statm3 statm2 statm4 n1 n2 n3 n4 n1 n2 n4 n5 n3 statm1 n1

For a strongly connected graph: Create a virtual edge

(28)

Cyclomatic Complexity

Region, R= 6

Number of Nodes = 13 Number of edges = 17

(29)

Cyclomatic Complexity

Cyclomatic Complexity for a flow graph is computed in one of three ways: • The numbers of regions of the flow graph correspond to the Cyclomatic

complexity.

• Cyclomatic complexity, V(G), for a flow graph G is defined as

V(G) = E – N + 2

where E is the number of flow graph edges and N is the number of flow graph nodes.

Cyclomatic complexity, V(G), for a graph flow G is also defined as

(30)

Cyclomatic Complexity

Cyclomatic Complexity, V( C) : V( C ) = R = 6;

Or

V(C) = Predicate Nodes + 1 =5+1 =6

Or

(31)
(32)

Execution Paths Analysis

To achieve 100% basis path coverage, you

need to define your basis set. The cyclomatic complexity of this method is four (one plus the number of decisions), so you need to

define four linearly independent paths. To do this, you pick an arbitrary first path as a

(33)

Execution Paths Analysis

Path 1: Any path will do for your baseline, so pick true for the decisions'

outcomes (represented as TTT). This is the first path in your basis set.

Path 2: To find the next basis path, flip the first decision (only) in your baseline, giving you FTT for your desired decision outcomes.

Path 3: You flip the second decision in your baseline path, giving you TFT for your third basis path. In this case, the first baseline decision remains fixed with the true outcome.

Path 4: Finally, you flip the third decision in your baseline path, giving you TTF for your fourth basis path. In this case, the first baseline decision

remains fixed with the true outcome.

(34)

Path Coverage Testing

Advantages

– Covers all basic blocks (does all of basic block testing)

Covers all conditions (does all of decision/condition

testing)

– Does all of both, but with fewer tests!

Automatable (in practice requires automation)

Disadvantages

(35)

if expression1 then

statement2 end if

do

statement3

while expr4

end do

if expression5 then

statement6 end if

statement7

(36)

Solution

n1 n3 n2 n4 n5 n7 n6 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10

if expression1 then

statement2 end if

do

statement3

while expr4

end do

if expression5 then

statement6 end if

statement7

(37)

Discussion on White Box Testing

Advantages

Find errors on code level

Typically based on a very systematic approach, covering

the complete internal module structure

Constraints

Does not find missing or additional functionalityDoes not really check the interface

(38)

40

Black Box Testing

Derived from program specification

Functional testing of a component of a system

Examine behaviour through inputs & the

corresponding outputs

Input is properly accepted, output is correctly

produced

(39)

Black Box Testing

(Continued)

Attempts to find the following errors:

Incorrect or missing functionsInterface errors

Errors in data structures or external database

access

Performance errors

(40)

Types

Types of Black Box Testing

There are many types of Black Box Testing but following are the prominent ones

-Functional testing - This black box testing type is related to functional requirements of a system; it is done by software testers.

Non-functional testing - This type of black box testing is not related to testing of a specific functionality , but non-functional requirements such as performance, scalability, usability.

(41)

Equivalence Partitioning

Divide input domain into classes of data

Based on an evaluation of equivalence classes for an input condition

Guidelines to define equivalence classes

Range input : One valid and two invalid equivalenceSpecific value : One valid and two invalid equivalence

(42)

44

Example – Data for Automated Banking Application

The use can access the bank using his personal computer, provide a six digit password, and follow with a series of typed commands that trigger various banking function. During the log on sequence the software supplied for the banking application accepts data in the form:

area code – blank or 3 digit numbers

prefix – 3 digit numbers, nor beginning with 0 or 1 suffix – 4 digit numbers

password – 6 digits alphanumeric strings commands – “check”, “deposit”, “bill pay” etc

Input condition

area code : Input condition : Boolean – area code may or may not present Input condition : Range – 200 – 999 with specific exception prefix : Input condition : Range – specified value > 200 with no 0 digits suffix : Input condition : Value – 4 digit length

password : Input condition : Boolean – password may or may not present Input condition : Value – six character string

(43)
(44)

46

Boundary Value Analysis

Complement equivalence partitioningTest both sides of each boundary

Look at output boundaries for test cases

Test min, min-1, max, max+1, typical valuesExample : 1 <= x <=100

(45)
(46)

48

Comparison Testing

Used only in situations in which the reliability of

software is absolutely critical (e.g., human-rated systems)

Separate software engineering teams develop

independent versions of an application using the same specification

Each version can be tested with the same test data to

ensure that all provide identical output

Then all versions are executed in parallel with

(47)

Orthogonal Array Testing

Used when the number of input parameters

is small and the values that each of the parameters may take are clearly bounded

X Y

Z

X Y

(48)

50

Discussion on Black Box Testing

Advantages

Find missing functionality

Independent from code size and functionalityFind some coding errors

Constraints

(49)

Black box testing techniques

Black box testing strategy:

Following are the prominent test strategy amongst the many used in Black box Testing

Equivalence Class Testing: It is used to minimize the number of

possible test cases to an optimum level while maintains reasonable test coverage.

Boundary Value Testing: Boundary value testing is focused on the values at boundaries. This technique determines whether a certain

range of values are acceptable by the system or not. It is very useful in reducing the number of test cases. It is mostly suitable for the systems where input is within certain ranges.

(50)

Summary

We have learned

• To understand the role of testing in ensuring software quality

(51)

References

1- These slides are designed to accompany Software

Engineering: A Practitioner’s Approach, 7/e (McGraw-Hill 2009). Slides copyright 2009 by Roger Pressman.

2- http://www.cs.unc.edu/~stotts/145/cocomo7.gif

3-Software Engineering” by Ian Somerville, Addison-Wesley, 2009

References

Related documents

• After the initialize statement, the condition part of the loop will be executed if the condition becomes true then body of the loop will be executed otherwise the loop will

The aim of this study was to evaluate the current vac- cination status of the HCWs in all of the Departments different from the Department for the Health of Women and Children of one

Constructions of social inclusion which focus upon the individual student and their levels of self-esteem or aspiration carry more psychological values: education is for

c) Regulation 36(3) of the Electricity Regulations 1994 states that for an installation where hand-held equipment, apparatus or appliance is likely to be used, protection

It is an exit-controlled loop statement (i.e., the body of the loop executed first and the test condition is evaluated for repetition of next time).. The body of loop may not

Some of the reported sorbents include clay materials (bentonite, kaolinite), zeolites, siliceous material (silica beads, alunite, perlite), agricultural wastes (bagasse pith,

All of the participants were faculty members, currently working in a higher education setting, teaching adapted physical activity / education courses and, finally, were

between fan-made works and &#34;official&#34; or &#34;canon&#34; media, the intertwining of &#34;amateur&#34; and &#34;professional&#34; modes of cultural production and