My Authors
Read all threads
#UnitTesting and #TDD continue to deliver

Yesterday, I was fighting a pretty nasty bug, all the unit tests passed

I knew there was a corner case not covered by the unit tests but what was it?

Reviewing my assumptions, the key: hw was not exactly sync
Need to test for data 1/
Not aligned, I added new unit test for that assumption, of course the test failed

Now, I just needed to modify the code to make that test pass and not make the rest of the tests fail

The best part, i could work with very small and manageable arrays (instead of the 2GB array) 2/
Once all the tests passed, tested with hardware and everything just worked!

Let's see why this worked:
1) there were 35 unit tests that tested the "happy path" and some corner cases
2) I could confidently modify the code and know I would be alerted if I broke existing code
3/
Now I have 40 unit tests ready for the next corner case I didn't envision or when the customer changes the requirements

As usual, the real benefit of tests is found once you already have several unit tests, so, take the leap of faith and start creating some

4/
Next time you find a bug, before modifying code, create a unit test that needs to pass once the bug is fixed, then go fix the code and verify with the unit test that you indeed fixed it

And that is why I love Test Driven Development

Thanks for following along :)

5/5
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Fabiola De la Cueva

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!