Smarty

Testing in Go by Example: Part 6

Even 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
Black Friday ready: Real-time ecommerce address verification
Arrow Icon
Don’t panic. We’re not telling you to set up your Christmas lights in July or tune into your favorite holiday station. We’re not crazy here (mostly). But also, do your thang. What we ARE saying is that if you’re in ecommerce, you know just as well as Smarty does that you have to start prepping for those big holidays months in advance. Today is as good as any to see how setting up the right real-time address capabilities, like suggesting verified customer addresses as they type, can get your business in the black on Black Friday.
Address Autocomplete API JavaScript SDK tutorial
Arrow Icon
Webinar recap: Ready to take your web forms from "meh" to "wow"?In our recent webinar, we gave tips and tricks and demonstrated live coding magic. The essentials of Smarty's address autocomplete APIJavaScript SDK magic made easyIntegrating Smarty’s Address Autocomplete API using our JavaScript SDK is a breeze. Smarty also has SDKs for . NET, Android, Go, iOS, Java, PHP, Python, Ruby, and Rust, making setting up client credentials, building functions, and handling address lookups look like child’s play.
How Smarty™ sidestepped the global IT outage with 100% uptime
Arrow Icon
A recent defective update from CrowdStrike, a leading cybersecurity provider, caused a global outage affecting millions of Windows systems. Oops. The faulty update to CrowdStrike's Falcon software, intended for endpoint detection and response, led to the infamous "blue screen of death" (BSOD) and rendered many systems non-bootable. The widespread disruption primarily impacted large organizations reliant on CrowdStrike's services, sparing home PCs and systems running on Mac and Linux. Like the rest of the world, Smarty employees were also impacted.