Golang Testing

TestMain function in any test files will always be cal by go test

func TestMain(m *testing.M) {
    setupDatabase()
    result := m.Run()
    teardownDatabase()
    os.Exit(result)
}

Any function that starts with Test is going to get run by Go’s testing harness.

Testing in Go https://blog.codeship.com/testing-in-go/

Testing Web Apps from End-to-End in Go http://nerdyc.com/blog/2016/06/16/testing-web-apps-end-to-end-in-go/

Building and Testing a REST API in GoLang using Gorilla Mux and MySQL http://bit.ly/2B99EqV

Building and Testing a REST API in Go with Gorilla Mux and PostgreSQL http://bit.ly/2j4nNSs

https://github.com/nerdyc/testable-golang-web-service