{"id":31045044,"url":"https://github.com/jrwdunham/tegere","last_synced_at":"2025-09-14T16:54:37.590Z","repository":{"id":55912946,"uuid":"192154347","full_name":"jrwdunham/tegere","owner":"jrwdunham","description":"TeGere! = Behave! — a Gherkin library for Clojure","archived":false,"fork":false,"pushed_at":"2023-10-12T22:42:27.000Z","size":152,"stargazers_count":13,"open_issues_count":8,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T02:44:23.337Z","etag":null,"topics":["clojure","gherkin-library","instaparse","testing"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jrwdunham.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","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":"2019-06-16T05:36:48.000Z","updated_at":"2024-07-19T22:40:25.000Z","dependencies_parsed_at":"2022-08-15T09:20:16.470Z","dependency_job_id":null,"html_url":"https://github.com/jrwdunham/tegere","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jrwdunham/tegere","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrwdunham%2Ftegere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrwdunham%2Ftegere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrwdunham%2Ftegere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrwdunham%2Ftegere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jrwdunham","download_url":"https://codeload.github.com/jrwdunham/tegere/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrwdunham%2Ftegere/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275136752,"owners_count":25411709,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clojure","gherkin-library","instaparse","testing"],"created_at":"2025-09-14T16:54:34.767Z","updated_at":"2025-09-14T16:54:37.560Z","avatar_url":"https://github.com/jrwdunham.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"================================================================================\n  TeGere\n================================================================================\n\n.. image:: https://circleci.com/gh/jrwdunham/tegere.svg?style=svg\n    :target: https://circleci.com/gh/jrwdunham/tegere\n.. image:: https://img.shields.io/clojars/v/tegere.svg\n    :target: https://clojars.org/tegere\n\nA Gherkin library for Clojure. To \"te gere\" is to carry oneself with dignity or,\nas the vulgar crowd might say, to \"behave!\".\n\n    \"Now, if you have one of these pretend testing systems that lets you write\n    English strings so that the customer can look at it, that's just silly.\"\n\n    -- Rich Hickey (Simple Made Easy talk)\n\n    \"You know a fool who persists in his folly becomes wise.\"\n\n    -- Alan Watts\n\nYes, `cucumber-jvm`_ and `cucumber-js`_ exist. TeGere offers a Clojure-first\nGherkin library and an opportunity to use Instaparse_ to create a useful DSL.\nTakes inspiration from `Python Behave`_.\n\n\nQuickstart\n================================================================================\n\nThe latest version on Clojars:\n\n.. code-block:: bash\n\n      {tegere {:mvn/version \"0.1.5\"}}\n\nTry it out quickly:\n\n.. code-block:: bash\n\n      clj -Sdeps \"{:deps {tegere {:mvn/version \\\"0.1.5\\\"}}}\"\n\nNow write some Gherkin_ feature files and save them (with the ``.feature``\nextension) to some directory. Now map the Gherkin step strings to Clojure\nfunctions using the ``Given``, ``When`` and ``Then`` functions of\n``tegere.steps``. Finally, execute the features by calling:\n\n.. code-block:: clojure\n\n       user\u003e (tegere.runner/run\n               (tegere.loader/load-feature-files \"path/to/gherkin\")\n               @tegere.steps/registry)\n\nAn optional config map may be passed to ``run`` as a third argument. It\nrecognizes the boolean key ``tegere.runner/stop`` which will cause TeGere to stop\nfeature execution after the first failure, and ``:tegere.query/query-tree`` which\nis a boolean search tree (see the spec_) that controls which scenarios get\nexecuted:\n\n.. code-block:: clojure\n\n       user\u003e (tegere.runner/run\n               (tegere.loader/load-feature-files \"path/to/gherkin\")\n               @tegere.steps/registry\n               {:tegere.runner/stop true\n                :tegere.query/query-tree\n                '(or (and \"chimpanzees\" (not \"fruit-reactions\"))\n                     \"bonobos\")})\n\nFor additional documentation, see the ``Detailed Usage`` section below or the\nexample Apes_ project under the ``examples/`` folder.\n\n\nDetailed Usage\n================================================================================\n\n\nCreate and Load Gherkin Files\n--------------------------------------------------------------------------------\n\nConsider the following simplistic Gherkin feature file at\n``examples/chimps/chimps.feature``::\n\n    @chimpanzees\n    Feature: Chimpanzees behave as expected\n      Experimenters want chimpanzee sims to behave correctly.\n\n      @fruit-reactions\n      Scenario: Chimpanzees behave as expected when offered various foods.\n        Given a chimpanzee\n        When I give him a papaya\n        Then he is happy\n\nTo parse and load this feature file into a Clojure data structure, pass its\ndirectory path to ``tegere.loader/load-feature-files``:\n\n.. code-block:: clojure\n\n       user\u003e (require '[tegere.loader :refer [load-feature-files]])\n       user\u003e (def features (load-feature-files \"examples/chimps\"))\n       user\u003e features\n       [#:tegere.parser{:name \"Chimpanzees behave as expected\",\n                        :description\n                        \"Experimenters want chimpanzee sims to behave correctly.\",\n                        :tags [\"chimpanzees\"],\n                        :scenarios\n                        [#:tegere.parser{:description\n                                         \"Chimpanzees behave as expected when ...\",\n                                         :tags [\"fruit-reactions\"],\n                                         :steps\n                                         [#:tegere.parser{:type :given,\n                                                          :text \"a chimpanzee\"}\n                                          #:tegere.parser{:type :when,\n                                                          :text \"I give him a papaya\"}\n                                          #:tegere.parser{:type :then,\n                                                          :text \"he is happy\"}]}]}]\n\nThe loaded feature is a ``:tegere.parser/features`` collection of\n``:tegere.parser/feature`` maps.\n\n\nMap Gherkin Step Definitions to Clojure Step Functions\n--------------------------------------------------------------------------------\n\nNow we can use the appropriate step-mapping function (``Given``, ``When``, or\n``Then``) to populate the global steps registry atom that maps regular\nexpressions (strings) matching Gherkin Step statements to Clojure functions:\n\n.. code-block:: clojure\n\n       user\u003e (require '[tegere.steps :refer [registry Given When Then]])\n       user\u003e (Given \"a {animal}\" (fn [ctx animal] (assoc ctx :animal animal)))\n       user\u003e (When \"I give him a {fruit}\"\n                   (fn [ctx fruit]\n                     (merge ctx\n                            {:received fruit\n                             :emotion (if (= fruit \"pear\") \"happy\" \"sad\")})))\n       user\u003e (Then \"he is {emotion}\"\n                   (fn [{actual-emotion :emotion :as ctx} emotion]\n                     (assert (= emotion actual-emotion)\n                             (format \"Ape is %s, expected her to be %s.\"\n                                     actual-emotion emotion))))\n       user\u003e @registry\n       {:given {\"a {animal}\" #function[user/eval13631/fn--13632]},\n        :when {\"I give him a {fruit}\" #function[user/eval13641/fn--13642]},\n        :then {\"he is {emotion}\" #function[user/eval13645/fn--13646]}}\n\nThe first argument to a step function is a context map, ``ctx`` in the examples\nabove. If successful, the step function should return a (possibly updated)\ncontext map. If the step fails, it should throw an exception.\n\n\nRun the Features from the REPL\n--------------------------------------------------------------------------------\n\nFinally, call ``tegere.runner/run`` to execute the parsed features using the\npopulated registry:\n\n.. code-block:: clojure\n\n       user\u003e (require '[tegere.runner :refer [run]])\n       user\u003e (run features @registry)\n       @chimpanzees\n       Feature: Chimpanzees behave as expected\n         Experimenters want chimpanzee sims to behave correctly.\n\n         @fruit-reactions\n         Scenario: Chimpanzees behave as expected when offered various foods.\n\n           Given a chimpanzee (took 0.0s)\n           When I give him a papaya (took 0.0s)\n           Then he is happy (took 0.001s)\n               Assertion error: Assert failed: Ape is sad, expected her to be happy.\n                   (= emotion actual-emotion)\n\n       0 features passed, 1 failed\n       0 scenarios passed, 1 failed\n       2 steps passed, 1 failed, 0 untested\n\nAs illustrated above, the execution of features entails a side-effect: the\noutcome of the execution is written to stdout. The return value of ``run``, on\nthe other hand, is data: a ``:tegere.runner/run`` data structure that details\nhow long each step took, the context value it returned, and whether it passed or\nfailed.\n\nAn optional third argument (a configuration map) may be passed to ``run``.\nSetting the boolean key ``:tegere.runner/stop`` to ``true`` will cause TeGere to\nstop feature execution after the first failure. The value of\n``:tegere.query/query-tree``, if supplied, must be a boolean search tree (see the\nspec_); it controls which scenarios get executed.\n\n\nCreate a Command-line Interface\n--------------------------------------------------------------------------------\n\nThe ``tegere.cli`` namespaces contains the ``validate-args`` function, which\ncan be used to create a command-line interface to a TeGere feature runner. For\nexample:\n\n.. code-block:: clojure\n\n       (cli/validate-args\n         [\"src/apes/features\"\n          \"--tags=@bonobos or @chimpanzees\"\n          \"--tags=not @orangutan\"\n          \"-Durl=http://api.example.com\"\n          \"--data=password=secret\"\n          \"--stop\"\n          \"--verbose\"])\n       {:tegere.runner/stop true,\n        :tegere.runner/verbose true,\n        :tegere.runner/data {:url \"http://api.example.com\", :password \"secret\"},\n        :tegere.query/query-tree (and (not \"orangutan\") (or \"bonobos\" \"chimpanzees\")),\n        :tegere.runner/features-path \"src/apes/features\"}\n\nIn the Apes_ example application, the above allows us to run the features from the\ncommand-line using the ``clj`` tool and a command like the following:\n\n.. code-block:: bash\n\n       $ clj -m apes.core src/apes/features/ \\\n             --tags='@chimpanzees \u0026 @fruit=banana or @bonobos and @orangutan'\n\nSee the ``apes.core`` namespace in the Apes_ examples app for more details.\n\n\nRun the Tests\n================================================================================\n\nUse the ``test`` alias defined in ``deps.edn``:\n\n.. code-block:: bash\n\n       $ clj -A:test\n\nTo run tests specific to a single namespace, e.g., ``tegere.grammar``:\n\n.. code-block:: bash\n\n       $ clj -A:test -n tegere.grammar-test\n\nExamples of running specific ``deftest`` expressions:\n\n.. code-block:: bash\n\n       $ clj -A:test -n tegere.runner-test -v tegere.runner-test/can-run-simple-feature-test\n       $ clj -A:test -n tegere.grammar-test -v tegere.grammar-test/step-block-parse-test\n       $ clj -A:test -n tegere.parser-test -v tegere.parser-test/step-data-and-linebreaks\n       $ clj -A:test -n tegere.parser-test -v tegere.parser-test/parsed-features-conform-to-spec\n\n\nLicense\n================================================================================\n\nCopyright © 2019 Joel Dunham\n\nThis program and the accompanying materials are made available under the\nterms of the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n\nThis Source Code may also be made available under the following Secondary\nLicenses when the conditions for such availability set forth in the Eclipse\nPublic License, v. 2.0 are satisfied: GNU General Public License as published by\nthe Free Software Foundation, either version 2 of the License, or (at your\noption) any later version, with the GNU Classpath Exception which is available\nat https://www.gnu.org/software/classpath/license.html.\n\n\n.. _`cucumber-js`: https://github.com/cucumber/cucumber-js\n.. _`cucumber-jvm`: https://github.com/cucumber/cucumber-jvm\n.. _`Python Behave`: https://github.com/behave/behave\n.. _Instaparse: https://github.com/Engelberg/instaparse\n.. _Gherkin: https://cucumber.io/docs/gherkin/reference/\n.. _Apes: examples/apes/README.rst\n.. _spec: src/tegere/query.clj\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrwdunham%2Ftegere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjrwdunham%2Ftegere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrwdunham%2Ftegere/lists"}