{"id":17993931,"url":"https://github.com/jimeh/go-mocktesting","last_synced_at":"2025-04-04T05:14:00.277Z","repository":{"id":45995742,"uuid":"428470777","full_name":"jimeh/go-mocktesting","owner":"jimeh","description":"Go package that mocks *testing.T for the purpose of testing test helpers.","archived":false,"fork":false,"pushed_at":"2021-11-22T03:23:52.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T00:09:55.012Z","etag":null,"topics":["go","go-testing","golang","golang-package","mock","test-helper","testing"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/jimeh/go-mocktesting","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/jimeh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-11-16T00:58:09.000Z","updated_at":"2021-11-22T03:23:51.000Z","dependencies_parsed_at":"2022-09-26T20:21:16.766Z","dependency_job_id":null,"html_url":"https://github.com/jimeh/go-mocktesting","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-mocktesting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-mocktesting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-mocktesting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-mocktesting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimeh","download_url":"https://codeload.github.com/jimeh/go-mocktesting/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123087,"owners_count":20887261,"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","go-testing","golang","golang-package","mock","test-helper","testing"],"created_at":"2024-10-29T20:13:30.319Z","updated_at":"2025-04-04T05:14:00.248Z","avatar_url":"https://github.com/jimeh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  go-mocktesting\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e\n    Mock *testing.T for the purpose of testing test helpers.\n  \u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/jimeh/go-mocktesting\"\u003e\u003cimg src=\"https://img.shields.io/badge/%E2%80%8B-reference-387b97.svg?logo=go\u0026logoColor=white\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-mocktesting/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/jimeh/go-mocktesting?label=release\" alt=\"GitHub tag (latest SemVer)\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-mocktesting/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/workflow/status/jimeh/go-mocktesting/CI.svg?logo=github\" alt=\"Actions Status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codeclimate.com/github/jimeh/go-mocktesting\"\u003e\u003cimg src=\"https://img.shields.io/codeclimate/coverage/jimeh/go-mocktesting.svg?logo=code%20climate\" alt=\"Coverage\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-mocktesting/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-raw/jimeh/go-mocktesting.svg?style=flat\u0026logo=github\u0026logoColor=white\" alt=\"GitHub issues\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-mocktesting/pulls\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-pr-raw/jimeh/go-mocktesting.svg?style=flat\u0026logo=github\u0026logoColor=white\" alt=\"GitHub pull requests\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-mocktesting/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/jimeh/go-mocktesting.svg?style=flat\" alt=\"License Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Import\n\n```go\nimport \"github.com/jimeh/go-mocktesting\"\n```\n\n## Usage\n\n```go\nfunc ExampleT_Error() {\n\tassertTrue := func(t testing.TB, v bool) {\n\t\tif v != true {\n\t\t\tt.Error(\"expected false to be true\")\n\t\t}\n\t}\n\n\tmt := mocktesting.NewT(\"TestMyBoolean1\")\n\tassertTrue(mt, true)\n\tfmt.Printf(\"Name: %s\\n\", mt.Name())\n\tfmt.Printf(\"Failed: %+v\\n\", mt.Failed())\n\tfmt.Printf(\"Aborted: %+v\\n\", mt.Aborted())\n\n\tmt = mocktesting.NewT(\"TestMyBoolean2\")\n\tassertTrue(mt, false)\n\tfmt.Printf(\"Name: %s\\n\", mt.Name())\n\tfmt.Printf(\"Failed: %+v\\n\", mt.Failed())\n\tfmt.Printf(\"Aborted: %+v\\n\", mt.Aborted())\n\tfmt.Printf(\"Output: %s\\n\", strings.Join(mt.Output(), \"\"))\n\n\t// Output:\n\t// Name: TestMyBoolean1\n\t// Failed: false\n\t// Aborted: false\n\t// Name: TestMyBoolean2\n\t// Failed: true\n\t// Aborted: false\n\t// Output: expected false to be true\n}\n```\n\n```go\nfunc ExampleT_Fatal() {\n\trequireTrue := func(t testing.TB, v bool) {\n\t\tif v != true {\n\t\t\tt.Fatal(\"expected false to be true\")\n\t\t}\n\t}\n\n\tmt := mocktesting.NewT(\"TestMyBoolean1\")\n\tfmt.Printf(\"Name: %s\\n\", mt.Name())\n\trequireTrue(mt, true)\n\tfmt.Printf(\"Failed: %+v\\n\", mt.Failed())\n\tfmt.Printf(\"Aborted: %+v\\n\", mt.Aborted())\n\n\tmt = mocktesting.NewT(\"TestMyBoolean2\")\n\tfmt.Printf(\"Name: %s\\n\", mt.Name())\n\tmocktesting.Go(func() {\n\t\trequireTrue(mt, false)\n\t\tfmt.Println(\"This is never executed.\")\n\t})\n\tfmt.Printf(\"Failed: %+v\\n\", mt.Failed())\n\tfmt.Printf(\"Aborted: %+v\\n\", mt.Aborted())\n\tfmt.Printf(\"Output:\\n  - %s\\n\", strings.Join(mt.Output(), \"\\n  - \"))\n\n\t// Output:\n\t// Name: TestMyBoolean1\n\t// Failed: false\n\t// Aborted: false\n\t// Name: TestMyBoolean2\n\t// Failed: true\n\t// Aborted: true\n\t// Output:\n\t//   - expected false to be true\n}\n```\n\n```go\nfunc ExampleT_Run() {\n\trequireTrue := func(t testing.TB, v bool) {\n\t\tif v != true {\n\t\t\tt.Fatal(\"expected false to be true\")\n\t\t}\n\t}\n\n\tmt := mocktesting.NewT(\"TestMyBoolean\")\n\tfmt.Printf(\"Name: %s\\n\", mt.Name())\n\tmt.Run(\"true\", func(t testing.TB) {\n\t\trequireTrue(t, true)\n\t})\n\tfmt.Printf(\"Failed: %+v\\n\", mt.Failed())\n\tfmt.Printf(\"Sub1-Name: %s\\n\", mt.Subtests()[0].Name())\n\tfmt.Printf(\"Sub1-Failed: %+v\\n\", mt.Subtests()[0].Failed())\n\tfmt.Printf(\"Sub1-Aborted: %+v\\n\", mt.Subtests()[0].Aborted())\n\n\tmt.Run(\"false\", func(t testing.TB) {\n\t\trequireTrue(t, false)\n\t\tfmt.Println(\"This is never executed.\")\n\t})\n\tfmt.Printf(\"Failed: %+v\\n\", mt.Failed())\n\tfmt.Printf(\"Sub2-Name: %s\\n\", mt.Subtests()[1].Name())\n\tfmt.Printf(\"Sub2-Failed: %+v\\n\", mt.Subtests()[1].Failed())\n\tfmt.Printf(\"Sub2-Aborted: %+v\\n\", mt.Subtests()[1].Aborted())\n\tfmt.Printf(\"Sub2-Output:\\n  - %s\\n\",\n\t\tstrings.Join(mt.Subtests()[1].Output(), \"\\n  - \"),\n\t)\n\n\t// Output:\n\t// Name: TestMyBoolean\n\t// Failed: false\n\t// Sub1-Name: TestMyBoolean/true\n\t// Sub1-Failed: false\n\t// Sub1-Aborted: false\n\t// Failed: true\n\t// Sub2-Name: TestMyBoolean/false\n\t// Sub2-Failed: true\n\t// Sub2-Aborted: true\n\t// Sub2-Output:\n\t//   - expected false to be true\n}\n```\n\n## Documentation\n\nPlease see the\n[Go Reference](https://pkg.go.dev/github.com/jimeh/go-mocktesting#section-documentation)\nfor documentation and examples.\n\n## License\n\n[MIT](https://github.com/jimeh/go-mocktesting/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimeh%2Fgo-mocktesting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimeh%2Fgo-mocktesting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimeh%2Fgo-mocktesting/lists"}