Code Naked

  • I can not merge your pull request on our Git.
  • Why?
  • There is only one file modified.
  • That is because we modified only one Java class.
  • That is exactly the problem. I can not see in the pull request the modified JUnit test.
  • I could not modify the unit test because there was no any.
  • I see. And that is a problem of the past. The present problem is that still there is no unit test.
  • But we have no time to write unit test for the whole program. There are zillion of lines of code developed during the last few hundred years. They have no unit tests and they just work.
  • I acknowledge that. That is the life when you maintain legacy code. But why did not you write unit test for the change you just created?
  • There are zillion of lines already…
  • Yes, those that “work”. But your change is new. How do you know that it works?
  • We just agreed that we do not start to write unit tests now. We do ad-hoc testing.
  • Okay. Then let’s just get back to the basics. Why do we have unit tests? What is the primary reason?
  • To have working and tested code.
  • Im my opinion this is more like documentation. Unit test is a live documentation that is more likely to be maintained than any other documenation. You just created a few lines of code without documentation.
  • I get your point, but we just do not have time for that.
  • Let’s look at the following situation. It is summer and hot. You wake up late and want to rush to fetch the bus. You take the shower and drink your coffe and run to the bus. Right?
  • Right.
  • You do not even dress. Run out naked.
  • No! No! I dress!
  • But you have no time. You are in a rush. If you have time to dress yourself why do you let your code run to production without unit tests naked?
  • I get the point. But you can survive without unit tests. If you run on the street naked you will not survive.
  • Why is that? The summer is hot, you will not catch cold.
  • Yeah, but police would catch you.
  • So this is a kind of society issue, is it?
  • Yes, it is.
  • And the coding society is not that matured yet, it lets you run naked without unit tests.
  • I assume… yes.

we still have a long way to go ahead of us…


9 thoughts on “Code Naked

  1. Stefan Reich

    So you’re the “police” kind of guy. I think that’s why my algorithms are better than yours.


  2. Vasile Boris

    There are projects were the clients do not want to pay for unit tests. I did not worked in such a project but I heard that it is a common practice. I heard that they explain that they will do the testing so there is not need to also unit test it.

    Liked by 1 person

    1. Peter Verhas Post author

      There are car owners, who do not bring their car to service. They explain that they do brake regularly so they will know when there is some problem with the brakes, so there is no need for the service testing the brakes.

      Liked by 3 people

  3. Kemény András

    ah, come on peter, you know unit testing is for wussies. anything you can test by unit testing is so simple it’s actually embarrassing you have to test it. anyway, any code that is so divided that all its pieces can be unit-tested separately is guaranteed to be a shameless resource hog.

    now, integration tests… that’s where the point is. alas, they are almost as complicated as (and in most cases, actually MORE complicated than) the software they’re testing. the systems i code would humongously benefit from integration tests as they tend to have a lot of simple parts interconnected in very, hm, exciting ways.

    but most of the clients are, “nah, we’ll fix any errors that pop up in the production run.” actually, unless you’re stupid enough to code bugs that cause actual unfixable data corruption or hard cash losses, then, with a bit of a devotion to fixing errors, it’s a viable option.


  4. Pingback: Java Testing Weekly 19 / 2016

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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