DEV Community

vamsi pavan mahesh gunturu
vamsi pavan mahesh gunturu

Posted on

Review on doing TDD for 14 days, 100% test coverage 😱

We have started doing TDD by pair programming at work for the past 14 days.

Some of the benefits that we could observe :

  • Tests don't feel like extra work that we need to fill once the code is written, they are part of the workflow.

  • Insane clarity on how the interfaces are going to look like because we design the interfaces in tests themselves.

  • Doing TDD is fun, you get a small joy whenever the test changes from red to green.

The side effect of all this is 100% test coverage.

Finished in 3.17 seconds (files took 6.89 seconds to load)
102 examples, 0 failures

Coverage report generated for RSpec to /Users/user/work/video_ops_backend/app/coverage. 813 / 814 LOC (99.88%) covered.
Enter fullscreen mode Exit fullscreen mode

Okay maybe I lied a little, we have not covered one line :p

That line happens to be in our exceptions handler, where we are not covering Generic catching of exception because we are catching all of them in the hierarchy above.

I don't think we are ever going back to writing code and backfilling tests after discovering this wonderful world of TDD.

Full disclosure:
The pair working on this project has a senior engineer(me) and a lead engineer, who are already familiar with the tech stack, writing tests for a couple of years, YMMV.

Top comments (0)