Disclaimer
I am the original author of gunit
and the oft-associated assertions
packages.
TL;DR
testify
is mainstream and very well-suited for integration test scenarios.gunit
has different (BDD-style) assertions/output and is a better fit for pure unit tests.
Similarities
- Similar startup:
suite.Run
&gunit.Run
- Both provide access to
*testing.T
- Similar Setup/Teardown for test cases
- Bottom Line: simple test suites defined in both gunit-style and testify-style look almost identical!
github.com/stretchr/testify/suite
- employs "shared" fixtures - uses the suite instance provided to
testify.Run
- sequential execution (ONLY?)
- if t.Parallel() is used in setup in an attempt to enable parallel/random execution of test cases, data races will undoubtedly occur
- because the provided suite instance is used it is possible to wire in other integrations for assertions, etc...
- more complicated suite aggregation and execution is possible... (see docs)
- all of the testify/assert package goodies are embedded on the suite
- built-in integration in popular editors
- supports suite-level setup and tear-down (integration tests)
github.com/smartystreets/gunit
- employs "fresh" fixtures - uses the suite/fixture instance provided only to know what to instantiate (fresh) for each fixture
- very limited assertion capabilities, in practice used with assertions and assertions/should
- includes an option to run test cases sequentially
- Skip/Focus/Long prefixes modify execution of tests, independent of any editor integration/settings
- weak integration with editors (requiring use of
Focus
prefix for debugging)
References:
- https://github.com/stretchr/testify
- https://github.com/smartystreets/gunit
- https://www.smartystreets.com/blog/2018/07/lets-build-xunit-in-go/
- https://www.smartystreets.com/blog/2018/03/history-of-go-testing/
- http://xunitpatterns.com/Fresh%20Fixture.html
- http://xunitpatterns.com/Shared%20Fixture.html