Can you say this is TDD fanboyism?

As you can guess from my previous post I believe that tests are not only a useful tool for writing code, but also a great way to deliver quality to your customer, even when you are the customer itself.

To be clear: I’m not an agile fanboy nor I believe that tests are the holy grail, like some people do.
Is quality itself always so important? If two developers have 2 weeks to build an e-commerce from scratch, you can bet they will not write a single line of test, if they want to deliver the code. In this case quality is not that important, at least not as much as writing quickly.

It’s the old-and-always-true triangle of cost/time/quality where you cannot pick more than 2 factors at the same time. Higher quality requires more time and delivers higher cost. You can guess by yourself what happens when you want a cheap product developed in just a few days.

Code/Time/Quality Triangle

Some triangle configurations seem (maybe only to me) to have sticked over in the programming languages world: your pull request to a ruby gem is usually not accepted if your code isn’t tested, while a lot of javascript libraries are completely left untested.

My rant comes from the fact that lately we started working on a pre-existing web app – developed, as far as I know, prioritizing quality – where the backend had a test coverage of nearly 90%, but no tests were written for the frontend.

Developer, Y U NO TESTS

I asked why, and the frontend developers in charge answered with something like You know, tests are not that useful, You know, writing tests requires a lot of time, You know, we are not so used to this practice, You know, it’s difficult to write tests for every different browser/platform.

NO, I DON’T KNOW. Even if you don’t know how to write tests with selenium, you can always write down your stories as cucumber features so that another dev (like me) can implement the steps’ code. There are also tools to record tests visually (click here, click there, and it will record the test), there are tools to run your integration tests on different browsers (like Sauce Labs), there are tools for everything. It’s only your fault if you’re not writing tests.

I’m not saying there should be a test for each animation, but I would expect at least a test for the navigation flow and the main features. I don’t think you need to test that a modal is showing up with a fade-in effect, but you can easily test that the modal is showing. Even if the fade-in doesn’t work you would have a degradation instead of a critical issue.

When you have this unbalanced scenario, with the backend fully tested and the frontend with no tests at all, then you have a big problem on the backend as well.

Backends and frontends have to communicate. Maybe with a REST API, maybe with a socket, in any case there will be a communication point that is fragile by nature, because shared between the 2 components. Besides testing that the backend is serving data correctly, you also need to check that the frontend is parsing the received data as expected. So at least an integration test should be mandatory to check that the entire chain is working properly.

And in fact, analyzing the tickets opened during the QA, 5 bugs out of 10 were on the frontend while 4 bugs out of 10 were on the frontend-backend interaction.

This problem isn’t related to javascript. I don’t really think it’s related to the programming language you’re using, although projects written in javascript, php, etc. usually have an undeniable lower test coverage. Maybe it’s because the typical developer is notoriously lazy, and writing tests requires a lot of effort. Or maybe it’s because you don’t know how tests could really save your day if you never used them correctly. I’m not sure about the real reason behind this, but as today, with projects more complex than ever before, tests should be mandatory when the triangle is pointing towards quality.

In the end I can say I’m not a fanboy of testing at every cost. But surely I’m a fanboy of the minimum indispensable integration tests that every application should have. Only this way you can ensure no critical issues are present.

Leave a Reply

Please Login to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.