Monday, May 9, 2016

Testing the Count Down

We had this announcement where the big boss stated that he would give us 90 days to change. OK, but change what? No satisfying answer was given to us when we asked what exactly they wanted us to change. So we continued doing our jobs as professional as always and I can tell you, we all worked very hard for the success of the company and to make our customers happy. Some of us even got a daily email with a reminder saying "80 days left", "79 days left"...etc. After the 90 days were expired, nothing happened. At least, we didn't notice anything and the emails had stopped.

I have no idea what was the original purpose of this announcement and the following up emails and I doubt that professinoal engineers can be impressed by such statements. Anyhow, this story inspired me for the cartoon, but if you are a software developer or test engineer then you probably draw a relation to a typical situation in software development.

A funny fact in programming is that arrays start at index 0 and not 1 for many popular programming languages (eg. C++,C#, Java, Perl, JavaScript) and the last position in the array is indexed as Array-length minus 1. This fact sometimes causes troubles and confusion and it isn't a rare scenario where developers introduce bugs because of that.

Consider the following piece of code which would cause the program to skip the first element of a list. It starts reading at position 1 (which is actually the second) instead of 0.


The correct code assigns variable i with value zero.

OK, so what? Blackbox testers usally don't look into the code of developers but you can see such patterns if you compare the total number of items in a list with the total number of found items stated in the header of a list. For example, you believe the label "100 items found", but when you count the items you see only 99.

For those who are curious why programmers start counting at 0 and not 1 I have the following explanation. In C, the name of an array is essentially a pointer (reference to a memory location), and so the expression sListElements[i] refers to a memory location i-elements away from the starting element. This means that the index is used as an offset. The first element of the array is exactly contained in the memory location that array sListElements refers (0 elements away), so it should be denoted as sListElements[0].

No comments:

Post a Comment