Smarty
Testing in Go by Example: Part 6Even more about assertions.
Michael Whatcott
Michael Whatcott
 • 
September 25, 2017
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
How Tech Companies Can Succeed in the 2024 Hiring Market
Arrow Icon
Throughout my many years of leading tech companies, I’ve immersed myself in the varying shifts in technology’s job market. However, the 2024 tech hiring market presents significant challenges for both companies and candidates, stemming from the rapid evolution of the industry, a shortage of skilled talent, workforce preferences for remote work options, increased competition, and a growing emphasis on cultural fit and soft skills. To navigate these challenges successfully, finding strategic approaches for employers is crucial.
Smarty Launches US GeoReference Data, Providing the Easiest, Most Accurate API Needed To Access Census Tract and Block
Arrow Icon
PROVO, Utah, April 10, 2024 – Smarty, the address data intelligence leader, announces today the launch of US GeoReference Data, a set of updates to Smarty's US Address Enrichment solutions. US GeoReference Data is a cloud-native solution that will allow organizations to append the geographic data found in U. S. Census Block and Tract information into accurately geocoded addresses.  Smarty's US GeoReference Data is the simplest and fastest way for organizations to access Census Blocks, Tracts, location names and statuses, as well as additional Census ID information relevant to a property.
International Be Kind to Lawyers Day
Arrow Icon
Lawyers get a bad rap. Lawyers have been around for a long time, and when you're this old, you're bound to collect your fair share of good and bad. It's true, ask your grandpa. We've got records of people described as "lawyers" going back to ancient Greece, Rome, and the Byzantines. These first individuals were folks who were asked to speak for the accused because those under scrutiny were—understandably so—shaken up by the situation. It went from someone who was your friend and did you a favor by speaking on your behalf to someone who knew all of the laws, and you'd hire them to speak eloquently for you.
Ready to get started?