{"id":16105806,"url":"https://github.com/devlights/go-external-test-package-example","last_synced_at":"2025-04-06T03:13:20.896Z","repository":{"id":56495392,"uuid":"309876589","full_name":"devlights/go-external-test-package-example","owner":"devlights","description":"This is example using golang external test package.","archived":false,"fork":false,"pushed_at":"2020-11-04T08:06:15.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-12T08:58:27.009Z","etag":null,"topics":["go","golang","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/devlights.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":"2020-11-04T03:47:14.000Z","updated_at":"2020-11-04T08:06:17.000Z","dependencies_parsed_at":"2022-08-15T19:50:29.041Z","dependency_job_id":null,"html_url":"https://github.com/devlights/go-external-test-package-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlights%2Fgo-external-test-package-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlights%2Fgo-external-test-package-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlights%2Fgo-external-test-package-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlights%2Fgo-external-test-package-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devlights","download_url":"https://codeload.github.com/devlights/go-external-test-package-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427012,"owners_count":20937214,"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":["go","golang","testing"],"created_at":"2024-10-09T19:10:41.818Z","updated_at":"2025-04-06T03:13:20.875Z","avatar_url":"https://github.com/devlights.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-external-test-package-example\nThis is example using golang external test package.\n\n[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/devlights/go-external-test-package-example)\n\n## internal and external tests\n\nThe following tests exist in the hello package (internal test package):\n\n- pkg/hello/hello_test.go\n  - TestMakeMessage\n\nThe following tests exist in the hello_test package (external test package):\n\n- pkg/hello/hello_external_test.go\n  - TestSay\n\n## run\n\n```sh\n$ go test -v -cover ./...\n=== RUN   TestMakeMessage\n=== RUN   TestMakeMessage/not_empty\n=== RUN   TestMakeMessage/empty\n--- PASS: TestMakeMessage (0.00s)\n    --- PASS: TestMakeMessage/not_empty (0.00s)\n    --- PASS: TestMakeMessage/empty (0.00s)\n=== RUN   TestSay\n=== RUN   TestSay/not_empty\n=== RUN   TestSay/empty\n--- PASS: TestSay (0.00s)\n    --- PASS: TestSay/not_empty (0.00s)\n    --- PASS: TestSay/empty (0.00s)\n=== RUN   ExampleSay\n--- PASS: ExampleSay (0.00s)\nPASS\ncoverage: 100.0% of statements\nok      github.com/devlights/go-external-test-package-example/pkg/hello 0.004s  coverage: 100.0% of statements\n```\n\n## doc\n\n```sh\n$ go doc -all ./pkg/hello/\npackage hello // import \"github.com/devlights/go-external-test-package-example/pkg/hello\"\n\nPackage hello contains functions to make greeing message.\n\nFUNCTIONS\n\nfunc Say(message string) string\n    Say makes the greeting message.\n\n    if parameter is empty, return empty.\n\n```\n\n## go list\n\n### Build targets\n\n```sh\n$ go list -f={{.GoFiles}} ./pkg/hello/\n[doc.go hello.go]\n```\n\n### Test targets in same package\n\n```sh\n$ go list -f={{.TestGoFiles}} ./pkg/hello/\n[hello_test.go]\n```\n\n### Test targets in external test package\n\n```sh\n$ go list -f={{.XTestGoFiles}} ./pkg/hello/\n[hello_external_test.go]\n```\n\n## references\n\n- 書籍「プログラミング言語Go」第11章 テスト\n  - ここに外部テストパッケージの件も含めて記載されています\n- [外部テストパッケージの利用ケース](https://qiita.com/hogedigo/items/5f491994647aa4a8a905)\n- [5 advanced testing techniques in Go](https://segment.com/blog/5-advanced-testing-techniques-in-go/)\n- [Go Fridayこぼれ話：非公開（unexported）な機能を使ったテスト](https://engineering.mercari.com/blog/entry/2018-08-08-080000/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlights%2Fgo-external-test-package-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevlights%2Fgo-external-test-package-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlights%2Fgo-external-test-package-example/lists"}