This website uses cookies for analytics and to improve provided services. By choosing I Accept, you consent to our use of them and other tracking technologies according to our Privacy Policy

When tests fail and how to deal with it

Imagine such a case: you're developing another e-shop. You've got products and a basket. You write some obvious tests:

Scenario: Adding a product to the basket
  Given I have found my lovely product
   When I add the product to the basket
   Then this product should be in the basket

Scenario: Adding the same product to the basket
  Given I have found my lovely product
    And I have already added one product to the basket
   When I add the product to the basket
   Then this product should be in the basket as one item with quantity equal 2

The implementation is done and everything works great. After a successful release, however, you've got a strange bug report - if you alternately add to the basket products A, B and A again, you will have three items with quantity 1 instead of two items - A with quantity 2 and B with quantity 1.

How did that happen? We had 100% tests coverage and all acceptance and unit tests were green!

Unfortunately such cases are inevitable because it's difficult to make 100% tests coverage for every possible case that could happen in regular use. So does this mean that TDD is dead and we shouldn't care about tests if we cannot completely protect ourselves? What should we do in such cases?

The answer could surprise you but… you should just write more specs! You cannot predict every scenario but when a new one arises you can describe it into formal specification and increase complexity awareness and improve regression tests feedback.

So don't worry about the bugs. They will always occur. But as a craftsman you should care that the same bug won't happen again and writing additional specs will always help.

What's the Future of Proptech Development?
10+ Ways to Optimize Your App Development Cost
jitsi illustration Jitsi, a Video Conferencing Alternative to Zoom and Google Hangouts