{"id":19135896,"url":"https://github.com/sonalys/testit","last_synced_at":"2026-01-02T12:16:10.524Z","repository":{"id":225119602,"uuid":"765130462","full_name":"sonalys/testit","owner":"sonalys","description":"A simple and robust Go test framework","archived":false,"fork":false,"pushed_at":"2024-07-13T08:38:40.000Z","size":48,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T18:48:30.683Z","etag":null,"topics":["framework","go","golang","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/sonalys.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-29T10:41:07.000Z","updated_at":"2024-07-13T08:38:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c436d07-f7b7-412b-8dbc-9507bf5df7c4","html_url":"https://github.com/sonalys/testit","commit_stats":null,"previous_names":["sonalys/testit"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonalys%2Ftestit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonalys%2Ftestit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonalys%2Ftestit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonalys%2Ftestit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonalys","download_url":"https://codeload.github.com/sonalys/testit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249650870,"owners_count":21306083,"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":["framework","go","golang","test","testing"],"created_at":"2024-11-09T06:32:36.372Z","updated_at":"2026-01-02T12:16:10.476Z","avatar_url":"https://github.com/sonalys.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestIt\n\nTestIt is a very simple, but powerful, testing framework.\n\nIt allows you to avoid repetition in the following:\n\n* mock initialization\n* pre-test cleanup\n* panic avoidance\n* test execution\n* assertions\n\nIt also helps you build small blocks that can be re-utilized between test cases without sharing states. Examples:\n\n* Setup a group of expected calls\n* Shared assertions for response fields\n\n## Usage\n\n### tools/tools.go\n\nCreate the tools/tools.go to declare testit as a development only dependency\n\n```go\n//go:build tools\n\npackage tools\n\nimport (\n\t_ \"github.com/sonalys/testit\"\n)\n\n```\n\n### A very simple example:\n\n```go\npackage testit_test\n\nimport (\n\t\"testing\"\n\n\t\"github.com/sonalys/testit\"\n)\n\nfunc Test_Example(t *testing.T) {\n\ttype dependency struct {\n\t\t// mock *mock.Mock // Mocks are automatically initialized\n\t}\n\ttype tc struct{}\n\n\tsetup := testit.SetupWithTestCase(func(t *testit.CHook[dependency, tc]) {\n\t\t// setup, pre-cleanup.\n\t\t// t.Dependencies.mock.EXPECT().DoSomething()\n\t\tt.After = func() {\n\t\t\t// teardown\n\t\t}\n\t})\n\n\twithHook := setup.Hook(func(t *testit.CHook[dependency, tc]) {\n\t\t// additional hook\n\t\tt.After = func() {\n\t\t\t// additional teardown\n\t\t}\n\t})\n\n\tadditionalStep := func(t testit.DCTest[dependency, tc]) {}\n\n\ttestfunc := func() (int, error) {\n\t\treturn 0, nil\n\t}\n\n\tt.Run(\"example\", withHook.Case(tc{},\n\t\t// any additional steps can be added manually as well.\n\t\tadditionalStep,\n\t\tfunc(t testit.DCTest[dependency, tc]) {\n\t\t\t// test execution\n\t\t\tvar err error\n\t\t\tt.NoError(err)\n\t\t\tt.FailNow(\"failing test\")\n\n\t\t\tvalue := testit.NoErr(testfunc())\n\t\t\tt.Equal(0, value)\n\t\t},\n\t))\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonalys%2Ftestit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonalys%2Ftestit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonalys%2Ftestit/lists"}