{"id":29440848,"url":"https://github.com/nalgeon/be","last_synced_at":"2025-07-14T13:02:16.245Z","repository":{"id":303563893,"uuid":"1015537777","full_name":"nalgeon/be","owner":"nalgeon","description":"Minimal test assertions in Go","archived":false,"fork":false,"pushed_at":"2025-07-08T08:22:26.000Z","size":10,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-08T09:35:19.397Z","etag":null,"topics":["assert","golang","simple","testing"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/nalgeon/be","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/nalgeon.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,"zenodo":null}},"created_at":"2025-07-07T16:45:55.000Z","updated_at":"2025-07-08T09:03:19.000Z","dependencies_parsed_at":"2025-07-08T09:39:11.569Z","dependency_job_id":"0dd6a3ea-d157-4a2b-ae84-7d052efa73c6","html_url":"https://github.com/nalgeon/be","commit_stats":null,"previous_names":["nalgeon/be"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nalgeon/be","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalgeon%2Fbe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalgeon%2Fbe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalgeon%2Fbe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalgeon%2Fbe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nalgeon","download_url":"https://codeload.github.com/nalgeon/be/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalgeon%2Fbe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265137053,"owners_count":23716783,"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":["assert","golang","simple","testing"],"created_at":"2025-07-13T12:15:59.368Z","updated_at":"2025-07-13T12:16:01.513Z","avatar_url":"https://github.com/nalgeon.png","language":"Go","funding_links":[],"categories":["Go","Members"],"sub_categories":[],"readme":"# Be - a minimal test assertions package\n\nIf you want simple test assertions and feel like [testify](https://pkg.go.dev/github.com/attic-labs/testify/assert) is too much, but [is](https://pkg.go.dev/github.com/matryer/is) is too basic, you might like `be`.\n\nHighlights:\n\n-   Minimal API: `Equal`, `Err`, and `True` assertions.\n-   Correctly compares `time.Time` values and other types with an `Equal` method.\n-   Flexible error assertions: check if an error exists, check its value, type, or any combination of these.\n-   Zero hassle.\n\nBe is new, but it's ready for production (or maybe I should say \"testing\" :) I've used it in three very different projects — a CLI tool, an API server, and a database engine — and it worked great every time.\n\n## Usage\n\nInstall with go get:\n\n```text\ngo get github.com/nalgeon/be\n```\n\n`Equal` asserts that two values are equal:\n\n```go\nfunc Test(t *testing.T) {\n    t.Run(\"pass\", func(t *testing.T) {\n        got, want := \"hello\", \"hello\"\n        be.Equal(t, got, want)\n        // ok\n    })\n\n    t.Run(\"fail\", func(t *testing.T) {\n        got, want := \"olleh\", \"hello\"\n        be.Equal(t, got, want)\n        // want \"hello\", got \"olleh\"\n    })\n}\n```\n\nOr that a value matches any of the given values:\n\n```go\nfunc Test(t *testing.T) {\n    got := 2 * 3 * 7\n    be.Equal(t, got, 21, 42, 84)\n    // ok\n}\n```\n\n`Err` asserts that there is an error:\n\n```go\nfunc Test(t *testing.T) {\n    _, err := regexp.Compile(\"he(?o\") // invalid\n    be.Err(t, err)\n    // ok\n}\n```\n\nOr that there are no errors:\n\n```go\nfunc Test(t *testing.T) {\n    _, err := regexp.Compile(\"he??o\") // valid\n    be.Err(t, err, nil)\n    // ok\n}\n```\n\nOr that an error message contains a substring:\n\n```go\nfunc Test(t *testing.T) {\n    _, err := regexp.Compile(\"he(?o\") // invalid\n    be.Err(t, err, \"invalid or unsupported\")\n    // ok\n}\n```\n\nOr that an error matches the expected error according to `errors.Is`:\n\n```go\nfunc Test(t *testing.T) {\n    err := \u0026fs.PathError{\n        Op: \"open\",\n        Path: \"file.txt\",\n        Err: fs.ErrNotExist,\n    }\n    be.Err(t, err, fs.ErrNotExist)\n    // ok\n}\n```\n\nOr that the error type matches the expected type according to `errors.As`:\n\n```go\nfunc Test(t *testing.T) {\n    got := \u0026fs.PathError{\n        Op: \"open\",\n        Path: \"file.txt\",\n        Err: fs.ErrNotExist,\n    }\n    be.Err(t, got, reflect.TypeFor[*fs.PathError]())\n    // ok\n}\n```\n\nOr a mix of the above:\n\n```go\nfunc Test(t *testing.T) {\n    err := AppError(\"oops\")\n    be.Err(t, err,\n        \"failed\",\n        AppError(\"oops\"),\n        reflect.TypeFor[AppError](),\n    )\n    // ok\n}\n```\n\n`True` asserts that an expression is true:\n\n```go\nfunc Test(t *testing.T) {\n    s := \"go is awesome\"\n    be.True(t, len(s) \u003e 0)\n    // ok\n}\n```\n\nThat's it!\n\n## Design decisions\n\nBe is opinionated. It only has three assert functions, which are perfectly enough to write good tests.\n\nUnlike other testing packages, Be doesn't support custom error messages. When a test fails, you'll end up checking the code anyway, so why bother? The line number shows the way.\n\nBe has flexible error assertions. You don't need to choose between `Error`, `ErrorIs`, `ErrorAs`, `ErrorContains`, `NoError`, or anything like that — just use `be.Err`. It covers everything.\n\nBe doesn't fail the test when an assertion fails, so you can see all the errors at once instead of hunting them one by one. The only exception is when the `be.Err(err, nil)` assertion fails — this means there was an unexpected error. In this case, the test terminates immediately because any following assertions probably won't make sense and could cause panics.\n\nThe parameter order is (got, want), not (want, got). It just feels more natural — like saying \"account balance is 100 coins\" instead of \"100 coins is the account balance\".\n\nBe has ≈150 lines of code (+500 lines for tests). For comparison, `is` has ≈250 loc (+250 lines for tests).\n\n## Contributing\n\nBug fixes are welcome. For anything other than bug fixes, please open an issue first to discuss your proposed changes. The package has a very limited scope, so it's important to discuss any new features before implementing them.\n\nMake sure to add or update tests as needed.\n\n## License\n\nCreated by [Anton Zhiyanov](https://antonz.org/). Released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnalgeon%2Fbe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnalgeon%2Fbe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnalgeon%2Fbe/lists"}