Our great sponsors
-
testify
This is a fork of github.com/stretchr/testify, we upstream as much as possible (by symflower)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
dockertest
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work.
-
consul
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
We were unhappy with the common unit test styles and we think we found a style that has clear advantages. An in-depth comparison can be found here https://symflower.com/en/company/blog/2022/better-table-driven-testing/ We also added support for maintaining such tests in our VS Code extension https://marketplace.visualstudio.com/items?itemName=symflower.symflower You can either use the command or the context menu item to maintain tests. There are some changes necessary to have better stack traces because "t.Run" calls the test function from another location. We are in the process of upstreaming them. Until then you can find these changes in our fork at https://github.com/symflower/testify Would appreciate your feedback on the style and extension. Would be also interesting to hear other approaches and conventions that could help others to write better tests.
prefer these two tools: https://github.com/maxbrunsfeld/counterfeiter and https://github.com/hexops/autogold
also if not using repository pattern, I prefer using https://github.com/ory/dockertest
Interesting! I independently arrived at almost the same pattern while working on tests in https://github.com/hashicorp/consul.
Did you encounter gotests when you were doing your research? It's a table test generation tool that generates test code using t.Run(). I do wish it could generate tests using testify, because I frequently end up rewriting the code in the inner loop, but I still use it because it's better than I am about ensuring there's a test for all functions I write.
As another alternative, sorry for the plug, I created this tiny library for structuring tests: https://github.com/devnev/testeach A bit more like BDD but I've found it quite nice to with with