Testing in Go by Example: Part 6

Michael Whatcott
Michael Whatcott
 • 
September 25, 2017
Even more about assertions.
Tags

For this installment of the Testing in Go series we'll be talking about a grouping of packages that facilitate general-purpose comparisons in various contexts. Since the most common context is testing it seemed like this series was the right place for the discussion.

We generally refer to these comparison functions as assertions (cue ominous background music and spooky sound effects). You may have already read the opinions found on the Golang FAQ related to assertions.

"Why does Go not have assertions?"

Go doesn't provide assertions. They are undeniably convenient, but our experience has been that programmers use them as a crutch to avoid thinking about proper error handling and reporting. Proper error handling means that servers continue operation after non-fatal errors instead of crashing...

"Where is my favorite helper function for testing?"

Go's standard testing package makes it easy to write unit tests, but it lacks features provided in other language's testing frameworks such as assertion functions. An earlier section of this document explained why Go doesn't have assertions, and the same arguments apply to the use of assert in tests.

In general, we agree that in many scenarios a single assertion failure shouldn't prevent a test from running. So, by default the assertion functions we use don't do that. Problem solved.

Subscribe to our blog!
Learn more about RSS feeds here.
rss feed iconSubscribe Now
Read our recent posts
6 Ways Telecom & Internet Companies Leverage Address Data
Arrow Icon
In a recent webinar, we showed how address data tools help managers improve business performance in the following areas:Network PlanningAsset ManagementCustomer Acquisition and RetentionData BlendingMail and Parcel DeliveryFraud Reduction1. Network PlanningAccurate address data plays a critical role in overcoming network planning challenges. We presented solutions at each of the following steps in the network planning process: Clean existing address data with US Address VerificationKeep incoming data clean with US Address AutocompleteMap all addresses using our US Master Address List and hyper-accurate US Rooftop GeocodingAdd context to maps with enriched US Property DataAnalyze, get spatial insights, and make confident business decisions 2.
A Fresh Start: Clean Out Your Computer Day
Arrow Icon
In a world where the lines between digital and physical spaces blur, the health of our computers has a massive impact on our productivity and overall ability to perform well at work.  Clean Out Your Computer Day, observed on the second Monday of February, is the perfect opportunity to ensure that we declutter and optimize our virtual spaces. Just as we regularly clean our homes and offices, this day underscores the importance of maintaining a streamlined, efficient computer setup. The Digital Declutter: Where to StartStarting with the basics, sift through your files and programs.
Smarty's 2023 Address Data Deep Dive: Trends, Challenges, and Breakthroughs
Arrow Icon
We recently hosted a webinar where Brent Francom and Jeffrey Duncan, two of our Product Managers, talked about the lessons we learned and the improvements we've made in 2023. Here are the highlights. When you process so many addresses, you see things. We processed 327 billion+ addresses in 2023, equating to nearly 900 million per day or over 10,000 per second. When you process that many addresses, you find many funny and interesting ones. We keep a "Wall of Shame" with funny and malformed addresses that somehow validate.
Ready to get started?