DEV Community

Cover image for TDD Part 1: Why Should I?

TDD Part 1: Why Should I?

Sam Hall on December 18, 2020

Introduction In the first part of this series I want to share my personal experience with test-driven development(TDD), how I got there,...
Collapse
 
dakujem profile image
Andrej Rypo

Looking forward to the rest of the series. I wonder if you plan on targeting higher level tests. I mean, unit tests are mostly easy. But how do you test request-to-response with all the middleware, controllers, database and microservices. That has always kept me wondering. How people efficiently do that.

Collapse
 
hallsamuel90 profile image
Sam Hall • Edited

Thanks for the feedback! That's a super interesting topic but maybe beyond the scope of this series. I do plan to talk about acceptance testing when covering outside-in TDD but that's about as high level as I plan to go.

There are a lot of interesting strategies for example something like chaos monkey which turns off random containers to flush out faults.

I will keep this in mind and can maybe do a follow up series!

Collapse
 
dynamicsquid profile image
DynamicSquid • Edited

Hmm... I see so many tutorials on how to write good tests, but I've never seen one on how to get started with writing tests...

Collapse
 
hallsamuel90 profile image
Sam Hall

Thanks for the feedback! I can address that in this series. Is there anything specific you'd like me to cover?

Collapse
 
dynamicsquid profile image
DynamicSquid

One example I can think of is writing tests for a "network" class that sends and receives data.

Thread Thread
 
hallsamuel90 profile image
Sam Hall

you got it!

Collapse
 
igorfil profile image
Igor Fil

I tried TDD 5 years ago. I cannot stress enough how powerful it is! It allow me to write code faster and with less bugs. Now whenever I start with a new technology, I first check how to write unit tests :)

Collapse
 
hallsamuel90 profile image
Sam Hall

Agree 💯. It's hard to go back once you get the hang of it!

Collapse
 
andreidascalu profile image
Andrei Dascalu

Tdd can be interesting as an exercise in discipline as long as you mean unit tests.

Collapse
 
hallsamuel90 profile image
Sam Hall

Yes definitely! Higher-level tests are important as well, but that is out of the scope of this series. Albeit acceptance tests that use mostly real objects are an important part of outside-in TDD.

Collapse
 
hallsamuel90 profile image
Sam Hall • Edited

Love to continue the discussion here! Let me know if you agree/disagree or have any questions.