Go advanced testing tips & tricks

This post has moved https://povilasv.me/go-advanced-testing-tips-tricks/

Povilas Versockas
1 min readJan 31, 2017

This post is based on talk I gave at Vilnius Golang meetup.
I have read many blogs, watched talks and gathered all these tips & tricks into a single place. Firstly I would like thank the people who came up with these ideas and shared them with community. I have used information and some examples from the following work:

Before reading this, I suggest that you should already know how to do table driven tests and use interfaces for your mock/stub injection. So here goes the tips:

Tip 1. Don’t use frameworks

Ben Johnson’s tip. Go has a really cool testing framework, it allows you to write test code using the same language, without needing to learn any library or test engine, use it! Also checkout Ben Johnson’s helper functions, which may save you some lines of code :)

Tip 2. Use the “underscore test” package

Ben Johnson’s tip. Using *_test package doesn’t allow you to enter unexported identifiers. This puts you into position of a package’s user, allowing you to check whether package’s public API is useful.

In order to read the full post go to https://povilasv.me/go-advanced-testing-tips-tricks/