Blog

Tester who did not understand if/elsif branching (zagorski software tester)

On April 26, 2015, in Syndicated, by Association for Software Testing
0
credit: commons.wikimedia.org

TLDR
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.

 

Comments are closed.


Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!