---
title: "Discussion on \"Unit tests - what are they and why don't you write any?\" | Hashnode"
description: "Discussion on \"Unit tests - what are they and why don't you write any?\". OK, the title was supposed to get you riled up - if you are the kind of developer who indeed does write unit tests.\nHowever in a recent poll* I conducted on my Twitter account, 50% of people admitted to having NEVER written a unit test, or at least n..."
url: "https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Unit tests - what are they and why don't you write any?](https://hn.katycodesstuff.com/unit-tests-what-are-they-and-why-dont-you-write-any?utm_source=hashnode&utm_medium=feed)

OK, the title was supposed to get you riled up - if you are the kind of developer who indeed does write unit tests. However in a recent poll\* I conducted on my Twitter account, 50% of people admitted to having NEVER written a unit test, or at least n...

Oct 27, 2021 · 5 min read · hn.katycodesstuff.com  
Read the article

-   [#tdd](https://hashnode.com/tag/tdd)
-   [#testing](https://hashnode.com/tag/testing)
-   [#software-development](https://hashnode.com/tag/software-development)
-   [#qa](https://hashnode.com/tag/qa)
-   [#programming](https://hashnode.com/tag/programming)

## Written by

[Katy A](https://hashnode.com/@KatyCodesStuff)

@KatyCodesStuff · Nottingham, UK

  
[View profile](https://hashnode.com/@KatyCodesStuff)

@KatyCodesStuff

## Responses 16

Markdown supported · ⌘↵ to post

[patel riya](https://hashnode.com/@riya5451)

[Sep 26, 2022](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/63314ff9491a0c3202e4957f)

Various people generally hire <a ref="h[gurugramescort.com/Gurugram](https://gurugramescort.com/Gurugram) Escorts">Gurugram Escorts</a> hourly; when required, it can also be extended to days per the customers' requirements. However, the pricing of packages will be high when going for more duration for the Independent Escorts in Delhi. For the benefit of customers, details regarding packages will be provided directly through the Delhi Escorts website.

[Riya Patel](https://hashnode.com/@riyapatel01)

[Jul 27, 2022](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/62e1020d657a4fae5a0e6b93)

[Delhi Russian Escorts](https://gurugramescort.com/russian-escort-in-delhi) Service will provide a beautiful girl if you're alone. Let me now tell you about Russian Delhi Escorts. Delhi Russian Service is an agency where you can find the most beautiful girls and have fun with them. It is also the capital and most modern state of India. As sex is relatively easy here, it is also prevalent. You can expect to meet intelligent and sophisticated [Russian escorts in Delhi](https://gurugramescort.com/russian-escort-in-delhi). Russian escorts Delhi can be so gorgeous that you'll feel like a Bellwood & Hollywood star or model is coming to your hotel room for sex. These escorts are devoted to their customers and take pride in their ability to satisfy them. The Delhi Call girl has a lot to offer customers. She will make the customer happier by becoming their partner or girlfriend after they get in bed.

[Richa Thakkar](https://hashnode.com/@richa123)

[Mar 14, 2022](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/622f338edf08b9b82341b1a1)

I suggest every user if you are finding this type of information so come here and visit it. [Escorts in Goa](http://www.7stargoaescorts.com/)

[Ruzaik Refai](https://hashnode.com/@Ruzaik)

[Feb 2, 2022](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/61fa668398d3a620773e46de)

Concise yet paints a clear picture. Kudos!

[James Osibogun](https://hashnode.com/@JamesCodesStuffBlog)

[Nov 14, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/619075ccc5a37f2de1be95d9)

Hello all,

This was a great post. It is important to do the unit test, Junit test, and practice running the code after the completion of a line. QA is always number one. Lastly, make sure you run "Hello World" before every project.

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Nov 14, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/619075ccc5a37f2de1be95d9#reply-6191043d83e4212d6e579956)

Thanks for commenting!

[Andrew Reiser](https://hashnode.com/@areiser)

[Nov 12, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/618ee5a126d4d237c427811a)

Unit tests are a complete waste of time. I'm so sick of zealots and evangelists like you propagating the myth that they actually make a difference. If you write tests, you are wasting your boss's time and money. I hear developers declare, "whoa, I wouldn't feel safe if my code wasn't back my tests". This is such rubbish. I have never seen a unit test save the day. I've never heard the words, "Whoa, that was a close one, lucky we had that unit test." They are a pest and a maintenance burden. Unit tests, just say NO.

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Nov 14, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/618ee5a126d4d237c427811a#reply-619104cdc5a37f2de1be9dea)

I'm sorry you feel like this - I have seen unit tests stop bugs getting introduced many times.

[Ernesto Cianciotta](https://hashnode.com/@ernstc)

[Dec 20, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/618ee5a126d4d237c427811a#reply-61c0d4ab02755832385f4aa5)

Indeed I have been in situations where I would have said "If we have had unit tests, these regressions would never happened" and the customer would have been much more happy.

[Rodrigo](https://hashnode.com/@rodrigomd)

[Nov 5, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/61859fcc936da605cb9ab101)

Hi Katy, great post. I enjoyed the reading; It shows that you know what you are talking about.

Although I have some clarifications to make (I hope you don't mind)

> A unit test is the smallest test you can do on your code.

That depends. When you work with TDD or TCR you write even smaller tests (micro tests) and all together they make up a unit test.

> The perfect unit test class will only test ONE class.

Many people associate that idea with "unit", which must be a class, function, or module. It is actually a **behavior** in which the behavior could be modeled by the interaction of multiple classes or functions. It doesn't necessarily mean having a to test just one class, module, or function.

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Nov 14, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/61859fcc936da605cb9ab101#reply-6191052583e4212d6e579967)

Hey Rodrigo, thanks for the comment.

My article is intended to summarise unit testing, rather than go into a lot of detail.

In general, unit tests are written to test one class at a time.

[Somya Pandey](https://hashnode.com/@somyapande)

[Oct 29, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/617bc10654e5820289bf976a)

A debt of gratitude is in order for imparting decent data to us. I like your post and all you share with us is forward-thinking and very enlightening, [High Profile Escorts in Bangalore](https://www.thebangaloreescorts.in/) I might want to bookmark the page so I can come here again to understand you, as you have worked effectively

[Chris Jackson](https://hashnode.com/@cjack0416)

[Oct 28, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/617ada5154e5820289bf89bd)

Great article! My internship this summer was my first experience with unit testing and I definitely see the benefit now. Saved so much time even though at first it doesn’t seem like it.

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Oct 28, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/617ada5154e5820289bf89bd#reply-617b1ec954e5820289bf8d2e)

Thanks for commenting Chris! I'm glad you're starting off somewhere which has already instilled the important of unit tests! It will only be positive for the future 😁

[Florin Tomozei](https://hashnode.com/@mallfurion)

[Oct 28, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/617a54f3913b6d3f08e17805)

Hey, Katie. Great article. Do you have any recommendation on how to determine what exactly to test in a component / class? Could the acceptance criteria of a story contribute to this?

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Oct 28, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/617a54f3913b6d3f08e17805#reply-617a584d913b6d3f08e1786b)

Hey Florin, thanks for the comment!

While AC should provide the great basis for feature testing, often they are too high level for unit tests. E.g. if your AC is to create an endpoint which POSTs a new blog post for example, you would have multiple classes to create this, and multiple sets of unit tests which will all test small parts of the flow but not the overarching feature. So the AC might be "When I submit a blog post to my endpoint, then I can view the blog post on the website"

The unit tests will be more granular like "Given I submit text to the controller, When I call Post, Then the Add To Database method is called" - and you would only be testing the Controller object here with all other dependencies mocked.

It's hard to explain without a better example but hopefully I can write up some in the near future. Hope that helps!

[Andrew Baisden](https://hashnode.com/@andrewbaisden)

[Oct 27, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/6179bcb1913b6d3f08e16e20)

Yay first article! The problem is that not every company takes unit testing seriously enough to have it as part of their daily workflow. And new developers tend to leave it until last or skip it altogether because it is not exciting to do.

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Oct 27, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/6179bcb1913b6d3f08e16e20#reply-6179bee26584fe6ae5984f23)

It's true, and so it's up to us developers to hammer the point home that tests are valuable, and we want them in our code base!

Thanks for the comment 😊

[Debbie Dann](https://hashnode.com/@debbiedann)

[Oct 27, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/6179aa716584fe6ae5984e09)

Amazing first article, Katy. Testing is on my to-learn list. It's not something that I've come across in my learning so far, it wasn't in the courses I did. I'll get to it soon though as I think it will be a big plus when applying for jobs.

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Oct 27, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/6179aa716584fe6ae5984e09#reply-6179ab316584fe6ae5984e20)

Thanks Debbie ☺️ it will definitely help you stand out, especially as a junior.

[Jon Jackson](https://hashnode.com/@iamjonjackson)

[Oct 27, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/6179a8ea913b6d3f08e16d31)

Great post Katy. I struggle with this myself, tending to work on smaller projects and succumbing to laziness! Important for software students to have this demonstrated to them as early as possible as part of real projects 👌🏻

[Katy A](https://hashnode.com/@KatyCodesStuff)

[Oct 27, 2021](https://hashnode.com/posts/unit-tests-what-are-they-and-why-dont-you-write-any/6179a4ff6584fe6ae5984da7/comment/6179a8ea913b6d3f08e16d31#reply-6179a955913b6d3f08e16d48)

I know unit testing is not the fun or sexy part of software development.

But it's worth it when you see all those green ticks... you know life will be ok. 😆

Thanks for the comment Jon, it should be taught to CS students really.
