Category Archives: Testing

Testing Practice – Find my Bugs

Some of my favorite experiences with learning about testing is is do exercises where there are known bugs.  Somehow, knowing that the bugs exist, and my challenge is to find them, is energizing.  That is probably a good mindset to have when approaching testing in the first place. There are always bugs…

I created a couple of modules, called bugPractice, with intentional bugs for you to practice your skills.  There are likely more bugs than what I purposely put in, maybe you will find those as well.

The first module is a classic testing interview question, test a palindrome checker.  The function is called is_palindrome and it takes a single string.  It returns True if that string is a palindrome. Otherwise, it returns False.    I put in 5 bugs. If you find all 5, congratulations. If you find more, well, shame on me.  Here is the happy path execution for is_palindrome:

Transcript of happy path execution of is_palindrome()

Transcript of happy path execution of is_palindrome()

The second module is an implementation of a very simple stack data structure.  A stack simulates a stack in the real world, you can add items on top of the stack (push action), or pull items off the top of the stack (a pop).  Here is the transcript for the stack happy path:

Transcript of happy path execution for a stack class.

Transcript of happy path execution for a stack class.

These use Python, my favorite language.  If you need to brush up on your Python, I recommend a couple of resources. First, a software testing class from Udacity uses Python to teach testing fundamentals.  Second, Codecedemy’s class on Python teaches the fundementals of the language.

The most simple way to get started, download the archive, unzip it, then invoke Python interactive from that folder and follow the transcripts above to get started.

Testers Adding Value to Unit Tests

Development practices like Test-Driven Development can lead to high levels of Unit Test coverage. Sometimes, the team reaches 100% statement coverage.  How can testers add value when the code is “fully covered”?

Example of a project with 100% Unit Test Coverage

Example of a project with 100% Unit Test Coverage

I provide a few examples in this Sticky Minds article:

Review unit tests for missing cases. Just because the code is fully executed doesn’t mean all of the cases are used which might cause the code to fail.

Review unit tests against the product requirements. The unit tests will check that the code works as the developer intended. Sometimes, you can verify that the functionality meets the requirements.

Review the unit tests themselves. Having 100% coverage for unit tests means that the code was executed during a test, not that the tests are good, or even test anything.  Check that the assertions are valid and useful.

Review Exception Handling.  Unit testing is a good way to test the exception handling because the developer has full control of the mocked environment and can simulate the exceptions. These exceptions are difficult to inject in other types of testing, so making sure the unit tests do a good job is important.

Other ideas? Great, please check out the article and leave a comment either here or there.


Testing Pi day, which is more accurate?

In the US, today is Pi day.  March 14, or as we write it with numbers 3.14.  Happy Pi day everyone!

However, in Europe, they tend to write out dates starting with the day, then the month.  So, today is 14.3 over there.  No-where near Pi.  Instead, the closest to Pi day in Europe would be 22/7 (July 22nd), where 22/7 is a common approximation of Pi.

Which is more accurate?

Testing both approximations is pretty easy with Wolfram Alpha. The error in the approximation is determined by taking the absolute value of the difference between Pi and the approximation. So, the following screen shows the result, asking if the error in the US version is greater than the European version of Pi day:

Comparing the US version of Pi day (3.14) to the European version (22/7) with Wolfram Alpha

Comparing the US version of Pi day (3.14) to the European version (22/7) with Wolfram Alpha

Europe wins this time. 22/7 is a better approximation than 3.14.

A story of exploratory testing – 30 bugs

Me: “This week, we ran 250 test cases.  245 passed and 5 failed.”

Flip the slide.

Me: “Here is our bug find/fix graph. This week, we found 30 bugs and fixed 42. This is the first week where fixes outnumbered finds.”

VP: “Wait, go back one slide.  How come you only had 5 tests fail, but found 30 bugs?”

30 bugs?

On this project, we created test cases based on the written requirements, and could show traceability from requirements down to test results.  These test cases were intended to show that we met the customer’s requirements – and the customers had full access to this data.

In addition to the official test cases, we also ran many exploratory tests. The testers spent time experimenting, not following a direct script.  In terms of finding bugs, this exploratory approach was much more productive than following the script.

One reason, the scripts were written from the requirements, the same document that influenced design and code. We should have been surprised if the  prepared test cases found any bugs.  Professional, smart, testers following their nose found many of the issues that would have frustrated customers.

(these events happened a long time ago, on a product where we had an annual release cycle and 3 months of system test – that feels like forever ago)