Similar documents
SOFTWARE TESTING UNIT-VI Logic Based Testing

This unit gives an in-depth overview of Paths of various flow graphs, their interpretations and application.

1 Version Spaces. CS 478 Homework 1 SOLUTION

Lab 1 - Calculator. K&R All of Chapter 1, 7.4, and Appendix B1.2 Iterative Code Design handout Style Guidelines handout

Lab 1 - Calculator. K&R All of Chapter 1, 7.4, and Appendix B1.2

1 Binary Trees and Adaptive Data Compression

Using the Swiftpage Connect List Manager

Eastern Mediterranean University School of Computing and Technology Information Technology Lecture2 Functions

Using SPLAY Tree s for state-full packet classification

CS1150 Principles of Computer Science Midterm Review

Reporting Requirements Specification

Relius Documents ASP Checklist Entry

CS1150 Principles of Computer Science Loops

Web of Science Institutional authored and cited papers

Data Structure Interview Questions

Scatter Search And Bionomic Algorithms For The Aircraft Landing Problem

Using the Swiftpage Connect List Manager

Lab 4. Name: Checked: Objectives:

COP2800 Homework #3 Assignment Spring 2013

Iteration Part 2. Review: Iteration [Part 1] Flow charts for two loop constructs. Review: Syntax of loops. while continuation_condition : statement1

UML : MODELS, VIEWS, AND DIAGRAMS

MATH PRACTICE EXAM 2 (Sections 2.6, , )

CS1150 Principles of Computer Science Methods

Test Pilot User Guide

Stealing passwords via browser refresh

Higher Maths EF1.2 and RC1.2 Trigonometry - Revision

Please contact technical support if you have questions about the directory that your organization uses for user management.

TRAINING GUIDE. Overview of Lucity Spatial

Two Dimensional Truss

Frequently Asked Questions

Relational Operators, and the If Statement. 9.1 Combined Assignments. Relational Operators (4.1) Last time we discovered combined assignments such as:

Grade 4 Mathematics Item Specification C1 TJ

of Prolog An Overview 1.1 An example program: defining family relations

INSTALLING CCRQINVOICE

Adverse Action Letters

Ascii Art Capstone project in C

User Guide. Document Version: 1.0. Solution Version:

Whitepaper. Migrating External Specs to AutoCAD Plant 3D. Set Up the Required Folder Structure. Migrating External Specs to AutoCAD Plant 3D

C++ Reference Material Programming Style Conventions

Lab 5 Sorting with Linked Lists

Querying Data with Transact SQL

Systems & Operating Systems

Focus University Training Document

PAGE NAMING STRATEGIES

ROCK-POND REPORTING 2.1

Interfacing to MATLAB. You can download the interface developed in this tutorial. It exists as a collection of 3 MATLAB files.

Faculty Textbook Adoption Instructions

Overview of OPC Alarms and Events

High School - Mathematics Related Basic Skill or Concept

Exercises: Plotting Complex Figures Using R

Summary. Server environment: Subversion 1.4.6

UiPath Automation. Walkthrough. Walkthrough Calculate Client Security Hash

UiPath Automation. Walkthrough. Walkthrough Calculate Client Security Hash

You may receive a total of two GSA graduate student grants in your entire academic career, regardless of what program you are currently enrolled in.

Data Miner Platinum. DataMinerPlatinum allows you to build custom reports with advanced queries. Reports > DataMinerPlatinum

Course 10262A: Developing Windows Applications with Microsoft Visual Studio 2010 OVERVIEW

Report Writing Guidelines Writing Support Services

CS1150 Principles of Computer Science Introduction (Part II)

The Mathematics of the Rubik s Cube

Tymberwood Academy. Introduction

Computational Methods of Scientific Programming Fall 2008

Project #1 - Fraction Calculator

Lecture Handout. Database Management System. Overview of Lecture. Vertical Partitioning. Lecture No. 24

1 Getting and Extracting the Upgrader

User Guide. ACE Data Source. OnCommand Workflow Automation (WFA) Abstract PROFESSIONAL SERVICES

Creating Relativity Dynamic Objects

MOS Access 2013 Quick Reference

Creating Relativity Dynamic Objects

In-Class Exercise. Hashing Used in: Hashing Algorithm

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Workflow Exception Routing for edocs

Access 2000 Queries Tips & Techniques

Qualtrics Instructions

Case Metrics Guide. January 11, 2019 Version For the most recent version of this document, visit our documentation website.

Reading and writing data in files

Infrastructure Series

softpanel generic installation and operation instructions for nanobox products

DECISION CONTROL CONSTRUCTS IN JAVA

McGill University School of Computer Science COMP-206. Software Systems. Due: September 29, 2008 on WEB CT at 23:55.

Network Rail ARMS - Asbestos Risk Management System. Training Guide for use of the Import Survey Template

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Getting Started with the Web Designer Suite

Chapter 2 Basic Operations

Power365. Quick Start Guide

UNIT 7 RIGHT ANGLE TRIANGLES

1on1 Sales Manager Tool. User Guide

Copyrights and Trademarks

Due Date: Lab report is due on Mar 6 (PRA 01) or Mar 7 (PRA 02)

Computer Organization and Architecture

Studio One 3.5 Audio Dropout Protection and Low-Latency Monitoring

Cisco Tetration Analytics, Release , Release Notes

Licensing the Core Client Access License (CAL) Suite and Enterprise CAL Suite

Quick Start Guide. Basic Concepts. DemoPad Designer - Quick Start Guide

Users, groups, collections and submissions in DSpace. Contents

Extensible Query Processing in Starburst

University Facilities

1 Getting and Extracting the Upgrader

Cntents 1 Intrductin Kit Cntents Requirements Installatin Gesture Sensr Kit Hardware and Jumper Settings De

Computer Organization and Architecture

LAB 7 (June 29/July 4) Structures, Stream I/O, Self-referential structures (Linked list) in C

Transcription:

Chapter 6: Lgic Based Testing LOGIC BASED TESTING: This unit gives an indepth verview f lgic based testing and its implementatin. At the end f this unit, the student will be able t: Understand the cncept f Lgic based testing. Learn abut Decisin Tables and their applicatin Understand the use f decisin tables in test-case design and knw their limitatins. Understand and interpret KV Charts and knw their limitatins. Learn hw t transfrm specificatins int sentences and map them int KV charts. Understand the imprtance f dnt-care cnditins. OVERVIEW OF LOGIC BASED TESTING: INTRODUCTION: The functinal requirements f many prgrams can be specified by decisin tables, which prvide a useful basis fr prgram and test design. Cnsistency and cmpleteness can be analyzed by using blean algebra, which can als be used as a basis fr test design. Blean algebra is trivialized by using Karnaugh-Veitch charts. "Lgic" is ne f the mst ften used wrds in prgrammers' vcabularies but ne f their least used techniques. Blean algebra is t lgic as arithmetic is t mathematics. Withut it, the tester r prgrammer is cut ff frm many test and design techniques and tls that incrprate thse techniques. Lgic has been, fr several decades, the primary tl f hardware lgic designers. Many test methds develped fr hardware lgic can be adapted t sftware lgic testing. Because hardware testing autmatin is 10 t 15 years ahead f sftware testing autmatin, hardware testing methds and its assciated thery is a fertile grund fr sftware testing methds. As prgramming and test techniques have imprved, the bugs have shifted clser t the prcess frnt end, t requirements and their specificatins. These bugs range frm 8% t 30% f the ttal and because they're first-in and last-ut, they're the cstliest f all. The truble with specificatins is that they're hard t express. Blean algebra (als knwn as the sentential calculus) is the mst basic f all lgic systems. Higher-rder lgic systems are needed and used fr frmal specificatins. Much f lgical analysis can be and is embedded in tls. But these tls incrprate methds t simplify, transfrm, and check specificatins, and the methds are t a large extent based n blean algebra. KWLEDGE BASED SYSTEM: The knwledge-based system (als expert system r artificial intelligence system has becme the prgramming cnstruct f chice fr many applicatins that were nce cnsidered very difficult. Knwledge-based systems incrprate knwledge frm a knwledge dmain such as medicine, law, r civil engineering int a database. The Chapter 6 Page 1

Chapter 6: Lgic Based Testing data can then be queried and interacted with t prvide slutins t prblems in that dmain. One implementatin f knwledge-based systems is t incrprate the expert's knwledge int a set f rules. The user can then prvide data and ask questins based n that data. The user's data is prcessed thrugh the rule base t yield cnclusins (tentative r definite) and requests fr mre data. The prcessing is dne by a prgram called the inference engine. Understanding knwledge-based systems and their validatin prblems requires an understanding f frmal lgic. Decisin tables are extensively used in business data prcessing; Decisin-table preprcessrs as extensins t COBOL are in cmmn use; blean algebra is embedded in the implementatin f these prcessrs. Althugh prgrammed tls are nice t have, mst f the benefits f blean algebra can be reaped by whlly manual means if yu have the right cnceptual tl: the Karnaugh-Veitch diagram is that cnceptual tl. DECISION TABLES: Figure 6.1 is a limited - entry decisin table. It cnsists f fur areas called the cnditin stub, the cnditin entry, the actin stub, and the actin entry. Each clumn f the table is a rule that specifies the cnditins under which the actins named in the actin stub will take place. The cnditin stub is a list f names f cnditins. Figure 6.1: Examples f Decisin Table. A mre general decisin table can be as belw: Chapter 6 Page 2

Chapter 6: Lgic Based Testing Figure 6.2: Anther Examples f Decisin Table. A rule specifies whether a cnditin shuld r shuld nt be met fr the rule t be satisfied. "" means that the cnditin must be met, "" means that the cnditin must nt be met, and "I" means that the cnditin plays n part in the rule, r it is immaterial t that rule. The actin stub names the actins the rutine will take r initiate if the rule is satisfied. If the actin entry is "", the actin will take place; if "", the actin will nt take place. The table in Figure 6.1 can be translated as fllws: Actin 1 will take place if cnditins 1 and 2 are met and if cnditins 3 and 4 are nt met (rule 1) r if cnditins 1, 3, and 4 are met (rule 2). "Cnditin" is anther wrd fr predicate. Decisin-table uses "cnditin" and "satisfied" r "met". Let us use "predicate" and TRUE / FALSE. Nw the abve translatins becme: 1. Actin 1 will be taken if predicates 1 and 2 are true and if predicates 3 and 4 are false (rule 1), r if predicates 1, 3, and 4 are true (rule 2). 2. Actin 2 will be taken if the predicates are all false, (rule 3). 3. Actin 3 will take place if predicate 1 is false and predicate 4 is true (rule 4). In additin t the stated rules, we als need a Default Rule that specifies the default actin t be taken when all ther rules fail. The default rules fr Table in Figure 6.1 is shwn in Figure 6.3 Chapter 6 Page 3

Chapter 6: Lgic Based Testing Figure 6.3: The default rules f Table in Figure 6.1 DECISION-TABLE PROCESSORS: Decisin tables can be autmatically translated int cde and, as such, are a higher-rder language If the rule is satisfied, the crrespnding actin takes place Otherwise, rule 2 is tried. This prcess cntinues until either a satisfied rule results in an actin r n rule is satisfied and the default actin is taken Decisin tables have becme a useful tl in the prgrammers kit, in business data prcessing. DECISION-TABLES AS BASIS FOR TEST CASE DESIGN: 0. The specificatin is given as a decisin table r can be easily cnverted int ne. 1. The rder in which the predicates are evaluated des nt affect interpretatin f the rules r the resulting actin - i.e., an arbitrary permutatin f the predicate rder will nt, r shuld nt, affect which actin takes place. 2. The rder in which the rules are evaluated des nt affect the resulting actin - i.e., an arbitrary permutatin f rules will nt, r shuld nt, affect which actin takes place. 3. Once a rule is satisfied and an actin selected, n ther rule need be examined. 4. If several actins can result frm satisfying a rule, the rder in which the actins are executed desn't matter DECISION-TABLES AND STRUCTURE: Decisin tables can als be used t examine a prgram's structure. Figure 6.4 shws a prgram segment that cnsists f a decisin tree. These decisins, in varius cmbinatins, can lead t actins 1, 2, r 3. Chapter 6 Page 4

Chapter 6: Lgic Based Testing Figure 6.4 : A Sample Prgram If the decisin appears n a path, put in a r as apprpriate. If the decisin des nt appear n the path, put in an I, Rule 1 des nt cntain decisin C, therefre its entries are:,, I,. The crrespnding decisin table is shwn in Table 6.1 CONDITION A CONDITION B CONDITION C CONDITION D ACTION 1 ACTION 2 ACTION 3 RULE 1 RULE 2 RULE 3 RULE 4 RULE 5 RULE 6 I I I I I I I I Table 6.1 : Decisin Table crrespnding t Figure 6.4 As an example, expanding the immaterial cases results as belw: Similalrly, If we expand the immaterial cases fr the abve Table 6.1, it results in Table 6.2 as belw: Chapter 6 Page 5

Chapter 6: Lgic Based Testing CONDITION A CONDITION B CONDITION C CONDITION D R 1 RULE 2 R 3 RULE 4 R 5 R 6 YY YY YN YY YYYY NNNN NNYY YNNY YY YY YN NN NNNN YYNN YYYY NYYN NN NY NN YY NN YN NN NN Table 6.2 : Expansin f Table 6.1 Sixteen cases are represented in Table 6.1, and n case appears twice. Cnsequently, the flwgraph appears t be cmplete and cnsistent. As a first check, befre yu lk fr all sixteen cmbinatins, cunt the number f Y's and N's in each rw. They shuld be equal. We can find the bug that way. ATHER EXAMPLE - A TROUBLE SOME PROGRAM: Cnsider the fllwing specificatin whse putative flwgraph is shwn in Figure 6.5: 1. If cnditin A is met, d prcess A1 n matter what ther actins are taken r what ther cnditins are met. 2. If cnditin B is met, d prcess A2 n matter what ther actins are taken r what ther cnditins are met. 3. If cnditin C is met, d prcess A3 n matter what ther actins are taken r what ther cnditins are met. 4. If nne f the cnditins is met, then d prcesses A1, A2, and A3. 5. When mre than ne prcess is dne, prcess A1 must be dne first, then A2, and then A3. The nly permissible cases are: (A1), (A2), (A3), (A1,A3), (A2,A3) and (A1,A2,A3). Figure 6.5 shws a sample prgram with a bug. Figure 6.5: A Trublesme Prgram Chapter 6 Page 6

Chapter 6: Lgic Based Testing The prgrammer tried t frce all three prcesses t be executed fr the cases but frgt that the B and C predicates wuld be dne again, thereby bypassing prcesses A2 and A3. Table 6.3 shws the cnversin f this flwgraph int a decisin table after expansin. Table 6.3: Decisin Table fr Figure 6.5 PATH EXPRESSIONS: GENERAL: Lgic-based testing is structural testing when it's applied t structure (e.g., cntrl flwgraph f an implementatin); it's functinal testing when it's applied t a specificatin. In lgic-based testing we fcus n the truth values f cntrl flw predicates. A predicate is implemented as a prcess whse utcme is a truth-functinal value. Fr ur purpse, lgic-based testing is restricted t binary predicates. We start by generating path expressins by path tracing as in Unit V, but this time, ur purpse is t cnvert the path expressins int blean algebra, using the predicates' truth values (e.g., A and ) as weights. BOOLEAN ALGEBRA: STEPS: 1. Label each decisin with an uppercase letter that represents the truth value f the predicate. The r TRUE branch is labeled with a letter (say A) and the r FALSE branch with the same letter verscred (say ). 2. The truth value f a path is the prduct f the individual labels. Cncatenatin r prducts mean "AND". Fr example, the straightthrugh path f Figure 6.5, which ges via ndes 3, 6, 7, 8, 10, 11, 12, and 2, has a truth value f ABC. The path via ndes 3, 6, 7, 9 and 2 has a value f. 3. If tw r mre paths merge at a nde, the fact is expressed by use f a plus sign (+) which means "OR". Chapter 6 Page 7

Chapter 6: Lgic Based Testing Figure 6.5 : A Trublesme Prgram Using this cnventin, the truth-functinal values fr several f the ndes can be expressed in terms f segments frm previus ndes. Use the nde name t identify the pint. There are nly tw numbers in blean algebra: zer (0) and ne (1). One means "always true" and zer means "always false". RULES OF BOOLEAN ALGEBRA: Blean algebra has three peratrs: X (AND), + (OR) and (T) X : meaning AND. Als called multiplicatin. A statement such as AB (A X B) means "A and B are bth true". This symbl is usually left ut as in rdinary algebra. + : meaning OR. "A + B" means "either A is true r B is true r bth". meaning T. Als negatin r cmplementatin. This is read as either "nt A" r "A bar". The entire expressin under the bar is negated. The fllwing are the laws f blean algebra: Chapter 6 Page 8

Chapter 6: Lgic Based Testing In all f the abve, a letter can represent a single sentence r an entire blean algebra expressin. Individual letters in a blean algebra expressin are called Literals (e.g. A,B) The prduct f several literals is called a prduct term (e.g., ABC, DE). An arbitrary blean expressin that has been multiplied ut s that it cnsists f the sum f prducts (e.g., ABC + DEF + GH) is said t be in sum-f-prducts frm. The result f simplificatins (using the rules abve) is again in the sum f prduct frm and each prduct term in such a simplified versin is called a prime implicant. Fr example, ABC + AB + DEF reduces by rule 20 t AB + DEF; that is, AB and DEF are prime implicants. The path expressins f Figure 6.5 can nw be simplified by applying the rules. The fllwing are the laws f blean algebra: Chapter 6 Page 9

Chapter 6: Lgic Based Testing Similarly, The deviatin frm the specificatin is nw clear. The functins shuld have been: Lps cmplicate things because we may have t slve a blean equatin t determine what predicate-value cmbinatins lead t where. KV CHARTS: INTRODUCTION: If yu had t deal with expressins in fur, five, r six variables, yu culd get bgged dwn in the algebra and make as many errrs in designing test cases as there are bugs in the rutine yu're testing. Chapter 6 Page 10

Chapter 6: Lgic Based Testing Karnaugh-Veitch chart reduces blean algebraic manipulatins t graphical trivia. Beynd six variables these diagrams get cumbersme and may nt be effective. SINGLE VARIABLE: Figure 6.6 shws all the blean functins f a single variable and their equivalent representatin as a KV chart. Figure 6.6 : KV Charts fr Functins f a Single Variable. The charts shw all pssible truth values that the variable A can have. A "1" means the variable s value is "1" r TRUE. A "0" means that the variable's value is 0 r FALSE. The entry in the bx (0 r 1) specifies whether the functin that the chart represents is true r false fr that value f the variable. We usually d nt explicitly put in 0 entries but specify nly the cnditins under which the functin is true. TWO VARIABLES: Figure 6.7 shws eight f the sixteen pssible functins f tw variables. Chapter 6 Page 11

Chapter 6: Lgic Based Testing Figure 6.7: KV Charts fr Functins f Tw Variables. Each bx crrespnds t the cmbinatin f values f the variables fr the rw and clumn f that bx. A pair may be adjacent either hrizntally r vertically but nt diagnally. Any variable that changes in either the hrizntal r vertical directin des nt appear in the expressin. In the fifth chart, the B variable changes frm 0 t 1 ging dwn the clumn, and because the A variable's value fr the clumn is 1, the chart is equivalent t a simple A. Figure 6.8 shws the remaining eight functins f tw variables. Chapter 6 Page 12

Chapter 6: Lgic Based Testing Figure 6.8: Mre Functins f Tw Variables. The first chart has tw 1's in it, but because they are nt adjacent, each must be taken separately. They are written using a plus sign. It is clear nw why there are sixteen functins f tw variables. Each bx in the KV chart crrespnds t a cmbinatin f the variables' values. That cmbinatin might r might nt be in the functin (i.e., the bx crrespnding t that cmbinatin might have a 1 r 0 entry). Since n variables lead t 2 n cmbinatins f 0 and 1 fr the variables, and each such cmbinatin (bx) can be filled r nt filled, leading t 2 2n ways f ding this. Chapter 6 Page 13

Chapter 6: Lgic Based Testing Cnsequently fr ne variable there are 2 21 = 4 functins, 16 functins f 2 variables, 256 functins f 3 variables, 16,384 functins f 4 variables, and s n. Given tw charts ver the same variables, arranged the same way, their prduct is the term by term prduct, their sum is the term by term sum, and the negatin f a chart is gtten by reversing all the 0 and 1 entries in the chart. THREE VARIABLES: KV charts fr three variables are shwn belw. As befre, each bx represents an elementary term f three variables with a bar appearing r nt appearing accrding t whether the rw-clumn heading fr that bx is 0 r 1. A three-variable chart can have grupings f 1, 2, 4, and 8 bxes. A few examples will illustrate the principles: OR Chapter 6 Page 14

Chapter 6: Lgic Based Testing Chapter 6 Page 15

Chapter 6: Lgic Based Testing Figure 6.8: KV Charts fr Functins f Three Variables. Chapter 6 Page 16