Arunkumar Khannur's Software Testing Knowledge Center
   
 

9.5 Predicates and Relational Operators


In order to implement requirements, we define process with predicates whose output is truth value TRUE or FALSE. In most of the cases, every predicate can have: Arithmetic Relational Operators: >, >=, =, < , < =, ≠. However it can have some other relational operators as well such as “sub set of”, “member of”, “substring of” etc.

Examples
If predicate is A > X, where A = 5 and X=3 then output of predicate is TRUE.
If predicate is “7 is member of set of even integer values” then output of predicate is FALSE.

From the flow chart shown in Fig. 9.1 A Sample Program Segment, we trace the paths that cause ACTION 1 and ACTION 2. Now we consider each path and start tracing it. If the decision appears on any condition that appears on that path, we put a YES or NO as appropriate. If any condition from the conditions listed in condition stub does not appear on the path, we put in an I. We repeat this exercise for second path, and then third path etc till we will all possible paths. The corresponding decision table is shown in Table. 9.4 The Decision Table Corresponding to Fig. 9.1.

Predicates need not always return binary truth values as output. In programming languages, switch statements; CASE statements; three-way IF statements are multi-valued logic structures. However, in our discussion on logic-based testing, we restrict to binary predicates. If we come across multi-valued predicates then we convert the same into many binary valued predicates.

Possible Mistakes with Predicates

When we wish to express predicate in the form of output over input values, there can be possible implementation mistakes which can be:

Using wrong relational operators. For Example, Instead of using ≥, we may be using >.

Example
In order to represent, Valid Voter for citizens who are 18 years and above, we may make a mistake in predicate by representing it as: “AGE > 18”. Here Citizens whose AGE value is exactly 18 years are treated as invalid voters which is wrong.

There can be possible mistakes of using AND operator instead of OR operator. For example, instead of writing AB, we may write A+B.

Logic based testing is very much useful in finding these bug types. However, logic based testing cannot find bugs like using wrong operands and processing leading to wrong predicate in the path.
 
 
Khannur's Book
Arunkumar Khannur, Software Testing - Techniques and Applications, Published by Pearson Publications, 2011 (ISBN:978-81-317-5836-6; Pages:341 + xxii)
Follow Khannur
         
Khannur's Company
ISQT Process & Consulting Services Pvt. Ltd., Bangalore, INDIA
Khannur's Software Testing Forum
STEP-AUTO Forum
 Contact Khannur
ISQT Process & Consulting Services Pvt. Ltd.
#732, 1st Floor, 12th Main,
3rd Block, Rajajinagar,
Bangalore - 560010, INDIA
Phone: +91 80 23012511
URL: www.isqtinternational.com
Email: khannur@isqtinternational.com
Skype: arun.isqt