Logic is important tool of software developer and tester. In this post I will describe one logical error in if-then-elsif-else branching construct.
Logic is important tool of every tester. One of the first problems related to software testing that I encountered in my work was to understand and properly use if-then-elsif-else branching. I thought that reading about that branching technique from programming text book is enough. But guess what, you need to use logic to properly understand it.
Lets take following gist as example:
We have two variables, destination and returntrip as input variables. Requirement is that back trip doubles the cost, and every planet has different cost. Can you spot logical error in the gist?
In given example, we properly calculated only backtrip to Moon. In if-then-elsif-else branching you must not interchange variables in if and elsif statements because you will make logical error. All variables that are part of business rule must be part of if and elsif statement. So, if you are doing source code inspection of test automation code, if you see in if-then-elsif-else statements different variables or different variable tuples (when business rules takes as input more than one variable), than for sure that code has logical error.
Labels: learn testing, testing tool