Over the last few weeks I had some free time to improve my graphql parsing library. There were a lot of inefficiencies in the lexer and in the parser as well so I had to refactor the complete codebase. Test coverage was important to me from the beginning, so refactoring to a state where everything still works as expected was no problem. Here’s a link if you are interested in parsing, lexing or graphql:

While refactoring, I came across many situations where I was fighting against my tests. Due to the way I’ve implemented my unit tests it wasn’t always easy to find the actual issue.

In the end I discovered/developed a style which I call “check based panic testing”. I’m confident this way of testing will make further refactoring a lot easier.

To get everyone on the same page I’d like to outline all the methods and styles of unit testing I’ve used, what their pro’s and con’s are and why I finally chose check based panic testing over the others. I hope you can learn something from my golang testing adventures.