Interestingly, the advent of subtests in the testing package makes it possible to implement a reflection-based test runner that achieves proper partitioning of test cases with absolutely no breaking changes to the existing API. This runner makes the gunit command unnecessary (but it will still hang around for a while) and so we no longer need to put the go generate compiler directive in our code or run go generate for any reason related to testing.
Here's an example of how to use it:
package stuff
import (
"testing"
"github.com/smartystreets/assertions/should"
"github.com/smartystreets/gunit"
)
func TestStuff(t *testing.T) { // This function is the new boilerplate. Not too bad.
gunit.Run(new(StuffFixture), t)
}
type StuffFixture struct {
*gunit.Fixture
}
...
Just run go test -v in the samples and you'll see it in action.
Interestingly, the advent of subtests in the testing package makes it possible to implement a reflection-based test runner that achieves proper partitioning of test cases with absolutely no breaking changes to the existing API. This runner makes the
gunit
command unnecessary (but it will still hang around for a while) and so we no longer need to put thego generate
compiler directive in our code or run go generate for any reason related to testing.Here's an example of how to use it:
Just run
go test -v
in the samples and you'll see it in action.The only downside right now is that the Go Intellij Plugin doesn't yet support displaying subtests in the test report window. So, this PR is, for all intents and purposes, blocked by that issue (which may be blocked on
go test
getting a -json flag).