{"id":17920896,"url":"https://github.com/eth-p/best","last_synced_at":"2025-03-24T00:32:36.078Z","repository":{"id":41131577,"uuid":"241259593","full_name":"eth-p/best","owner":"eth-p","description":"A Bash unit and snapshot testing framework.","archived":false,"fork":false,"pushed_at":"2023-05-16T02:15:24.000Z","size":179,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-05-16T04:26:15.315Z","etag":null,"topics":["bash","bash-testing","hacktoberfest","snapshot-test","snapshot-testing","unit-test","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/eth-p.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-18T03:02:07.000Z","updated_at":"2023-04-10T06:17:35.000Z","dependencies_parsed_at":"2022-08-26T17:52:39.999Z","dependency_job_id":null,"html_url":"https://github.com/eth-p/best","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fbest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fbest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fbest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fbest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eth-p","download_url":"https://codeload.github.com/eth-p/best/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221929724,"owners_count":16903438,"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":["bash","bash-testing","hacktoberfest","snapshot-test","snapshot-testing","unit-test","unit-testing"],"created_at":"2024-10-28T20:29:33.172Z","updated_at":"2024-10-28T20:29:33.604Z","avatar_url":"https://github.com/eth-p.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Best\nA testing framework designed for Bash, and built with Bash.\n\nMinimum Bash version: `3.2.0`  \nSupported platforms:\n - GNU Linux\n - MacOS\n\n\n## Command Line\n\n```shell\nbin/best.sh [options] [test...]\n```\n\n**Options:**\n\n| Option                | Value      | Description                                                  |\n| --------------------- | ---------- | ------------------------------------------------------------ |\n| `--jobs` / `-j`       | \\[number\\] | Specify the number of tests to run in parallel. Defaults to the current number of logical cores. |\n| `--suite`             | \\[string\\] | Loads a specific test suite.\u003cbr /\u003eIf this is absent, all suites in `$PWD/test` will be loaded. |\n| `--snapshot:generate` |            | Forces all snapshots to be regenerated.                      |\n| `--snapshot:show`     |            | Prints the difference between test output and output snapshots. |\n| `--snapshot:skip`     |            | Skips snapshot testing.                                      |\n| `--verbose`           |            | Prints STDOUT and STDERR of failed tests.                    |\n| `--strict`            |            | Treat skipped tests as though they were failed tests.        |\n| `--failed`            |            | Only show failed tests.                                      |\n| `--VERBOSE`           |            | Prints STDOUT and STDERR of all tests.                       |\n| `--debug`             |            | Prints debug information.\u003cbr /\u003eThis only prints information about `best` itself. |\n| `--porcelain`         |            | Changes the printing mode to something machine-friendly.     |\n| `--color`             |            | Enable color output.                                         |\n| `--no-color`          |            | Disable color output.                                        |\n\n**Subcommands:**\n\n| Subcommand  | Description                                   |\n| ----------- | --------------------------------------------- |\n| `--list`    | Prints a list of tests in the loaded suites.  |\n| `--version` | Prints the version and exits.                 |\n| `--repl`    | Enters a minimal REPL similar to the IPC API. |\n\n**Environment Variables:**\n\n| Variable           | Description                                                  | Default          |\n| ------------------ | ------------------------------------------------------------ | ---------------- |\n| `$BEST_BASH`       | A path to the version of Bash to execute tests with.         |                  |\n| `$TEST_ENV_TMPDIR` | The value of `$TMPDIR` inside the testing environment.       | Inherited        |\n| `$TEST_ENV_PATH`   | The value of `$PATH` inside the testing environment.         | Inherited        |\n| `$TEST_ENV_HOME`   | The value of `$HOME` inside the testing environment.         | Inherited        |\n| `$TEST_ENV_TERM`   | The value of `$TERM` inside the testing environment.         | `xterm-color`    |\n| `$TEST_LIB_PREFIX` | A variable that prepends a sequence to the test functions. This can be used to prevent function name conflicts with `best` and the scripts that it's testing. | None             |\n| `$TEST_SHIM_PATH`  | The path to the shims loadable by `use_shim`.                | None             |\n| `$TEST_DIR`        | The directory where test suites are stored.                  | `$PWD/test`      |\n| `$SNAPSHOT_DIR`    | The directory where snapshots are stored.                    | `$PWD/test-data` |\n\n\n\n\n\n\n## Tests\n\n### Suites\n\nTest suites are located inside `$(PWD)/test` as `.sh` files.\n\n```bash\ntest:my_test() {\n    description 'This is your first test.'\n\n    assert_equal 1 1\n    assert [ \"a\" = \"b\" ]\n}\n```\n\n\n\n### Functions\n\n- [`assert [function...]`](docs/fn_assert.md)\n- [`assert_equal [a] [b]`](docs/fn_assert_equal.md)\n- [`assert_not_equal [a] [b]`](docs/fn_assert_not_equal.md)\n- [`assert_less [a] [b]`](docs/fn_assert_less.md)\n- [`assert_less_or_equal [a] [b]`](docs/fn_assert_less_or_equal.md)\n- [`assert_greater [a] [b]`](docs/fn_assert_greater.md)\n- [`assert_greater_or_equal [a] [b]`](docs/fn_assert_greater_or_equal.md)\n- [`assert_exit [code]`](docs/fn_assert_exit.md)\n- [`expect [function...]`](docs/fn_expect.md)\n- [`expect_equal [a] [b]`](docs/fn_expect_equal.md)\n- [`expect_not_equal [a] [b]`](docs/fn_expect_not_equal.md)\n- [`expect_less [a] [b]`](docs/fn_expect_less.md)\n- [`expect_less_or_equal [a] [b]`](docs/fn_expect_less_or_equal.md)\n- [`expect_greater [a] [b]`](docs/fn_expect_greater.md)\n- [`expect_greater_or_equal [a] [b]`](docs/fn_expect_greater_or_equal.md)\n- [`fail [pattern] [...]`](docs/fn_fail.md)\n- [`skip [pattern] [...]`](docs/fn_skip.md)\n- [`array_contains [value] in [...]`](docs/fn_assert.md)\n- [`snapshot [\"stdout\"|\"stderr\"]`](docs/fn_snapshot.md)\n- [`description [message]`](docs/fn_description.md)\n- [`use_shim [name]`](docs/fn_use_shim.md)\n\n\n\n### Setup / Teardown\n\nThe functions named `setup` and `teardown` are used for test suite setup and teardown.\nThe former will be called when the suite is loaded, and the latter will be called after all tests are run.\n\n```bash\nsetup() {\n    MY_VAR=3\n}\n\nteardown() {\n    unset MY_VAR\n}\n\ntest:check_setup() {\n    assert_equal \"$MY_VAR\" 3\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feth-p%2Fbest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feth-p%2Fbest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feth-p%2Fbest/lists"}