{"id":13413883,"url":"https://github.com/franela/goblin","last_synced_at":"2025-03-14T20:30:41.902Z","repository":{"id":10696375,"uuid":"12939346","full_name":"franela/goblin","owner":"franela","description":"Minimal and Beautiful Go testing framework","archived":false,"fork":false,"pushed_at":"2022-12-22T11:02:03.000Z","size":299,"stargazers_count":889,"open_issues_count":21,"forks_count":76,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-10T02:57:54.914Z","etag":null,"topics":[],"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/franela.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":"2013-09-19T02:34:24.000Z","updated_at":"2025-02-23T16:55:25.000Z","dependencies_parsed_at":"2022-08-07T06:00:22.014Z","dependency_job_id":null,"html_url":"https://github.com/franela/goblin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franela%2Fgoblin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franela%2Fgoblin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franela%2Fgoblin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franela%2Fgoblin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franela","download_url":"https://codeload.github.com/franela/goblin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243641964,"owners_count":20323940,"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":[],"created_at":"2024-07-30T20:01:51.906Z","updated_at":"2025-03-14T20:30:41.881Z","avatar_url":"https://github.com/franela.png","language":"Go","readme":"Goblin\n======\n\n[![Build Status](https://travis-ci.org/franela/goblin.svg)](https://travis-ci.org/franela/goblin)\n[![Go Reportcard](https://goreportcard.com/badge/github.com/franela/goblin)](https://goreportcard.com/report/github.com/franela/goblin)\n[![GoDoc](https://godoc.org/github.com/franela/goblin?status.svg)](https://godoc.org/github.com/franela/goblin)\n[![License](https://img.shields.io/github/license/franela/goblin.svg)](https://github.com/franela/goblin/blob/master/LICENSE.md)\n[![Release](https://img.shields.io/github/release/franela/goblin.svg)](https://github.com/franela/goblin/releases/latest)\n\n\nA [Mocha](http://mochajs.org/) like BDD testing framework written in Go that requires no additional dependencies. Requires no extensive documentation nor complicated steps to get it running.\n\n![](https://github.com/marcosnils/goblin/blob/master/goblin_logo.jpg?raw=true)\n\nWhy Goblin?\n-----------\n\nInspired by the flexibility and simplicity of Node BDD and frustrated by the\nrigorousness of Go way of testing, we wanted to bring a new tool to\nwrite self-describing and comprehensive code.\n\n\n\nWhat do I get with it?\n----------------------\n\n- Run tests as usual with `go test`\n- Colorful reports and beautiful syntax\n- Preserve the exact same syntax and behaviour as Node's Mocha\n- Nest as many `Describe` and `It` blocks as you want\n- Use `Before`, `BeforeEach`, `After` and `AfterEach` for setup and teardown your tests\n- No need to remember confusing parameters in `Describe` and `It` blocks\n- Use a declarative and expressive language to write your tests\n- Plug different assertion libraries\n - [Gomega](https://github.com/onsi/gomega) (supported so far)\n- Skip your tests the same way as you would do in Mocha\n- Automatic terminal support for colored outputs\n- Two line setup is all you need to get up running\n\n\n\nHow do I use it?\n----------------\n\nSince ```go test``` is not currently extensive, you will have to hook Goblin to it. You do that by\nadding a single test method in your test file. All your goblin tests will be implemented inside this function.\n\n```go\npackage foobar\n\nimport (\n    \"testing\"\n    . \"github.com/franela/goblin\"\n)\n\nfunc Test(t *testing.T) {\n    g := Goblin(t)\n    g.Describe(\"Numbers\", func() {\n        // Passing Test\n        g.It(\"Should add two numbers \", func() {\n            g.Assert(1+1).Equal(2)\n        })\n        // Failing Test\n        g.It(\"Should match equal numbers\", func() {\n            g.Assert(2).Equal(4)\n        })\n        // Pending Test\n        g.It(\"Should substract two numbers\")\n        // Excluded Test\n        g.Xit(\"Should add two numbers \", func() {\n            g.Assert(3+1).Equal(4)\n        })\n    })\n}\n```\n\nOuput will be something like:\n\n![](https://github.com/marcosnils/goblin/blob/master/goblin_output.png?raw=true)\n\nNice and easy, right?\n\nCan I do asynchronous tests?\n----------------------------\n\nYes! Goblin will help you to test asynchronous things, like goroutines, etc. You just need to add a ```done``` parameter to the handler function of your ```It```. This handler function should be called when your test passes.\n\n```go\n  ...\n  g.Describe(\"Numbers\", func() {\n      g.It(\"Should add two numbers asynchronously\", func(done Done) {\n          go func() {\n              g.Assert(1+1).Equal(2)\n              done()\n          }()\n      })\n  })\n  ...\n```\n\nGoblin will wait for the ```done``` call, a ```Fail``` call or any false assertion.\n\nHow do I use it with Gomega?\n----------------------------\n\nGomega is a nice assertion framework. But it doesn't provide a nice way to hook it to testing frameworks. It should just panic instead of requiring a fail function. There is an issue about that [here](https://github.com/onsi/gomega/issues/5).\nWhile this is being discussed and hopefully fixed, the way to use Gomega with Goblin is:\n\n```go\npackage foobar\n\nimport (\n    \"testing\"\n    goblin \"github.com/franela/goblin\"\n    . \"github.com/onsi/gomega\"\n)\n\nfunc Test(t *testing.T) {\n    g := goblin.Goblin(t)\n\n    //special hook for gomega\n    RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })\n\n    g.Describe(\"lala\", func() {\n        g.It(\"lslslslsls\", func() {\n            Expect(1).To(Equal(10))\n        })\n    })\n}\n```\n\n\nFAQ\n----\n\n### How do I run specific tests?\n\nIf `-goblin.run=$REGES` is supplied to the `go test` command then only tests that match the supplied regex will run\n\n\nContributing\n-----\n\nWe do have a couple of [issues](https://github.com/franela/goblin/issues) pending.  Feel free to contribute and send us PRs (with tests please :smile:).\n\nSpecial Thanks\n------------\n\nSpecial thanks to [Leandro Reox](https://github.com/leandroreox) (Leitan) for the goblin logo.\n","funding_links":[],"categories":["测试相关","开源类库","Links Úteis","Testing","Misc","Open source library","Go","测试","Template Engines","\u003cspan id=\"测试-testing\"\u003e测试 Testing\u003c/span\u003e","测试相关`测试库和测试数据集生成库`","Testing Frameworks"],"sub_categories":["查询语","测试","Em Português","Advanced Console UIs","Testing Frameworks","HTTP Clients","Test","交流","HTTP客户端","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranela%2Fgoblin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranela%2Fgoblin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranela%2Fgoblin/lists"}