{"id":19156331,"url":"https://github.com/ess/jamaica","last_synced_at":"2025-02-22T21:42:10.320Z","repository":{"id":57536632,"uuid":"109047139","full_name":"ess/jamaica","owner":"ess","description":"It's not exactly aruba, but it tests CLI apps in go with godog","archived":false,"fork":false,"pushed_at":"2019-04-03T00:16:52.000Z","size":20,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-01-03T20:10:02.161Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ess.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":"2017-10-31T20:10:06.000Z","updated_at":"2019-04-03T00:16:44.000Z","dependencies_parsed_at":"2022-08-29T00:40:35.775Z","dependency_job_id":null,"html_url":"https://github.com/ess/jamaica","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ess%2Fjamaica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ess%2Fjamaica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ess%2Fjamaica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ess%2Fjamaica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ess","download_url":"https://codeload.github.com/ess/jamaica/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240241803,"owners_count":19770463,"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-11-09T08:34:07.423Z","updated_at":"2025-02-22T21:42:10.301Z","avatar_url":"https://github.com/ess.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"The jamaica pacakge provides some handy step definitions and functions for in-process testing of CLI applications via the [godog](https://github.com/DATA-DOG/godog) Cucumber port.\n\nIn short, this is an attempt to implement a very minimal [aruba](https://github.com/cucumber/aruba) for Go.\n\n## Installation ##\n\nIt would be best to use [dep](https://github.com/golang/dep) to include jamaica in your dependency tree, but there is absolutely no reason that you shouldn't be\nable to simply do the standard `go get`:\n\n```\ngo get github.com/ess/jamaica\n```\n\n## Configuration ##\n\nThe same steps are necessary regardless of the way that your `godog` suite is set up:\n\n1. Use `jamaica.SetRootCmd()` to declare the command that you want to test. The object passed must adhere to the [`jamaica.Command`]() interface.\n2. Use `jamaica.StepUp()` to inject the jamaica step definitions into your `godog` suite.\n\n### Basic Godog Configuration ###\n\nIf you're not using `TestMain` to execute your `godog` suite, you would set up jamaica within the `FeatureContext` in one of your test files:\n\n```go\npackage something\n\nimport (\n  \"github.com/DATA-DOG/godog\"\n  \"github.com/ess/jamaica\"\n)\n\nfunc FeatureContext(s *godog.Suite) {\n  jamaica.SetRootCmd(myCommand)\n  jamaica.StepUp(s)\n  \n  // Register the rest of your steps\n}\n```\n\n### TestMain Configuration ###\n\nIf you're using `TestMain` to execute your `godog` suite, you would set up jamaica like so:\n\n```go\npackage main\n\nimport (\n  \"os\"\n  \"testing\"\n\n  \"github.com/DATA-DOG/godog\"\n  \"github.com/ess/jamaica\"\n)\n\nfunc TestMain(m *testing.M) {\n  jamaica.SetRootCmd(cmd.RootCmd)\n\n  status := godog.RunWithOptions(\n    \"godog\",\n\n    func(s *godog.Suite) {\n      jamaica.StepUp(s)\n      \n      // Register the rest of your steps\n    },\n\n    godog.Options{\n      Format: \"pretty\",\n      Paths: []string{\"features\"},\n    },\n  )\n\n  if st := m.Run(); st \u003e status {\n    status = st\n  }\n\n  os.Exit(status)\n}\n```\n\n## Provided Steps ##\n\nA fairly minimal set of steps are provided by jamaica, because it's not exactly aruba.\n\n### Running the Command ###\n\nAfter you've set up all of your givens and such, you can use the following\nstep to run the command under test in-process:\n\n```gherkin\nWhen I run `mycommand and its arguments`\n```\n\n### Checking the Output ###\n\nTo assert that the command output contains a given string, use the following step:\n\n```gherkin\nThen stdout contains \"a given string\"\n```\n\nTo assert that the command output exactly matches a given string, use the following step:\n\n```gherkin\nThen stdout is \"a given string\"\n```\n\nIf these steps don't suit your needs (or if you'd prefer to use your own terminology), you can access the command's stdout via `jamaica.LastCommandStdout()` for your comparisons.\n\n### Checking the Exit Status ###\n\nTo assert the expectation that the application ran successfully (without error), use the following step:\n\n```gherkin\nThen it exits successfully\n```\n\nOn the other hand, to assert that you expect for the command to have failed, use this:\n\n```gherkin\nThen it exits with an error\n```\n\n## Usage ##\n\nSimply run your test suite via either `godog` or by using godog with the \"test main\" pattern.\n\n## History ##\n\n* v1.0.3 - Added LastCommandStatus getter\n* v1.0.2 - Added missing steps\n* v1.0.1 - Fixing some typos\n* v1.0.0 - First stable release\n* v0.0.8 - No hard deps\n* v0.0.7 - Minor tweaks\n* v0.0.6 - And now you can get the command output\n* v0.0.5 - Now maybe even working\n* v0.0.4 - Root the command\n* v0.0.3 - Always be returning\n* v0.0.2 - Or maybe I can cargo cult my own code properly\n* v0.0.1 - Initial attempt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fess%2Fjamaica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fess%2Fjamaica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fess%2Fjamaica/lists"}