While only a minor point in the article, I was intrigued by the reflection that the conversion from Ruby to Go was relatively easy because the test suite executes Hub’s executable as a user would, instead of calling individual functions.
This has me thinking a few things:
I wonder how Hub dealt with the CLI making network requests in tests, though?
Akkartik’s trace testing provides a similar piece of non-language specific indirection.
It always bothers me to some degree, that heavily depending on the programming language for you testing environment (like mock objects) provides great ergonomics for creating tests. However, they cement an implementation so deeply, I wonder if they create much more commitment than any author intended.
I guess different people mean different things when they say ‘better’, but I’d agree in the vague sense that I would rather be comfortable with some integration tests, than with good ‘unit test’ coverage and no integration/end-to-end tests.
Also, if your system wasn’t tested in the first place, integration testing is often a necessary step before you can start unit testing as it requires reorganizing and decoupling your code.
Answering my own question: it looks like the tests use given blocks to specify a fake API and responses that the CLI hits.