DEV Community

Cover image for The Testing Introduction I Wish I Had

The Testing Introduction I Wish I Had

Max Antonucci on February 12, 2019

Seeing as there's no shortage of topics I should've learned about earlier, I'm surprised it took so long to write another "Introduction I Wish I Ha...
Collapse
 
priteshusadadiya profile image
Pritesh Usadadiya • Edited

Writing a test that passes isn't always good. There's been cases where I get a test passing, but when I deliberately change it to fail, it still passed and I realized it was busted.

Always, always, always beware of False Positive.

Awesome introduction to Testing @maxwell_dev . Didn't knew about Percy. i will surely check it out

Collapse
 
maxwell_dev profile image
Max Antonucci

I have a few False Positive horror stories, and I actually wish I'd called them that since it's a great way to sum up that testing issue!

And definitely check out Percy, part of me hopes it can be a more reliable, mainstream VR tester for programmers someday.

Collapse
 
maxwell_dev profile image
Max Antonucci

It is a sad reality, and honestly if I didn't work with good programmers in my current job who knew to emphasize testing I likely would have not learned it myself at this point. It's tough because a lack of tests are like working near a nuclear waste spill - it doesn't do any immediate damage, but the damage it does is slow, gradual, and by the time you notice the damage it's likely too late and you're incapable of having children.

So for the sake of future generations, extra focus on tests is needed!

Collapse
 
biros profile image
Boris Jamot ✊ /

Great summary for testing but you may have forgotten performance and stress tests.
Regarding unit tests, it can become very complex when it comes to mocking dependencies or testing asynchronous functions.

Thanks for your post!

Collapse
 
maxwell_dev profile image
Max Antonucci

Ah good catch with the performance and stress tests. Sadly right now in my career I haven't had much exposure to those, so those slipped through my focus. I'll need to do some more research later, thank you for bringing those up!

Collapse
 
fpuffer profile image
Frank Puffer

Great introduction. I would add two - often underrated - items to your Why Testing Matters section:

  • Unit and integration tests promote modular software design. Designing for testability makes code easier to understand and maintain.

  • Tests can serve as an additional documentation, especially to help other developers familiarize themselves with the code. Tests define what the software is supposed to do and what not.

Collapse
 
maxwell_dev profile image
Max Antonucci

These are good points and I thank you for bringing them up here! Especially the point about tests serving as extra documentation. I had planned to include a "tests make your code's aims explicit" section but that header felt too wishy-washy to me and I removed it. But if I'd framed it as documentation I likely would have kept it since it gets more to the point of how it adds value.

Collapse
 
jtenner profile image
jtenner

Absolutely nailed the article! Thanks for this!

I just happened to write an article about testing myself and stumbled onto this gem. (get it?)

dev.to/jtenner/testing-with-assemb...

I managed to develop a testing framework from scratch for the new AssemblyScript language (TypeScript subset compiled to Web Assembly) and would love your thoughts on how it is written.

Thanks a bunch, and cheers on your endeavors! 🎉

Collapse
 
maxwell_dev profile image
Max Antonucci

The React testing struggle is definitely real. I've been spoiled by Ember testing, and the big tradeoff with that is I've gotten much less experience adding my own tests or customizing them when needed. All the more reason it matters to build up a few apps from nothing for better understanding.

Collapse
 
adriantega12 profile image
Adrián Octavio Terrazas García

Loved your article! I've been always bothered by how little emphasis there is on testing. I just finished my degree in CS and just started hearing about testing in my penultimate semester. Had to take a course from another career (IT) to get an introduction to testing! So hadn't I gone out of my way to take that particular class I may have never heard about it up to this point.

Collapse
 
tam360 profile image
Mirza

When I was doing internship as backend developer (ruby on rails), one of my first task was to test the existing apis. My senior fellow recommend me to use 2 gems, factory bot and faker. Factory bot helped me in automatically injecting dummy data for testing. For dummy data itself, Faker played its role. It's a powerful gem that can mock almost all types of data (dates, phone number, coordinates, names etc). These 2 gems really eased the testing process.

P.S awesome article

Collapse
 
maxwell_dev profile image
Max Antonucci

Good recommendations, and we actually use those same two gems for testing in our own Rails app! Plus the RSpec testing library, since it does so much to make the tests explicit, readable, and even fun to write in classic Ruby fashion.

Collapse
 
thehumble_angy profile image
Ange Kouakou

Can someone advise me a suitable article on the ABC of testing for a newbie like me?

Collapse
 
davidshq profile image
Dave Mackey

Love this article Max! Very helpful overview of the different types of testing - it can feel a bit overwhelming when one just sees a list of the different code tests without any succinct explanations. Added this to my "core articles" list (a list I maintain on Diigo of all the articles I think are really essentialy on various topics).

Collapse
 
simoroshka profile image
Anna Simoroshka • Edited

Try react-testing-library! It is awesome, makes testing React so much easier.

Collapse
 
juliatorrejon profile image
Julia Torrejón

What about System Testing?

  • End to end testing scenarios involves testing the fully integrated application in order to check the interaction between different components of the system.
  • Involves verifying thorough testing of every input in the application to check for expected results.
Collapse
 
alilosoft profile image
Ali FELLAHI

I think system testing or end-to-end testing is a kind of integration test at a large scale.

Collapse
 
danku profile image
Daniel McMahon

Interesting article! Definitely recommend checking out WireMock as a useful data stubbing solution: wiremock.org/

Collapse
 
tino profile image
Tino de Bruijn

I can wholeheartedly recommend Obey the Testing Goat!: obeythetestinggoat.com/. It covers all of this in great and practical detail. We have all our juniors work through it during onboarding.

Collapse
 
maxwell_dev profile image
Max Antonucci

I love that! That's a great onboarding topic, it must really help keep the codebase consistently strong.

That would make an amazing t-shirt to, "Obey the Testing Goat."

Collapse
 
lmolivera profile image
Lucas Olivera

I have always thought that tests are unskipable and those who did were lazy people.

Excellent article!

Collapse
 
steelsector profile image
Steelsector

For VR testing I have tried BackstopJS seemed easy to setup and provide what I needed for a small site.