• No results found

week 11

N/A
N/A
Protected

Academic year: 2020

Share "week 11"

Copied!
52
0
0

Loading.... (view fulltext now)

Full text

(1)

The University of Lahore

A “W4” Category University

07/10/2020 1

Lecture 31

CHAPTER 4

(2)

The University of Lahore

A “W4” Category University

(3)

The University of Lahore

A “W4” Category University

07/10/2020 3

Use Case Testing

1. A black-box test design technique in which test cases are

designed to execute user scenarios.

2. A use case is a description of a particular use of the system by

an actor (a user of a system). Each use case describes the

interactions the actor has with the system in order to achieve a

specific tasks.

3. Use case are a sequence of steps that describe the interactions

between the actor and the system.

(4)

The University of Lahore

(5)

The University of Lahore

A “W4” Category University

(6)

The University of Lahore

(7)

The University of Lahore

A “W4” Category University

(8)

The University of Lahore

(9)

The University of Lahore

A “W4” Category University

07/10/2020 9

Experienced-Based Testing techniques

Error Guessing

“A test design technique where the experience of the tester is

used to anticipate where defects might be present in the

component or system.”

1. Success of error guessing is very much dependent on the

skills of the testers.

(10)

The University of Lahore

A “W4” Category University

Exploratory Testing

1. It is about exploring, finding out about the software, what it

does, what it doesn’t do, what work and what doesn’t work.

(11)

The University of Lahore

A “W4” Category University

(12)

The University of Lahore

A “W4” Category University

Definition of White-Box Testing

1. Testing based on analysis of internal logic (design,

code, etc.). (But

expected

results still come from

requirements.)

2. Also know as

structural testing.

3. White-box testing concerns techniques for

designing

tests; it is

not

a level of testing.

(13)

The University of Lahore

A “W4” Category University

07/10/2020 13

Structure-Based/White-Box/Glass-Box Testing

Design Techniques

(14)

The University of Lahore

A “W4” Category University

Code Coverage

(15)

The University of Lahore

A “W4” Category University

07/10/2020 15

Types of Coverage

(16)

The University of Lahore

A “W4” Category University

1. The statement coverage is also known as line

coverage or segment coverage.

2. The statement coverage

covers only the true

conditions.

3. Through statement coverage we can identify the

statements executed and where the code is not

executed.

(17)

The University of Lahore

A “W4” Category University

07/10/2020 17

1. Statement Coverage requires

that each statement will have

been executed at least once.

2. Simplest form of logic coverage.

(18)

The University of Lahore

A “W4Category University

Statement Coverage OR Statement Testing

Statement Coverage = Number of statements exercised

Total number of statements X 100

(19)

The University of Lahore

A “W4” Category University

07/10/2020 19

Example 1.1

1 READ A

2 READ B

3 C = A + 2 * B

4 IF C>50 THEN

5 PRINT “LARGE C”

6 ENDIF

TEST SET 1

Test 1_1: A = 2, B = 3 Test 1_2: A = 0, B = 25 Test 1_3: A = 47, B = 1

Test 1_4: A = 20, B = 25 (100% statement coverage)

83% statement coverage 2 READ statements

(20)

The University of Lahore

A “W4” Category University

1. If all statements in a program have been executed by

a set of tests then 100% statement coverage has

been achieved.

(21)

The University of Lahore

A “W4” Category University

07/10/2020 21

Example 1.2

READ X

READ Y

I F X>Y THEN Z = 0

ENDIF

To achieve 100% statement coverage of this code segment just

1 test case

is

required, one which ensures that variable X contains a value that is greater

than the value of variable Y.

Test Case_01:

X = 12 and Y = 10.

(22)

The University of Lahore

A “W4” Category University

Exercise 1.3

How many tests are required to achieve 100%

statement coverage?

1 test would be required to execute all three executable statements.

If our component consists of three lines of code we will execute all with one test case, thus achieving 100% statement coverage. There is only one way we can execute the code -

(23)

The University of Lahore

A “W4” Category University

07/10/2020 23

Exercise 1.4

(24)

The University of Lahore

A “W4” Category University

Exercise 1.5

How many tests are required to achieve 100% statement

coverage?

Therefore we will need three tests that answer 'yes' to 'if fuel tank empty‘

* Fuel tank empty AND petrol engine ( to execute line 3)

* Fuel tank empty AND NOT petrol engine( to execute line 5)

(25)
(26)

The University of Lahore

A “W4” Category University

Exercise 1.6

How many tests are required to achieve 100% statement

coverage?

In this example we have two separate questions that are being asked.

The tests have shown are

* A coffee drinker who wants cream

* A non coffee drinker who doesn`t want cream

Our 2 tests achieve 100% statement coverage, but equally we could have had 2 tests with:

(27)

The University of Lahore

A “W4” Category University

07/10/2020 27

Exercise 1.7

Draw flow diagram for this code:

READ P, Q

IF P+Q > 100 THEN

PRINT 'LARGE'

END IF

IF P>50

(28)

The University of Lahore

A “W4” Category University

Statement Coverage

(29)

The University of Lahore

A “W4” Category University

07/10/2020 29

if (x < y)

{

y = 0;

x = x + 1;

}

else

{

x = y;

}

4

1

2

3

x >= y x < y

x = y y = 0

x = x + 1

Statement coverage:

Cover every

reachable

statement

(30)

The University of Lahore

A “W4” Category University

areTheyPositive(int x, int y) {

if (x >= 0)

print(“x is positive”); else

print(“x is negative”); if (y >= 0)

print(“y is positive”); else

print(“y is negative”); }

There are smaller test cases which will give us statement coverage too:

T2 = {(x=12,y=  5), (x= 1,y=35)}

(31)

The University of Lahore

A “W4” Category University

07/10/2020 31

Exercise 1.10

assignAbsolute(int x) {

if (x < 0) x := -x; z := x; }

Consider this program segment, the test set T = {x=1} will give statement coverage, however not branch coverage

(x < 0)

x := -x

z := x

B0

B1

B2

Test set {x=1} does not execute this edge, hence, it does not give branch coverage true false

(32)
(33)

The University of Lahore

A “W4” Category University

(34)

The University of Lahore

A “W4” Category University

Decision Coverage OR Condition Coverage

Check if each possible branch from a decision

point has been executed

at least once.

(35)

The University of Lahore

A “W4” Category University

07/10/2020 35

Decision Coverage OR Condition Coverage

(36)

The University of Lahore

A “W4” Category University

1. The objective of decision coverage testing is to show all the

decisions within a component have been executed

at least

once.

(37)

The University of Lahore

A “W4” Category University

07/10/2020 37

Exercise 1.1

(x < 0)

x := -x

z := x

B0

B1

B2

Test set {x=1} does not execute this edge, hence, it does not give branch coverage

Test set {x= 1, x=2} gives both statement and branch coverage

(38)

The University of Lahore

A “W4” Category University

Exercise 1.2

if (x < y) { x = 5 * y; x = x + 3; }

else

y = 5; x = x+y;

(x < y)

x = 5 * y

x = x + 3 y = 5

x = x+y

B1 B

2

B0

B3

(39)

The University of Lahore

A “W4” Category University

07/10/2020 39

Exercise 1.3

1 READ A

2 READ B

3 C = A - 2 * B

4 IF C<0 THEN

5 PRINT “C negative”

6 ENDIF

TEST SET 2

(40)

The University of Lahore

A “W4” Category University

Exercise 1.4

(41)

The University of Lahore

A “W4” Category University

07/10/2020 41

SOLUTION

In this example there is one decision, and therefore 2 outcomes.

To achieve 100% decision coverage we could have two tests:

1- Age less than 17(answer 'yes')

2- Age equal to or greater than 17 (answer 'no')

(42)

The University of Lahore

A “W4” Category University

Exercise 1.5

(43)

The University of Lahore

A “W4” Category University

07/10/2020 43

Exercise 1.6

(44)

The University of Lahore

A “W4” Category University

SOLUTION

1 test for statement coverage

3 tests for decision coverage

SO you may think that 4 tests may be required to achieve 100% decision coverage ( two for each decision).

This is NOT the case! We can achieve 100% decision coverage with three tests - we need to exercise the 'Yes' outcome from the first decision ( line 1) twice, in order to next

exercise the 'Yes' and then the 'No' outcome from the supplementary question(line 2). We need a further third test to ensure we exercise the 'No' outcome of the first

decision( line 1 ).

(45)

The University of Lahore

A “W4” Category University

07/10/2020 45

Exercise 1.7

(46)

The University of Lahore

A “W4” Category University

SOLUTION

2 tests for statement coverage

3 tests for decision coverage

We have now introduced a statement that is associated with 'No' outcome of the decision on line 2.

(47)

The University of Lahore

A “W4” Category University

07/10/2020 47

Exercise 1.8

(48)

The University of Lahore

A “W4” Category University

SOLUTION

(49)

The University of Lahore

A “W4” Category University

07/10/2020 49

Exercise 1.9

1.

How many tests are required to achieve 100% statement coverage?

2.

How many tests are required to achieve 100% decision coverage?

(50)

The University of Lahore

A “W4” Category University

SOLUTION

(51)

The University of Lahore

A “W4” Category University

07/10/2020 51

Exercise 1.10

Read P Read Q

IF P+Q > 100 THEN Print “Large”

ENDIF

(52)

The University of Lahore

A “W4” Category University

Path Coverage

References

Related documents

Vasopressin vs Noradrenaline as Initial therapy in Septic Shock (VANISH): a randomised controlled trial. A double-blind parallel group factorial (2x2) randomised controlled trial

In contrast to the measured contact angles on quartz, the contact angle for OTAC solutions on calcite remained unchanged for all surfactant concentrations, whereas the general trend

We may have time to do some final birding along the eastern slopes of Table Mountain before you catch your flight to Durban to join our Subtropical South Africa tour or

The current study investigates basic, relational concept development, as measured by the Boehm Test of Basic Concepts 3 rd Edition – Preschool Version (BTBC3-P), in 51 preschool aged

cizellikle Eski Trirkge ddnemine iligkin yaziar yer ahr. Derginin tiikenen eski ciltlerinin trpkrbasrmr da yaprlmrgtrr. Esas olarak Fin-Ugor halklan iizerine yaziaru

Medicare will not reimburse for Fluorescence In Situ Hybridization (FISH) testing if the patient is being screened for an initial diagnosis of bladder cancer. ICD-9 Codes That

To claim benefits, your beneficiary who is entitled to benefits in the case of your death (or you, in the case of an accelerated benefit), the claimant must contact the Baker