Testing in golang with "Is" framework
Today’s post is gonna be a short one. I’d like to recommend a framework which I used personally on a number of occasions.
Golang comes with a great environment and a set of tools. Tests are first class citizens. Why would you need additional framework for your tests then? Purely for convenience.
is is a mini framework, at the moment of writing this post, the API is comprised of four functions:
and frankly, majority of the times, that’s all you’ll need. The framework itself doesn’t distract you from the work, yet provides convenience to write tests faster and express the intention clearer. Compare the following:
I’m sure we all agree that the former is much more concise and quicker to write.
Tests usually serve two purposes. The first one is obvious: quality assurance. The second one is API documentation. As far as the latter is concerned, is serves that purpose perfectly. Tests written with is assertions can be, more or less, read like a natural spoken language which greatly improves comprehension.
Give is a try. I’m pretty sure you won’t regret it.