https://github.com/restuwahyu13/golang-testing-fundamental
Example basic fundamental testing in golang
https://github.com/restuwahyu13/golang-testing-fundamental
golang tdd testing unit-testing
Last synced: 11 days ago
JSON representation
Example basic fundamental testing in golang
- Host: GitHub
- URL: https://github.com/restuwahyu13/golang-testing-fundamental
- Owner: restuwahyu13
- Created: 2021-10-08T16:42:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-09T14:21:33.000Z (over 3 years ago)
- Last Synced: 2025-05-07T04:42:46.959Z (11 days ago)
- Topics: golang, tdd, testing, unit-testing
- Language: Go
- Homepage:
- Size: 293 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Golang Fundamental Testing
`Example` write basic fundamental testing in Golang
## Installation
```sh
$ go mod download || go get .
```## Implementation Case
- **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## Rule Using Ginkgo
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.
```go
func TestCalculate(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Calculate Suite")
}
```## Rule Ginkgo Hooks
- **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 doneMore about functionality in ginkgo check [here](https://github.com/onsi/ginkgo/blob/ver2/docs/index.md)
## Command
- ### Testing
```sh
$ make test || go test -v ./...
```- ### Coverage Testing
```sh
$ make coverage || go test -cover -v ./... || go test -coverprofile=coverage.out ./... || go tool cover -func=coverage.out
```- ### Ginkgo Testing
```sh
$ make ginkgo || go test -v || ginkgo -v
```## Testing And Coverage Testing Result
![]()
![]()