{"id":23153458,"url":"https://github.com/gunjan5/go-test-driven-development","last_synced_at":"2025-08-17T21:32:45.096Z","repository":{"id":46551090,"uuid":"54225731","full_name":"gunjan5/go-test-driven-development","owner":"gunjan5","description":":hammer: :wrench: Test Driven Development :repeat: with Golang :hamster:","archived":false,"fork":false,"pushed_at":"2017-06-20T20:28:53.000Z","size":151,"stargazers_count":31,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-01T19:46:22.701Z","etag":null,"topics":["benchmark","go","golang","tdd","test","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gunjan5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-18T19:14:15.000Z","updated_at":"2023-02-26T13:08:39.000Z","dependencies_parsed_at":"2022-09-10T17:02:23.254Z","dependency_job_id":null,"html_url":"https://github.com/gunjan5/go-test-driven-development","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gunjan5%2Fgo-test-driven-development","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gunjan5%2Fgo-test-driven-development/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gunjan5%2Fgo-test-driven-development/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gunjan5%2Fgo-test-driven-development/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gunjan5","download_url":"https://codeload.github.com/gunjan5/go-test-driven-development/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230171849,"owners_count":18184461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","go","golang","tdd","test","testing"],"created_at":"2024-12-17T19:33:47.515Z","updated_at":"2024-12-17T19:33:48.011Z","avatar_url":"https://github.com/gunjan5.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :wrench::nut_and_bolt::hammer::repeat:Test Driven Development (TDD) with Go :raised_hands:\nI will be following TDD approach, where I write the test first, and then write the main code to make it pass eventually\n\n### Naming conventions:\n- Test file         : xxx_test.go\n- Test func         : TestXxx\n- Benchmark         : BenchmarkXxx\n- Example           : ExampleXxx\n- Custom Test runner: TestMain\n\n\n\n### Tips:\n- Follow the AAA rule for EACH test\n  - [x] Arrange\n  - [x] Act\n  - [x] Assert (assert only one set of actions)\n- DRY (Don't Repeat Yourself) also applies to Tests \n\n## Notes:\n- `t.Error()` = `t.Log()`+`t.Fail()` //t.Fail() fails the current test but continues with rest of the tests\n- `t.Fatal()` = `t.Log()`+`t.FailNow()` // t.Fatal() and t.FailNow() fails \u0026 stops ALL the tests\n\n### Commands:\n- `go test` //for normal testing in the current dir\n- `go test -v` //for verbose output\n- `go test \u003cpackage_name\u003e` // to test the package\n- `go test -run \u003cfunc_name\u003e` //to run tests only on a specific function instead of the whole file\n- `go test -timeout \u003cduration\u003e` //times out \u0026 panics the test if not finished in the specified timeout i.e. 2s, 1m, etc.\n- `go test -v -short`//Skip some long running tests (Goes with `if testing.Short(){t.Skip(\"Skipping\")}` in the Test func)\n\n### Coverage:\n- `go test -cover` //to see test coverage\n- `go test -coverprofile=coverage.out; go tool cover -html=coverage.out` //this will open a html in browser with showing which lines of code are covered in green (and not covered with red) (sample image below)\n\n![Code coverage html image](https://raw.githubusercontent.com/gunjan5/go-test-driven-development/master/coverage_html.png?token=AFsMeNKyNVWefbQsy2IorN14XmkzgnUSks5W94VSwA%3D%3D)\n\n### Benchmark:\n- `go test -bench .` //run benchmark in the current dir\n- `go test -v -bench .` //verbose\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgunjan5%2Fgo-test-driven-development","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgunjan5%2Fgo-test-driven-development","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgunjan5%2Fgo-test-driven-development/lists"}