DEV Community

Cover image for A Series of My Unfortunate Mistakes (When Writing Tests)

A Series of My Unfortunate Mistakes (When Writing Tests)

briwa on July 06, 2019

Once upon a time, when I started writing tests long time ago (actually, not that long, maybe a few years ago), I was a naive young man. I hate bugs...
Collapse
 
thinkdigitalsoftware profile image
ThinkDigitalSoftware

Love your writing style! It kept me interested all the way though. The lessons are great too!

Collapse
 
briwa profile image
briwa

Thanks! It means a lot since I just started writing two months ago, and I've kind of been shooting in the dark here. Glad that you like it. If you do have any feedback, do send them my way. Thanks, again.

Collapse
 
tyrrrz profile image
Oleksii Holub

I would argue that testing constructor that only assigns private initial value is unnecessary, seeing how you're testing methods that work with that value. After all, it doesn't matter what's going on inside a class if the output is correct.

Collapse
 
briwa profile image
briwa

You have a point. I've mentioned in the article, maybe if the constructor function has some logic, it can be tested and asserted as well. But true that, in the example I've given, testing the constructor itself might not mean that much, just putting it there.

Collapse
 
scriptmunkee profile image
Ken Simeon

Very nice write up. These lessons are the exact same one's I'm driving into my Quality Engineers.
I'll be sharing this article with them.

Cheer!

Collapse
 
martingaston profile image
Martin Gaston

Thanks for the article! There's some good testing tips in here that I'll definitely be keeping in mind with my next project 👍

Collapse
 
briwa profile image
briwa

Glad to hear that!

Collapse
 
mcborreo profile image
Caye

Can relate to having those awkward testing skills 😅 Glad you learned along the way! And thanks for sharing them to us here 👍

Collapse
 
vlasales profile image
Vlastimil Pospichal

Write tests first!

Nice article.

Collapse
 
briwa profile image
briwa

Wow, nice catch! Thanks. I've amended the article.