Example
write basic fundamental testing in Golang
$ go mod download || go get .
- 01_testing write testing
- 02_testing write testing using testify
- 03_testing write API testing using testify
- 04_testing write API testing using gin framework, testify and go supertest
- 05_testing write testing using ginkgo bdd testing framework
- 06_testing write testing using gin framework and ginkgo bdd testing framework
You must set up like this before you run testing using ginkgo, because this is bootstrapping for your test in single file not each every file, if you create new test you must need code like this again with difference name method.
func TestCalculate(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Calculate Suite")
}
- BeforeEach: run code every test is execute
- AfterEach: run code after every test is execute done
- BeforeSuite: run code before all test is execute
- AfterSuite: run code after all test is execute done
More about functionality in ginkgo check here
$ make test || go test -v ./...
$ make coverage || go test -cover -v ./... || go test -coverprofile=coverage.out ./... || go tool cover -func=coverage.out
$ make ginkgo || go test -v || ginkgo -v