DEV Community

loading...

52 Unit Tests

John Forstmeier
Build well
Updated on ・2 min read

I'm not really a New Years resolutions-type person but I am definitely a TODO list-type person and the New Year happens to be a convenient starting point to measure task progress against.

I write the majority of my software in Go which has this handy-dandy _test.go feature which many people have written about previously. For example, if you have a production file called handlers.go there would be a matching handlers_test.go file for test code which encourages a focus on developing good testing practices.

Even with this inherent design it can still be difficult to maintain good self-discipline and test-writing habits and that is where I struggle. However, TDD provides an immensely beneficial perspective from which to approach software design and construction (plus these tests run in seconds so they can be run after nearly every local code change).

But getting myself permanently into that mindset takes time, just like any habit. I'll be trying to write at least one unit test per week this year; I will be counting any updates/tweaks I need to make to existing unit tests if I'm focusing on existing production code that week. To track progress, I'll be making tasks each week in Todoist but if anyone has a better idea on how to track it, let me know! Maybe I'll do a mid-year check in or a full-year post mortem and see my results.

Discussion (1)

Collapse
jamesrichmond24 profile image
James Richmond

Great decision!
Unit tests are incredibly important and eventually make your job easier!