[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4692":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":31,"readmeContent":32,"aiSummary":33,"trendingCount":16,"starSnapshotCount":16,"syncStatus":34,"lastSyncTime":35,"discoverSource":36},4692,"testify","stretchr\u002Ftestify","stretchr","A toolkit with common assertions and mocks that plays nicely with the standard library","https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify",null,"Go",26017,1725,170,233,0,12,62,6,44.71,"MIT License",false,"master",[25,26,27,28,5,29,30],"assertions","go","golang","mocking","testing","toolkit","2026-06-12 02:01:03","Testify - Thou Shalt Write Tests\n================================\n\n> [!NOTE]\n> Testify is being maintained at v1, no breaking changes will be accepted in this repo.  \n> [See discussion about v2](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fdiscussions\u002F1560).\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Factions\u002Fworkflows\u002Fmain.yml\u002Fbadge.svg?branch=master)](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Factions\u002Fworkflows\u002Fmain.yml) [![Go Report Card](https:\u002F\u002Fgoreportcard.com\u002Fbadge\u002Fgithub.com\u002Fstretchr\u002Ftestify)](https:\u002F\u002Fgoreportcard.com\u002Freport\u002Fgithub.com\u002Fstretchr\u002Ftestify) [![PkgGoDev](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fgithub.com\u002Fstretchr\u002Ftestify)](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify)\n\nGo code (golang) set of packages that provide many tools for testifying that your code will behave as you intend.\n\nFeatures include:\n\n  * [Easy assertions](#assert-package)\n  * [Mocking](#mock-package)\n  * [Testing suite interfaces and functions](#suite-package)\n\nGet started:\n\n  * Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date)\n  * For an introduction to writing test code in Go, see https:\u002F\u002Fgo.dev\u002Fdoc\u002Fcode#Testing\n  * Check out the API Documentation https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\n  * Use [testifylint](https:\u002F\u002Fgithub.com\u002FAntonboom\u002Ftestifylint) (via [golangci-lint](https:\u002F\u002Fgolangci-lint.run\u002F)) to avoid common mistakes\n  * A little about [Test-Driven Development (TDD)](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FTest-driven_development)\n\n[`assert`](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fassert \"API documentation\") package\n-------------------------------------------------------------------------------------------\n\nThe `assert` package provides some helpful methods that allow you to write better test code in Go.\n\n  * Prints friendly, easy to read failure descriptions\n  * Allows for very readable code\n  * Optionally annotate each assertion with a message\n\nSee it in action:\n\n```go\npackage yours\n\nimport (\n\t\"testing\"\n\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n)\n\nfunc TestSomething(t *testing.T) {\n\t\u002F\u002F assert equality\n\tassert.Equal(t, 123, 123, \"they should be equal\")\n\n\t\u002F\u002F assert inequality\n\tassert.NotEqual(t, 123, 456, \"they should not be equal\")\n\n\t\u002F\u002F assert for nil (good for errors)\n\tassert.Nil(t, object)\n\n\t\u002F\u002F assert for not nil (good when you expect something)\n\tif assert.NotNil(t, object) {\n\t\t\u002F\u002F now we know that object isn't nil, we are safe to make\n\t\t\u002F\u002F further assertions without causing any errors\n\t\tassert.Equal(t, \"Something\", object.Value)\n\t}\n}\n```\n\n  * Every assert func takes the `testing.T` object as the first argument.  This is how it writes the errors out through the normal `go test` capabilities.\n  * Every assert func returns a bool indicating whether the assertion was successful or not, this is useful for if you want to go on making further assertions under certain conditions.\n\nif you assert many times, use the below:\n\n```go\npackage yours\n\nimport (\n\t\"testing\"\n\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n)\n\nfunc TestSomething(t *testing.T) {\n\tassert := assert.New(t)\n\n\t\u002F\u002F assert equality\n\tassert.Equal(123, 123, \"they should be equal\")\n\n\t\u002F\u002F assert inequality\n\tassert.NotEqual(123, 456, \"they should not be equal\")\n\n\t\u002F\u002F assert for nil (good for errors)\n\tassert.Nil(object)\n\n\t\u002F\u002F assert for not nil (good when you expect something)\n\tif assert.NotNil(object) {\n\t\t\u002F\u002F now we know that object isn't nil, we are safe to make\n\t\t\u002F\u002F further assertions without causing any errors\n\t\tassert.Equal(\"Something\", object.Value)\n\t}\n}\n```\n\n[`require`](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Frequire \"API documentation\") package\n---------------------------------------------------------------------------------------------\n\nThe `require` package provides same global functions as the `assert` package, but instead of returning a boolean result they terminate current test.\nThese functions must be called from the goroutine running the test or benchmark function, not from other goroutines created during the test.\nOtherwise race conditions may occur.\n\nSee [t.FailNow](https:\u002F\u002Fpkg.go.dev\u002Ftesting#T.FailNow) for details.\n\n[`mock`](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fmock \"API documentation\") package\n----------------------------------------------------------------------------------------\n\nThe `mock` package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code.\n\nAn example test function that tests a piece of code that relies on an external object `testObj`, can set up expectations (testify) and assert that they indeed happened:\n\n```go\npackage yours\n\nimport (\n\t\"testing\"\n\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fmock\"\n)\n\n\u002F*\n  Test objects\n*\u002F\n\n\u002F\u002F MyMockedObject is a mocked object that implements an interface\n\u002F\u002F that describes an object that the code I am testing relies on.\ntype MyMockedObject struct {\n\tmock.Mock\n}\n\n\u002F\u002F DoSomething is a method on MyMockedObject that implements some interface\n\u002F\u002F and just records the activity, and returns what the Mock object tells it to.\n\u002F\u002F\n\u002F\u002F In the real object, this method would do something useful, but since this\n\u002F\u002F is a mocked object - we're just going to stub it out.\n\u002F\u002F\n\u002F\u002F NOTE: This method is not being tested here, code that uses this object is.\nfunc (m *MyMockedObject) DoSomething(number int) (bool, error) {\n\targs := m.Called(number)\n\treturn args.Bool(0), args.Error(1)\n}\n\n\u002F*\n  Actual test functions\n*\u002F\n\n\u002F\u002F TestSomething is an example of how to use our test object to\n\u002F\u002F make assertions about some target code we are testing.\nfunc TestSomething(t *testing.T) {\n\t\u002F\u002F create an instance of our test object\n\ttestObj := new(MyMockedObject)\n\n\t\u002F\u002F set up expectations\n\ttestObj.On(\"DoSomething\", 123).Return(true, nil)\n\n\t\u002F\u002F call the code we are testing\n\ttargetFuncThatDoesSomethingWithObj(testObj)\n\n\t\u002F\u002F assert that the expectations were met\n\ttestObj.AssertExpectations(t)\n}\n\n\u002F\u002F TestSomethingWithPlaceholder is a second example of how to use our test object to\n\u002F\u002F make assertions about some target code we are testing.\n\u002F\u002F This time using a placeholder. Placeholders might be used when the\n\u002F\u002F data being passed in is normally dynamically generated and cannot be\n\u002F\u002F predicted beforehand (eg. containing hashes that are time sensitive)\nfunc TestSomethingWithPlaceholder(t *testing.T) {\n\t\u002F\u002F create an instance of our test object\n\ttestObj := new(MyMockedObject)\n\n\t\u002F\u002F set up expectations with a placeholder in the argument list\n\ttestObj.On(\"DoSomething\", mock.Anything).Return(true, nil)\n\n\t\u002F\u002F call the code we are testing\n\ttargetFuncThatDoesSomethingWithObj(testObj)\n\n\t\u002F\u002F assert that the expectations were met\n\ttestObj.AssertExpectations(t)\n\n}\n\n\u002F\u002F TestSomethingElse2 is a third example that shows how you can use\n\u002F\u002F the Unset method to cleanup handlers and then add new ones.\nfunc TestSomethingElse2(t *testing.T) {\n\t\u002F\u002F create an instance of our test object\n\ttestObj := new(MyMockedObject)\n\n\t\u002F\u002F set up expectations with a placeholder in the argument list\n\tmockCall := testObj.On(\"DoSomething\", mock.Anything).Return(true, nil)\n\n\t\u002F\u002F call the code we are testing\n\ttargetFuncThatDoesSomethingWithObj(testObj)\n\n\t\u002F\u002F assert that the expectations were met\n\ttestObj.AssertExpectations(t)\n\n\t\u002F\u002F remove the handler now so we can add another one that takes precedence\n\tmockCall.Unset()\n\n\t\u002F\u002F return false now instead of true\n\ttestObj.On(\"DoSomething\", mock.Anything).Return(false, nil)\n\n\ttestObj.AssertExpectations(t)\n}\n```\n\nFor more information on how to write mock code, check out the [API documentation for the `mock` package](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fmock).\n\nYou can use the [mockery tool](https:\u002F\u002Fvektra.github.io\u002Fmockery\u002Flatest\u002F) to autogenerate the mock code against an interface as well, making using mocks much quicker.\n\n[`suite`](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fsuite \"API documentation\") package\n-----------------------------------------------------------------------------------------\n> [!WARNING]\n> The suite package does not support parallel tests. See [#934](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fissues\u002F934).\n\nThe `suite` package provides functionality that you might be used to from more common object-oriented languages.  With it, you can build a testing suite as a struct, build setup\u002Fteardown methods and testing methods on your struct, and run them with 'go test' as per normal.\n\nAn example suite is shown below:\n\n```go\n\u002F\u002F Basic imports\nimport (\n\t\"testing\"\n\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fsuite\"\n)\n\n\u002F\u002F Define the suite, and absorb the built-in basic suite\n\u002F\u002F functionality from testify - including a T() method which\n\u002F\u002F returns the current testing context\ntype ExampleTestSuite struct {\n\tsuite.Suite\n\tVariableThatShouldStartAtFive int\n}\n\n\u002F\u002F Make sure that VariableThatShouldStartAtFive is set to five\n\u002F\u002F before each test\nfunc (suite *ExampleTestSuite) SetupTest() {\n\tsuite.VariableThatShouldStartAtFive = 5\n}\n\n\u002F\u002F All methods that begin with \"Test\" are run as tests within a\n\u002F\u002F suite.\nfunc (suite *ExampleTestSuite) TestExample() {\n\tassert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive)\n}\n\n\u002F\u002F In order for 'go test' to run this suite, we need to create\n\u002F\u002F a normal test function and pass our suite to suite.Run\nfunc TestExampleTestSuite(t *testing.T) {\n\tsuite.Run(t, new(ExampleTestSuite))\n}\n```\n\nFor a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fblob\u002Fmaster\u002Fsuite\u002Fsuite_test.go)\n\nFor more information on writing suites, check out the [API documentation for the `suite` package](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fsuite).\n\n`Suite` object has assertion methods:\n\n```go\n\u002F\u002F Basic imports\nimport (\n\t\"testing\"\n\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fsuite\"\n)\n\n\u002F\u002F Define the suite, and absorb the built-in basic suite\n\u002F\u002F functionality from testify - including assertion methods.\ntype ExampleTestSuite struct {\n\tsuite.Suite\n\tVariableThatShouldStartAtFive int\n}\n\n\u002F\u002F Make sure that VariableThatShouldStartAtFive is set to five\n\u002F\u002F before each test\nfunc (suite *ExampleTestSuite) SetupTest() {\n\tsuite.VariableThatShouldStartAtFive = 5\n}\n\n\u002F\u002F All methods that begin with \"Test\" are run as tests within a\n\u002F\u002F suite.\nfunc (suite *ExampleTestSuite) TestExample() {\n\tsuite.Equal(suite.VariableThatShouldStartAtFive, 5)\n}\n\n\u002F\u002F In order for 'go test' to run this suite, we need to create\n\u002F\u002F a normal test function and pass our suite to suite.Run\nfunc TestExampleTestSuite(t *testing.T) {\n\tsuite.Run(t, new(ExampleTestSuite))\n}\n```\n\n------\n\nInstallation\n============\n\nTo install Testify, use `go get`:\n\n    go get github.com\u002Fstretchr\u002Ftestify\n\nThis will then make the following packages available to you:\n\n    github.com\u002Fstretchr\u002Ftestify\u002Fassert\n    github.com\u002Fstretchr\u002Ftestify\u002Frequire\n    github.com\u002Fstretchr\u002Ftestify\u002Fmock\n    github.com\u002Fstretchr\u002Ftestify\u002Fsuite\n    github.com\u002Fstretchr\u002Ftestify\u002Fhttp (deprecated)\n\nImport the `testify\u002Fassert` package into your code using this template:\n\n```go\npackage yours\n\nimport (\n\t\"testing\"\n\n\t\"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n)\n\nfunc TestSomething(t *testing.T) {\n\tassert.True(t, true, \"True is true!\")\n}\n```\n\n------\n\nStaying up to date\n==================\n\nTo update Testify to the latest version, use `go get -u github.com\u002Fstretchr\u002Ftestify`.\n\n------\n\nSupported go versions\n==================\n\nWe currently support the most recent major Go versions from 1.19 onward.\n\n------\n\nContributing\n============\n\nPlease feel free to submit issues, fork the repository and send pull requests!\n\nWhen submitting an issue, we ask that you please include a complete test function that demonstrates the issue. Extra credit for those using Testify to write the test code that demonstrates it.\n\nCode generation is used. [Look for `Code generated with`](https:\u002F\u002Fgithub.com\u002Fsearch?q=repo%3Astretchr%2Ftestify%20%22Code%20generated%20with%22&type=code) at the top of some files. Run `go generate .\u002F...` to update generated files.\n\nWe also chat on the [Gophers Slack](https:\u002F\u002Fgophers.slack.com) group in the `#testify` and `#testify-dev` channels.\n\n------\n\nLicense\n=======\n\nThis project is licensed under the terms of the MIT license.\n","stretchr\u002Ftestify 是一个专为 Go 语言设计的测试工具包，提供了丰富的断言和模拟功能。它包括易于使用的断言方法、强大的模拟支持以及测试套件接口与函数，这些特性使得开发者能够编写出更清晰且可靠的测试代码。该库与 Go 的标准库无缝集成，特别适合于需要进行单元测试、集成测试或采用测试驱动开发（TDD）模式的应用场景。通过简洁直观的 API 设计，testify 大大简化了复杂条件下的错误处理过程，并提高了代码可读性。",2,"2026-06-11 03:00:06","top_language"]