Sign in
Log inSign up
Katy A

167 likes

·

2.4K reads

27 comments

Debbie Dann
Debbie Dann
Oct 27, 2021

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.

4
·
·1 reply
Katy A
Katy A
Author
·Oct 27, 2021

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

2
·
Jon Jackson
Jon Jackson
Oct 27, 2021

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 👌🏻

3
·
·1 reply
Katy A
Katy A
Author
·Oct 27, 2021

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.

2
·
Andrew Baisden
Andrew Baisden
Oct 27, 2021

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.

1
·
·1 reply
Katy A
Katy A
Author
·Oct 27, 2021

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 😊

2
·
Florin Tomozei
Florin Tomozei
Oct 28, 2021

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?

1
·
·1 reply
Katy A
Katy A
Author
·Oct 28, 2021

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!

1
·
Chris Jackson
Chris Jackson
Oct 28, 2021

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.

1
·
·1 reply
Katy A
Katy A
Author
·Oct 28, 2021

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 😁

1
·
James Osibogun
James Osibogun
Nov 14, 2021

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.

1
·
·1 reply
Katy A
Katy A
Author
·Nov 14, 2021

Thanks for commenting!

·
Deactivated User
Deactivated User
Deactivated User
Dec 9, 2021

Great words right there! I have just started learning some basic testing for a React project of mine and I am starting to see its potential 💪🏼 As you said, it might not be the sexiest thing in programming, but it should be well considered for any Solid software structure! Thanks for the article 🙏🏼

1
·
Somya Pandey
Somya Pandey
Oct 29, 2021

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 I might want to bookmark the page so I can come here again to understand you, as you have worked effectively

·
Deactivated User
Deactivated User
Deactivated User
Oct 30, 2021

Great Article! Now I may be a bad dev. But I have 0 idea what a unit test is. 🙃

·
·1 reply
Katy A
Katy A
Author
·Nov 3, 2021

Hopefully you have a slightly better idea now!

·
Rodrigo
Rodrigo
Nov 5, 2021

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.

·
·1 reply
Katy A
Katy A
Author
·Nov 14, 2021

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.

·
Andrew Reiser
Andrew Reiser
Nov 12, 2021

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.

·
·3 replies
Katy A
Katy A
Author
·Nov 14, 2021

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

·
Ernesto Cianciotta
Ernesto Cianciotta
Dec 20, 2021

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.

·
Deactivated User
Deactivated User
Deactivated User
Jan 26, 2022

"Software Engineering", the only engineering discipline where testing is optional!

I wonder how many people would want the same philosophy in Civil or Mechanical Engineering.

·
Deactivated User
Deactivated User
Deactivated User
Jan 26, 2022

From my experience, I've found that unit tests have other values that aren't promoted as much. The value of "preventing bugs" isn't as valuable as the following:

  • Unit tests provide a living documentation of the requirements.
  • Unit tests are a powerful design tool when TDD is done. It enables the developer to work with the interface before the implementation. Thus, allowing them to empathize with code maintainers before the code becomes a mess.

I think the name "Unit Test" is unfortunate. For whatever reason, our industry sees "testing" and "design" as optional and consumers expect software to be buggy.

I liked your point on DI. This is another key benefit of TDD. The number of times I had to go into someone else's code base where they just exploited singletons everywhere often makes me question my career choice.

·
Ruzaik Refai
Ruzaik Refai
Feb 2, 2022

Concise yet paints a clear picture. Kudos!

·
Richa Thakkar
Richa Thakkar
Mar 14, 2022

I suggest every user if you are finding this type of information so come here and visit it. Escorts in Goa

·