Testability is having resilient code. This resilience is proved as a programmer attempts to use one class with multiple use cases. In the past, I attempted to write tests for a project I already wrote code for. During these attempts I noticed these classes relied heavily on other aspects of the project. This can be other class references or variables. This made the resulting tests longer and much more complex than it should be. To make this code testable, these references needed to become variables.
Let's get technical
I’ll use some code from Github to demonstrate how I wrote code that was not testable. Within my first week of learning Go I decided to write a web framework. I tried to use only two files to write an entire code base for a framework. This was, undoubtedly, a terrible idea. You can find the contraption at https://github.com/cheikhshift/gos. Here is a piece of sample code to present the problem visually :