{"id":16567306,"url":"https://github.com/chris-peterson/kekiri","last_synced_at":"2025-07-31T15:40:18.149Z","repository":{"id":9558823,"uuid":"11468377","full_name":"chris-peterson/kekiri","owner":"chris-peterson","description":"A .NET framework that supports writing low-ceremony BDD tests using Gherkin language","archived":false,"fork":false,"pushed_at":"2022-05-03T00:51:01.000Z","size":774,"stargazers_count":20,"open_issues_count":4,"forks_count":15,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-07-19T13:13:48.192Z","etag":null,"topics":["bdd","bdd-framework","csharp","cucumber","dotnet","gherkin-language","ioc","nunit","scenario","specflow","specification","testing","xunit"],"latest_commit_sha":null,"homepage":"","language":"C#","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/chris-peterson.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":"2013-07-17T05:52:09.000Z","updated_at":"2024-08-21T23:59:38.000Z","dependencies_parsed_at":"2022-07-12T15:03:39.925Z","dependency_job_id":null,"html_url":"https://github.com/chris-peterson/kekiri","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/chris-peterson/kekiri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fkekiri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fkekiri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fkekiri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fkekiri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chris-peterson","download_url":"https://codeload.github.com/chris-peterson/kekiri/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fkekiri/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266087790,"owners_count":23874519,"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":["bdd","bdd-framework","csharp","cucumber","dotnet","gherkin-language","ioc","nunit","scenario","specflow","specification","testing","xunit"],"created_at":"2024-10-11T21:06:14.020Z","updated_at":"2025-07-20T08:05:59.520Z","avatar_url":"https://github.com/chris-peterson.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# Overview\n\nA .NET framework that supports writing low-ceremony BDD tests using Gherkin language.\n\nKekiri honors the conventions of the Gherkin\n[cucumber language](https://cucumber.io/docs/gherkin/reference/).\n\n## Status\n\n[![Build status](https://gitlab.com/chris-peterson/kekiri/badges/master/pipeline.svg)](https://gitlab.com/chris-peterson/kekiri/-/pipelines)\n\nPackage | Latest Release |\n:-------- | :------------ |\nKekiri | [![NuGet version](https://img.shields.io/nuget/dt/Kekiri.svg)](https://www.nuget.org/packages/kekiri)\nKekiri.IoC.Autofac | [![NuGet version](https://img.shields.io/nuget/dt/Kekiri.IoC.Autofac.svg)](https://www.nuget.org/packages/kekiri.ioc.autofac)\nKekiri.IoC.ServiceProvider | [![NuGet version](https://img.shields.io/nuget/dt/Kekiri.IoC.ServiceProvider.svg)](https://www.nuget.org/packages/kekiri.ioc.ServiceProvider)\nKekiri.Xunit | [![NuGet version](https://img.shields.io/nuget/dt/Kekiri.Xunit.svg)](https://www.nuget.org/packages/kekiri.xunit)\nKekiri.NUnit | [![NuGet version](https://img.shields.io/nuget/dt/Kekiri.NUnit.svg)](https://www.nuget.org/packages/kekiri.nunit)\n\n## Setup\n\nKekiri targets `netstandard2.0`.  To get started, be sure to have the latest [dotnet core](https://www.microsoft.com/net/core) tools.\n\n### Select Test Runner\n\n#### Xunit (recommended)\n\n`PM\u003e Install-Package Kekiri.Xunit`\n\n#### NUnit\n\n`PM\u003e Install-Package Kekiri.NUnit`\n\n### IoC Integration (optional)\n\n#### Autofac\n\n`PM\u003e Install-Package Kekiri.IoC.Autofac`\n\nBe sure to call `AutofacBootstrapper.Initialize()` before your tests run.\n\n#### IServiceProvider\n\n`PM\u003e Install-Package Kekiri.IoC.ServiceProvider`\n\nBe sure to call `ServiceProviderBootstrapper.Initialize(…)` before your tests run.\n\n## Why Kekiri\n\nUnlike other BDD frameworks that impose process overhead (management of feature files, custom tooling, etc) Kekiri allows developers to write BDD scenarios just as quickly and easily as they would a \"plain old\" test.\n\nThe resulting scenario fixtures are concise, highly portable, and adhere to [Act, Arrange, and Assert](https://automationpanda.com/2020/07/07/arrange-act-assert-a-pattern-for-writing-good-tests/).\n\nIoC is also a first-class citizen encouraging testing object interactions in collaboration rather than isolation.  More details [here](https://github.com/chris-peterson/kekiri/wiki/IoC-Support).\n\n## Example\n\nImplementing a basic calculator.\n\n### Start with the test\n\n```c#\n    class Calculator_tests : Scenarios\n    {\n        [Scenario]\n        public void Adding_two_numbers()\n        {\n            Given(a_calculator)\n               .And(the_user_enters_50)\n               .And(the_user_enters_70);\n            When(adding);\n            Then(the_result_is_120);\n        }\n\n        void a_calculator() {}\n\n        void the_user_enters_50() {}\n\n        void the_user_enters_70() {}\n\n        void adding() { throw new NotImplementedException(); }\n\n        void the_result_is_120() {}\n    }\n```\n\nIf we were to run this test (even though it fails) we get a nice Cucumber-style feature output:\n\n```plaintext\n        Scenario: Adding two numbers\n        Given a calculator\n            And the user enters 50\n            And next the user enters 70\n        When adding\n        Then the result is 120\n```\n\n### Add the implementation\n\n```c#\n    class Adding_two_numbers : Scenarios\n    {\n        Calculator _calculator;\n\n        [Scenario]\n        public void Adding_two_numbers()\n        {\n            Given(a_calculator)\n               .And(the_user_enters_50)\n               .And(the_user_enters_70);\n            When(adding);\n            Then(the_screen_displays_a_result_of_120);\n        }\n\n        void a_calculator()\n        {\n            _calculator = new Calculator();\n        }\n\n        void the_user_enters_50()\n        {\n            _calculator.Operand1 = 50;\n        }\n\n        void the_user_enters_70()\n        {\n            _calculator.Operand2 = 70;\n        }\n\n        void adding()\n        {\n            _calculator.Add();\n        }\n\n        void the_result_is_120()\n        {\n            Assert.AreEqual(120m, _calculator.Result);\n        }\n    }\n\n    class Calculator\n    {\n        public decimal Operand1 { get; set; }\n        public decimal Operand2 { get; set; }\n\n        public decimal Result { get; set; }\n\n        public void Add() { Result = Operand1 + Operand2; }\n    }\n```\n\n---\n\n## Supported Naming Conventions\n\nKekiri supports both Pascal case conventions (e.g. `WhenDoingTheThing`) as it does\nunderscore convention (e.g. `When_doing_the_thing`).\n\n---\n\n## Scenario Output\n\nKekiri supports outputing the cucumber text.\nThe output settings are controlled via the `KEKIRI_OUTPUT` environment variable.\n\nExample:\n\n```ps1\n   $env:KEKIRI_OUTPUT='console,files'\n```\n\n### Output to Console\n\nTo output to the console, ensure that `KEKIRI_OUTPUT` contains `console`.\n\n### Output to Files\n\nTo output to .feature files in the test execution directory, ensure that `KEKIRI_OUTPUT` contains `files`.\n\nThe name of the feature file is based on the containing namespace of the scenario.\nFor example, if `Adding_two_numbers` was defined in `UnitTests.Features.Addition.Adding_two_numbers`, the output would be written to `Addition.feature`.\n\n---\n\n## Wiki\n\nMore detailed documentation can be found on the [wiki](\u003chttps://github.com/chris-peterson/kekiri/wiki\u003e).\n\n## Other common use cases\n\n### Expected Exceptions\n\n```c#\n    class Divide_by_zero : Scenarios\n    {\n        readonly Calculator _calculator = new Calculator();\n\n        [Scenario]\n        public Divide_by_zero()\n        {\n            Given(a_denominator_of_0);\n            When(dividing).Throws();\n            Then(an_exception_is_raised);\n        }\n\n        void a_denominator_of_0()\n        {\n            _calculator.Operand2 = 0;\n        }\n\n        void dividing()\n        {\n            _calculator.Divide();\n        }\n\n        void an_exception_is_raised()\n        {\n            Catch\u003cDivideByZeroException\u003e();\n        }\n    }\n```\n\nNotice, here we've used the `Throws()` method to inform that throwing an\nexception is the expected behavior.  In 1 or more `Then` methods, the thrown type of exception must\nbe caught (using the templated method `Catch\u003c\u003e`).\n\n### Examples (aka tabular tests)\n\n```c#\n    public class Subtracting_two_numbers : Scenarios\n    {\n        readonly Calculator _calculator = new Calculator();\n\n        [Example(12, 5, 7)]\n        [Example(20, 5, 15)]\n        [ScenarioOutline]\n        public Subtracting_two_numbers(double operand1, double operand2, double expectedResult)\n        {\n            Given(the_user_enters_OPERAND1, operand1)\n                .And(the_user_enters_OPERAND2, operand2);\n            When(subtracting);\n            Then(the_result_is_EXPECTED, expectedResult);\n        }\n\n        void the_user_enters_OPERAND1(double operand1)\n        {\n            _calculator.Operand1 = operand1;\n        }\n\n        void the_user_enters_OPERAND2(double operand2)\n        {\n            _calculator.Operand2 = operand2;\n        }\n\n        void subtracting()\n        {\n            _calculator.Subtract();\n        }\n\n        void the_result_is_EXPECTED(double expected)\n        {\n            Assert.AreEqual(expected, _calculator.Result);\n        }\n    }\n```\n\n```plaintext\n        Given the user enters 12\n          And the user enters 5\n        When subtracting\n        Then the result is 7\n```\n\nNote: step method parameter names can be used as substitution macros by mentioning them in CAPS.\n\nFor more advanced topics, check out the [wiki](https://github.com/chris-peterson/kekiri/wiki).\n\n## Acknowledgements\n\nKekiri uses and is influenced by the following open source projects:\n\n* [Xunit](\u003chttps://xunit.github.io\u003e)\n* [NUnit](\u003chttp://nunit.org\u003e)\n* [Autofac](\u003chttps://github.com/autofac/Autofac\u003e)\n* [xrepo](\u003chttps://github.com/andyalm/xrepo\u003e)\n* [pickles](\u003chttps://github.com/picklesdoc/pickles#pickles\u003e)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-peterson%2Fkekiri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris-peterson%2Fkekiri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-peterson%2Fkekiri/lists"}