Recently on Clubhouse – so hot right now – I took a part in discussion about How programming languages influence the way we test software. The room was held in Polish under 🇵🇱 Dev Radio PL label. There were a mix of people with different backgrounds attending — backend developers, frontend developers and mobile ones.
I’m a fullstack developer with set of skills leaning more towards backend. Mobile development is a thing that I’m not familiar with. What I learned from the discussion was, that the tooling is poor and there is poor culture of testing in this environment. This caused that it’s even hard to separate the domain code from the frameworks, which makes testing pretty hard. It’s a costly lesson, but they’re learning from it.
Greatness of the Ruby community
I’m proud that I jumped into Ruby on Rails in between 2008/2009. Rails framework has a wonderful community which encourages testing and the tooling around that is good.
As I wrote earlier, I’m more of backend dev, but few years ago I discovered that writing frontend code with React, sparks joy. I had to learn how to test such apps, yet another skill, different environment, different tooling.
Let’s get back to the Clubhouse thing. One frontend developer said that from his experience, 90% of the frontend apps are not tested. My head exploded. It’s not like every backend app is fully tested and the tests itself are top notch. However, my community strongly believes in tests and I didn’t meet people who openly discouraged writing tests. A lot of arguments were raised, I’ll try to address them.
We don’t have enough time, deadlines are short
To me, tests are integral part of the code I ship. Yes, they take time, they cost money. Isn’t it the same with the bugs? Writing tests reduces chance of making a bug. It helps you designing a better code. Why do we agree on deadlines so short that we don’t have time to write tests? By doing that, we, developers are accomplice to unreliable software.
My client doesn’t pay for writing tests
Similarly as in previous paragraph. Moreover, who will pay for fixing bugs and loss of software users due to poorly working software? Be professional, tests are integral part of the code you deliver, count it into your development time. Tests are also great documentation. You’ll thank yourself when you have to get back to code written by yourself after few months break.
We make a lot of changes, tests outdate quickly
Do you even TDD, son? What are the guarantees that you won’t screw things up while moving fast? I’ll tell you — there are none. If test become outdated, probably they’re not the part of your development flow and you don’t run them often enough. Or they’re not the part of your CI/CD flow. Or they are too granular. Fix your working environment, be familiar with new tools, improve your skills. But we’re prototyping a lot, those are just MVPs. Throw them away after validating the business idea and start from the beginning with tests included.
The tooling sucks
There’s no testing culture in my company
You can change the organization or you can change the organization. Change the company. I'm not kidding. It’s probably not a good place to work and you are wasting your time there. Or learn on your own, become a testing advocate, show good practices, educate colleagues. They will thank you later.
My first production app wasn’t tested, second one had poor tests, third one had tests which I could rely on. Testing is a separate skill which I learned. You can write too granular tests which will make your code hard to change without breaking half of the test suite. You can write typo tests, eg. the ones which check if presence validation is defined in model. You can rely on database on your suite which will make you slow and no one will want to use it. But it can be useful to determine that your domain logic is highly coupled with persistence. I’m grateful to people who showed me how to do it right and pointed to the valuable books to read.
Back in the days, one of my colleagues said: Writing tests is like maintaining your programming hygiene. Imagine a surgeon who doesn’t wash one’s hands before performing a surgery. I can’t agree with him more. Don’t take shortcuts, don’t find excuses, don’t commit to low quality of software.
Be the one who tests the code.