New 42 day free trial
Smarty

Testing in Go by Example: Part 6

Smarty header pin graphic
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 icon
Subscribe Now
Read our recent posts
Shipping optimization: Boosting your bottom line
Arrow Icon
Shipping optimization is rapidly evolving the retail landscape with advancements in shipping technology. From using robotics to increase efficiency and protect workers from dangerous jobs to autonomous vehicles and drones taking items to hard-to-reach areas, shipping has drastically evolved from the infancy of ecommerce in the 1990s. Sure, the 90s are currently having a pop culture resurgence, but your customers don’t want their shipping experience to go retro. One of the most impactful ways to ship effectively is to use a Shipping Execution System (SES).
Wildfire risk assessment with Smarty®
Arrow Icon
In the wake of the recent LA fires that scorched over 10,000 homes and displaced thousands of families, the need for precision in disaster preparation, wildfire risk assessment, and emergency response is clear. Wildfire risk assessment processes are full of pain points for insurance carriers and reinsurance carriers alike: specifically considering risk assessment, efficient response times and routes, and even recovery efforts. This is where address location intelligence can support insurance carriers and governmental entity responses.
Inside Smarty® - Irina O'hara
Arrow Icon
Irina O'Hara is one of our uniquely clever, expert frontend developers. She’s immensely talented and has had a vital impact on our website redesign. When it came time to spotlight her, Irina was a joy to sit down with and get to know a little better. To get to the basics, she writes code and creates awesome websites, and she’s darn good at both. BackgroundIrina was born and raised in St. Petersburg, Russia. However, she wasn't born a development expert and had other aspirations from the start.

Ready to get started?