DEV Community

Discussion on: When TDD doesn't click, something else should click "harder"!

Collapse
 
galdin profile image
Galdin Raphael

Just like you mentioned, I use TDD only when I know every possible outcome before hand. Eg. in domain logic.

With integration or UI/end-to-end tests, my goal is generally to avoid regression, so I write few broad tests after the code has been written. The tricky part however is ensuring that these tests fail when they should -- I find it hard to tell if there are false positives without TDD.

Collapse
 
yaser profile image
Yaser Al-Najjar

Exactly... the worst part is that you never know in future whether new requirements are gonna make them red or not.

I'll discuss those in the coming article and what approach is actually suitable for such cases.

Collapse
 
ewoks profile image
Beeblebrox

Like you write application code and need to refactore it if requirements change, you need to redactore unit tests too. However I you have good unit test suite and you realize that part of code can be refactored to something better, with unit tests you will quickly figure out if you broke something during refactoring, or everything works as it should and all of that without manual clicking and "quickly testing" by hand.

Thread Thread
 
yaser profile image
Yaser Al-Najjar

Yep but TDD isn't the answer for quick refactor, maybe something else can be better, more descriptive, and more time-saving.

Thread Thread
 
ewoks profile image
Beeblebrox • Edited

actually it is... ¯\(ツ)

Thread Thread
 
yaser profile image
Yaser Al-Najjar

I know how it feels @vbjelak

Have a look at this great video: youtube.com/watch?v=qkblc5WRn-U

It's a good start ;)