Unit testing is more important than you think

The most important benefit unit testing gave me is being able to make changes without fearing things might blow up due to even a small change. The whole process of Software development is dealing with complexity where each new step creates a brand new tangle in the already existing fuck sandwich of a stack.

For smaller projects, you may get away okay without writing unit tests. But in a decent sized project with more than one developer involved, it’s a must if you want to keep your sanity intact.

As engineers, all we do is making things that reduce human effort. So why hurt your brain thinking about whether your current changes will break another feature? leave it to the software to test. Unit testing is testing your function as a small unit of your entire app. Besides making sure your function is working properly, this practice has some beneficial side effects as well.

Superior error handling
The difference between a good and bad software is that the former handles errors better. When you write code with tests in mind, you know there will be test cases that provide invalid data or invoke the function with incorrect parameters and expect it to throw certain errors. Having tests in mind will automatically force you to write better code and deal with different types of errors in proper way.

Another way it helps you handle errors better is you can copy test cases for similar features from open source projects. For example, if your code deals with http requests, you can find the test cases commonly used on network requests and add those to your code. Why reinvent the wheel?

Better reasoning about the software
Test driven develoment is overall a better strategy of software development in my opinion. Thinking about your code in this approach gives a clearer picture.

--

--

--

Software Developer. Building digital products.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating Logical Volumes on Linux System

Xcode Unit Testing: Right way to mock async code

5 Dimensions of Why Software Excellence is Important for Your Organization

Setting the standard for fair play

Chapter 7 Attorney

chapter 7 attorney

11 Preparation Tips For The AZ-104 Exam

GCP: Folder Hierarchy & Group Management with Terraform

How to serve multiple S3 buckets via single AWS CloudFront distribution

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shakil Ahmed

Shakil Ahmed

Software Developer. Building digital products.

More from Medium

Owning features, and how to deliver in an organized way

The art of polite code reviews

Green Software Engineering — Back to the roots!

Not so soft skills