package
0.5.0
Repository: https://github.com/marcusljx/go-utils.git
Documentation: pkg.go.dev

# README

gest

SetUp + TearDown for standard go tests. Allows for before-after wrapping of test cases without having to move away from standard golang test development (a la testify Suite)

Usage

Apply the following in your test package's TestMain:

func TestMain(m *testing.M) {
  code := gest.New("MyTestSuite").
    TestSetUp(setUpFunc).
    TestTearDown(tearDownFunc).
    Run(m)
    
  os.Exit(code)
}

func setUpFunc(t *testing.T) {
  // Do set up here...
}

func tearDownFunc(t *testing.T) {
  // Do tear down here...
}

Supported Builders

Each new gest Suite supports the following:

  • TestSetUp
  • TestTearDown
  • BenchmarkSetUp (runs on every iteration, not a general "before whole case") // See TODO
  • BenchmarkTearDown (runs on every iteration, not a general "after whole case") // See TODO
  • ExampleSetUp
  • ExampleTearDown
  • BenchmarkCaseSetUp
  • BenchmarkCaseTearDown

TODO

  • Test/Benchmark/Example Function name injection into setup/teardown methods (breaks API)