79

At one of my former jobs, I had a four-day-week. I remember once being called on my free Friday by an agitated colleague of mine arguing that I crashed the entire application on the staging environment and I shall fix it that very day.

I refused. It was my free day after all and I had made plans. Yet I told him: OK, I take a look at it in Sunday and see what all the fuzz is all about. Because I honestly could fathom what big issue I could have caused.

On that Sunday, I realized that the feature I implemented worked as expected. And it took me two minutes to realize the problem: It was a minor thing, as it so often is: If the user was not logged in, instead of a user object, null got passed somewhere and boom -- 500 error screen. Some older feature broke due to some of my changes and I never noticed it as while I was developing I was always in a logged in state and I never bothered to test that feature as I assumed it working. Only my boss was not logged in when testing on the stage environment, and so he ran into it.

So what really pushed my buttons was:

It was not a bug. It was a regression.

Why is that distinction important?

My boss tried to guilt me into admitting that I did not deliver quality software. Yet he was the one explicitly forbidding me to write tests for that software. Well, this is what you get then! You pay in the long run by strange bugs, hotfixes, and annoyed developers. I salute you! :/

Yet I did not fix the bug right away. I could have. It would have just taken me just another two minutes again. Yet for once, instead of doing it quickly, I did it right: I, albeit unfamiliar with writing tests, searched for a way to write a test for that case. It came not easy for me as I was not accustomed to writing tests, and the solution I came up with a functional test not that ideal, as it required certain content to be in the database. But in the end, it worked good enough: I had a failing test. And then I made it pass again. That made the whole ordeal worthwhile to me. (Also the realization that that very Sunday, alone in that office, was one of the most productive since a long while really made me reflect my job choice.)

At the following Monday I just entered the office for the stand-up to declare that I fixed the regression and that I won't take responsibility for that crash on the staging environment. If you don't let me write test, don't expect me to test the entire application again and again. I don't want to ensure that the existing software doesn't break. That's what tests are for. Don't try to blame me for not having tests on critical infrastructure. And that's all I did on Monday. I have a policy to not do long hours, and when I do due to an "emergency", I will get my free time back another day. And so I went home that Monday right after the stand-up.

Do I even need to spell it out that I made a requirement for my next job to have a culture that requires testing? I did, and never looked back and I grew a lot as a developer.

I have familiarized myself with both the wonderful world of unit and acceptance testing. And deploying suddenly becomes cheap and easy. Sure, there sometimes are problems. But almost always they are related to infrastructure and not the underlying code base. (And yeah, sometimes you have randomly failing tests, but that's for another rant.)

Comments
  • 4
    Not gonna lie, you've opened up my eyes up to testing. JUnit is gonna get abused soon.
  • 1
    Nice story, sometimes shit has I go wrong before it can improve :)
  • 4
    Why would you forbid people from writing tests
  • 5
    @gggggggggg It's not that uncommon. There are three main rationalizations:

    1) The project is fire and forget. It won't need test.
    2) It's a prototype. It won't go live.
    3) Writing tests takes longer than without writing tests. You know how to code, don't you?

    My boss both used number 3 and 2. Needless to say I wasted lot of days on weird bug hunts which made the matter of time a joke in the end. And of course my prototype went live.

    It happens more in web agencies (which I now avoid) but also point 2 is often used even in companies that otherwise cherish tests.
  • 1
    I think number 3 is yet another proof of Poe's law.
  • 1
    @Grumpy It also has to do that my former boss had a coding background. And by that I mean he used to code with php4 and raw mysql statements. So it surely influenced his thinking, even though it made some discussions borderline grotesque.
  • 3
    Writing tests are fun and super valuable. How can you even develop quality software without tests? Sounds very hard.
  • 2
    @simeg It's not only hard, I neigh impossible.
  • 2
    This is an exceptionally important post for all the newbros out there. Test your shit and especially the shit of others.
Add Comment