+ All Categories
Home > Documents > Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used...

Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used...

Date post: 18-Jan-2018
Category:
Upload: beverley-jenkins
View: 216 times
Download: 0 times
Share this document with a friend
Description:
Hardware Logic Testing Logic has been the primary tool of hardware logic designers. Many test methods developed for hardware logic testing are adapted to software logic testing. Because hardware testing automation is 10 to 15 years ahead of software testing automation. So hardware testing methods and its associated theory is a fertile ground for software testing methods. We can expect the both hardware and software designers meet at a middle ground where Boolean algebra will be a basic to their common language of disclosure.
43
Chapter - 10 LOGIC-BASED TESTING
Transcript
Page 1: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Chapter - 10

LOGIC-BASED TESTING

Page 2: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Programmers and Logic “Logic” is one of the most often used

words In programmers’ vocabularies but one of their least used techniques.

Boolean Algebra is being the simplest form of logic.

Boolean Algebra is to logic as arithmetic is to mathematics.

Page 3: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Hardware Logic Testing Logic has been the primary tool of hardware

logic designers. Many test methods developed for hardware

logic testing are adapted to software logic testing. Because hardware testing automation is 10 to 15 years ahead of software testing automation.

So hardware testing methods and its associated theory is a fertile ground for software testing methods.

We can expect the both hardware and software designers meet at a middle ground where Boolean algebra will be a basic to their common language of disclosure.

Page 4: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Specification Systems and Languages

The trouble with specifications is that they’re hard to express.

Boolean Algebra (Sentential Calculus) is the most basic of all logic systems.

Higher order logic systems are needed and used for formal specifications.

These tools incorporate methods to simplify, transform, and check specifications, and the methods are to a large extent based on Boolean algebra.

Page 5: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Knowledge Based Systems The knowledge based system( also expert system, or

artificial intelligence system) has become the programming construct of choice for many applications that were once considered very difficult.

Knowledge based systems incorporate knowledge from a knowledge domain such as medicine, law or civil engineering into a data base. The data can be queried and interacted to provide solutions to problems in that domain.

Other implementation of knowledge based systems is to incorporate the expert’s knowledge into a set of rules. The user can then provide data and ask questions based on that data.

The processing is done by a program called Inference Engine.

Page 6: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Decision Tables A decision table is a table that

consists of four areas called the condition stub, the condition entry, the action stub and the action entry.

Each column of the table is a rule that specifies the conditions under which the actions named in the action stub will take place.

Page 7: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

An example of a Decision Table

RULE 1

RULE 2

RULE 3

RULE 4

CONDITION 1CONDITION 2CONDITION 3CONDITION 4

YESYESNONO

YESI

YESYES

NONONONO

NOII

YESACTION 1ACTION 2ACTION 3

YESNONO

YESNONO

NOYESNO

NONOYES

Page 8: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

The condition stub is a list of names of conditions. A rule specifies whether a condition should or

should not be met for the rule to be satisfied. “yes” means that the conditions must be met, and “No” means that conditions must not be met, and “I” means that the conditions plays no part in the rule, or it is immaterial to the rule.

The action stub names the actions the routine will take or initiate if the rule is satisfied.

If the action entry is “YES” , the action will take place; if “NO” , the action will not take place.

Some of the rules are not specified by the decision table for which a default action to be taken are called Default Rules.

Page 9: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Decision Table Processors Decision tables can be automatically

translated into code and as such are a higher order language.

The decision table translator checks the source decision table for consistency and completeness and fills in any required default rules.

Decision tables as a source language have the virtue of clarity, direct correspondence to specifications, and maintainability.

Page 10: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Decision tables as a Basis for Test Case Design

If a specification is given as a decision table, it follows that decision tables should be used for test case design.

If a program’s logic is implemented as a decision table, decision table should also be used as a basis for test design.

It is not always possible or desirable to implement the program as a decision table because the program’s logical behavior is only part of its behavior. The program interfaces with other programs, there are restrictions or the decision table language may not have needed features.

The use of a decision table model to design tests is warranted when:

The specification is given as a decision table or can be easily converted into one.

The order in which the predicates are to be evaluated does not affect interpretation of the rules or the resulting action.

Once a rule is satisfied and an action is selected, no other rule need be examined.

If several actions can result from satisfying rule, the order in which the actions are executed doesn’t matter.

Page 11: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Expansion of Immaterial Cases

Improperly specified immaterial entries (I) cause most decision-table contradictions.

If a condition’s truth value is immaterial in a rule, satisfying the rule doesnot depend on the condition. It doesn’t mean that the case is impossible.

For example, Rule 1: “ if the persons are male and over 30, then

they shall receive a 15% raise” Rule 2: “but if the persons are female, then they shall

receive a 10% raise.” The above rules state that age is material for a male’s

raise, but immaterial for determining a female’s raise.

Page 12: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Expansion of Immaterial Cases

Rule 2.1

Rule 2.2

Rule 4.1

Rule 4.2

Rule 4.3

Rule 4.4

CONDITION1

CONDITION2

CONDITION3

CONDITION4

YESYESYESYES

YESNO YESYES

NOYESYESYES

NOYESNO

YES

NONONO

YES

NONOYESYES

Page 13: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

The expansion of an Inconsistent Specification

Rule 1

Rule 2

Condition 1Condition 2Condition 3Condition 4

YesIYesNo

YesNoINo

Action 1Action 2

YesNo

Noyes

Rule 1.1

Rule 1.2

Rule 2.1

Rule 2.2

YesYesYesNo

YesNoYesNo

YesNoYesNo

YesNoNoNo

YesNo

YesNo

NoYes

NoYes

Page 14: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Test Case Design Test case design by decision tables begins

with examining the specification’s consistency and completeness.

This is done by expanding all immaterial cases and checking the expanded tables.

Once the specification have been verified, the objective of the test case is to show that the implementation provides the correct action for all combinations of predicate values.

Page 15: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Decision tables and Structure

Decision tables can also be used to examine a program’s structure.

1

8

9

10

Action 1

Action 3

Action 2

A B

D

D

C

A

A1

B

B1

D

D1

C

C1D

D1

R1

R3

R5

R6

R2

R4

Page 16: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6Condition

ACondition

BCondition

CCondition

D

YesYes

IYes

YesNoII

YesYes

INo

NoI

YesI

NoI

NoYes

NoI

NoNo

Action 1Action 2Action 3

YesNoNo

YesNoNo

NoYesNo

NoYesNo

NoYesNo

NoNo

Yes The decision table corresponding to the previous decision tree

Page 17: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Predicates&Relational Operators

A predicate is implemented as a process whose outcome is a truth functional value.

Predicates are based on relational operators, of which the arithmetic relational operators are most common.

A sample of some other relational operators are: is a member of…….,is a subset of……..,is a substring of………, is above……, is below………..

Page 18: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Case statements and Multivalued Logic

Predicates need not be restricted to binary truth values (TRUE/FALSE). There are multiway predicates, of which FORTRAN three-way IF is the most problematic and the case statement the most useful.

Page 19: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

What goes Wrong with Predicates?

Several things can go wrong with predicates, especially if the predicate has to interpreted in order to express it as a predicate over input values. The wrong relational operator is used. The predicate expression of a compound

predicate is incorrect. The wrong operands are used The processing leading to the predicate is

faulty.

Page 20: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Boolean Algebra Steps taken to get the predicate expression

of a path: Label each decision with an uppercase

letter that represents the truth value of the predicate. The YES/TRUE branch is labeled with a letter and the NO/FALSE branch with the same letter over scored.

The truth value of a path is the product of the individual labels.

If two or more paths merge at a node, the fact is expressed by use of a plus sign (+) which means “OR”.

Page 21: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

The Rules of Boolean Algebra

Boolean Algebra has three operators: x – meaning AND. Also called multiplication.

A statement such s AB means “A and B both are true”. This symbol is usually left out as ordinary Algebra.

+ - meaning OR. “A+B” means either A is true or B is true or both.

A1 meaning NOT. Also negation or complementation. This is read as either not A or A bar.

Page 22: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Laws of Boolean Algebra A+A=A A1+A1= A1

A+1=1 A+0=A A+B=B+A A+A1=1 AA=A A1A1=A1

AX1=A AX0=0 AB=BA

AA1=0 (A1)1=A 01=1 11=0 (A+B)1=A1B1

(AB)1=A1+B1

A(B+C)=AB+AC (AB)C=A(BC) (A+B)+C=A+(B+C) A+A1B=A+B1

A+AB=A

Page 23: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

KV-Charts The Boolean algebraic expressions are used

to determine which cases are interesting and which combination of predicate values should be used to reach which node.

If you had deal with expressions in four or five or six variables, you could get bogged down in the algebra and make as many errors in the designing test cases as there are bug in the routine you’re tesing.

The karnaugh – Veitch chart reduces boolean algebraic manipulations to graphical trivia.

Page 24: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

One Variable Map

0 0A

0 10 The function is never

true

0 10 1

A The function is true when A is true

1 00 1

A1 The function is true when A is false

1 10 1

1 The function is always true

Page 25: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Two Variable Map

Page 26: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Representation of Functions in the Map

Page 27: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Three variable Map

Page 28: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Three variable map-example

Page 29: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 30: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 31: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 32: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Four variable map-example

Page 33: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Four variable map-example

Page 34: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 35: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 36: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Five variable map-example

Page 37: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 38: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 39: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.
Page 40: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

Example Use a Karnaugh map to minimizeF(A,B,C,D)=AB’C’D’+A’B’C’D’+ABC’D+A’BCD

+ABD+B’CD’+A’B Some of the terms in the above sum of

products form does not contain all the variables.

F(A,B,C,D)=AB’C’D’+A’B’C’D’+ABC’D+A’BCD+ABD+B’CD’+A’B

Multiply those terms with the missing variables in (X+X1) form.

Page 41: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

F(A,B,C,D)=AB’C’D’+A’B’C’D’+ABC’D+A’BCD+ABD+B’CD’+A’B

ABD=ABD(C+C’)=ABCD+ABC’D B’CD’=B’CD’(A+A’)=AB’CD’ +A’B’CD’ A’B= A’B(C+C’)(D+D’) =(A’BC+A’BC’)(D+D’)

=A’BCD+A’BCD’+ A’BC’D+A’BC’D’

Finally, the function can be written as

F(A,B,C,D)=AB’C’D’+A’B’C’D’+ABC’D+A’BCD+ABCD+ABC’D+AB’CD’+A’B’CD’+A’BCD+A’BCD’+

A’BC’D+A’BC’D’=∑(8,0,13,7,15,13,10,2,7,6,5,4) =∑(0,2,4,5,6,7,8,10,13,15)

Page 42: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

F(A,B,C,D)=∑(0,2,4,5,6,7,8,10,13,15)

Page 43: Chapter - 10 LOGIC-BASED TESTING. Programmers and Logic “Logic” is one of the most often used words In programmers’ vocabularies but one of their least.

1 11 1 1 1

1 11 1

ABCD

0001

11

10

00 01 11 10

F(A,B,C,D)=∑(0,2,4,5,6,7,8,10,13,15)=A1B+BD+B1D1


Recommended