Comment by t43562

3 years ago

I find go test writing a misery because of the style golang recommends and our company has decoded is to be enforced. You have a list of data values and expected results in an array and then a test at the bottom that applies these array items to the function you're testing - sounds great right? No - because often the only way to get all the variations you need in the test is to have helper functions that are referenced in the array to setup the situations you want. i.e. it ends up being far harder to add a new and slightly different test to this array than to just write a new test - and that's not supposed to be allowed.

Since you brought up Go, I had a question as someone who's just started using the language. Do Go users generally just use "testing" package for writing tests or are there other commonly used packages that can be used in place of or in tandem with that? Just trying to get a sense of what the options are and what the "state of the art" is.

  • The standard testing package for the win, and many pull in a light weight assertion library like Testify.

    I love testing in Go (and _loath_ testing in Ruby). Our unit and integration tests are mostly great. Tests are just code. No DSL or special anything; just normal code. My favorite test that showed me the light: it would spin up several smtp servers (the system under test), like a dozen or more, get the SMTP conversation to different points and wait for timeouts and ensure that everything behaved. The test ran in under 10ms.

    We have tests that ensure logs happened, metrics emitted, timeouts honored, graceful shutdowns work, and error paths are easily validated with test fakes that return canned errors (no mocks). I love testing in Go.

    • Nice, thanks for the reply. Our Python tests run incredibly slowly. Having fast tests makes such a big difference. It can be really demoralizing waiting for a bunch of tests to finish. In general, I'm incredibly excited for how fast Go is, especially compared to Python. I had almost forgotten what fast feels like.

      2 replies →