All Projects → chris-peterson → kekiri

chris-peterson / kekiri

Licence: MIT license
A .NET framework that supports writing low-ceremony BDD tests using Gherkin language

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to kekiri

Specflow
#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
Stars: ✭ 1,827 (+9515.79%)
Mutual labels:  xunit, bdd, specflow, nunit
scenari
Clojure BDD library - Executable Specification with Behavior-Driven Development
Stars: ✭ 57 (+200%)
Mutual labels:  bdd, cucumber, scenario
eggplant
A behaviour driven development (BDD) library for Clojure. Simplicity is key.
Stars: ✭ 16 (-15.79%)
Mutual labels:  bdd, specification, bdd-framework
hitchstory
Type-safe, StrictYAML based BDD framework for python.
Stars: ✭ 24 (+26.32%)
Mutual labels:  bdd, specification, bdd-framework
Awesome-Cucumber
A collection of awesome Cucumber and Gherkin-related resources
Stars: ✭ 33 (+73.68%)
Mutual labels:  bdd, cucumber, bdd-framework
bat
Gherkin based DSL for testing HTTP APIs via Cucumber.JS
Stars: ✭ 30 (+57.89%)
Mutual labels:  bdd, cucumber, bdd-framework
Cake
🍰 Cake (C# Make) is a cross platform build automation system.
Stars: ✭ 3,154 (+16500%)
Mutual labels:  xunit, nunit
bUnit
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
Stars: ✭ 857 (+4410.53%)
Mutual labels:  xunit, nunit
Molder
BDD steps libraries for test automation databases, web services, and WebUI
Stars: ✭ 16 (-15.79%)
Mutual labels:  bdd, specflow
cucumber6-ts-starter
Starter project to write and debug cucumber-js features in TypeScript language
Stars: ✭ 62 (+226.32%)
Mutual labels:  bdd, cucumber
Pester
Pester is the ubiquitous test and mock framework for PowerShell.
Stars: ✭ 2,620 (+13689.47%)
Mutual labels:  bdd, bdd-framework
deveroom-visualstudio
Visual Studio extension for SpecFlow
Stars: ✭ 26 (+36.84%)
Mutual labels:  bdd, specflow
codeceptjs-bdd
⭐️ ⭐️⭐️ Migrated to Salesforce Open Source Platform - https://github.com/salesforce/codeceptjs-bdd
Stars: ✭ 24 (+26.32%)
Mutual labels:  bdd, cucumber
xRetry
Retry running tests via Xunit and Specflow
Stars: ✭ 15 (-21.05%)
Mutual labels:  xunit, specflow
testcontainers-dotnet
dotnet port of testcontainers-java
Stars: ✭ 22 (+15.79%)
Mutual labels:  xunit, nunit
Nightwatch Cucumber
[DEPRECATED] Cucumber.js plugin for Nightwatch.js.
Stars: ✭ 243 (+1178.95%)
Mutual labels:  bdd, cucumber
selenium BDD framework
Behavioural driven development UI automation framework using selenium, cucumber-java, testng, maven, phantomjs
Stars: ✭ 34 (+78.95%)
Mutual labels:  scenario, bdd-framework
justtestlah
Dynamic test framework for web and mobile applications
Stars: ✭ 43 (+126.32%)
Mutual labels:  bdd, cucumber
docs
Cucumber user documentation
Stars: ✭ 110 (+478.95%)
Mutual labels:  bdd, cucumber
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+33500%)
Mutual labels:  bdd, cucumber

Overview

A .NET framework that supports writing low-ceremony BDD tests using Gherkin language.

Kekiri honors the conventions of the Gherkin cucumber language.

Status

Build status

Package Latest Release
Kekiri NuGet version
Kekiri.IoC.Autofac NuGet version
Kekiri.IoC.ServiceProvider NuGet version
Kekiri.Xunit NuGet version
Kekiri.NUnit NuGet version

Setup

Kekiri targets netstandard2.0. To get started, be sure to have the latest dotnet core tools.

Select Test Runner

Xunit (recommended)

PM> Install-Package Kekiri.Xunit

NUnit

PM> Install-Package Kekiri.NUnit

IoC Integration (optional)

Autofac

PM> Install-Package Kekiri.IoC.Autofac

Be sure to call AutofacBootstrapper.Initialize() before your tests run.

IServiceProvider

PM> Install-Package Kekiri.IoC.ServiceProvider

Be sure to call ServiceProviderBootstrapper.Initialize(…) before your tests run.

Why Kekiri

Unlike 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.

The resulting scenario fixtures are concise, highly portable, and adhere to Act, Arrange, and Assert.

IoC is also a first-class citizen encouraging testing object interactions in collaboration rather than isolation. More details here.

Example

Implementing a basic calculator.

Start with the test

    class Calculator_tests : Scenarios
    {
        [Scenario]
        public void Adding_two_numbers()
        {
            Given(a_calculator)
               .And(the_user_enters_50)
               .And(the_user_enters_70);
            When(adding);
            Then(the_result_is_120);
        }

        void a_calculator() {}

        void the_user_enters_50() {}

        void the_user_enters_70() {}

        void adding() { throw new NotImplementedException(); }

        void the_result_is_120() {}
    }

If we were to run this test (even though it fails) we get a nice Cucumber-style feature output:

        Scenario: Adding two numbers
        Given a calculator
            And the user enters 50
            And next the user enters 70
        When adding
        Then the result is 120

Add the implementation

    class Adding_two_numbers : Scenarios
    {
        Calculator _calculator;

        [Scenario]
        public void Adding_two_numbers()
        {
            Given(a_calculator)
               .And(the_user_enters_50)
               .And(the_user_enters_70);
            When(adding);
            Then(the_screen_displays_a_result_of_120);
        }

        void a_calculator()
        {
            _calculator = new Calculator();
        }

        void the_user_enters_50()
        {
            _calculator.Operand1 = 50;
        }

        void the_user_enters_70()
        {
            _calculator.Operand2 = 70;
        }

        void adding()
        {
            _calculator.Add();
        }

        void the_result_is_120()
        {
            Assert.AreEqual(120m, _calculator.Result);
        }
    }

    class Calculator
    {
        public decimal Operand1 { get; set; }
        public decimal Operand2 { get; set; }

        public decimal Result { get; set; }

        public void Add() { Result = Operand1 + Operand2; }
    }

Supported Naming Conventions

Kekiri supports both Pascal case conventions (e.g. WhenDoingTheThing) as it does underscore convention (e.g. When_doing_the_thing).


Scenario Output

Kekiri supports outputing the cucumber text. The output settings are controlled via the KEKIRI_OUTPUT environment variable.

Example:

   $env:KEKIRI_OUTPUT='console,files'

Output to Console

To output to the console, ensure that KEKIRI_OUTPUT contains console.

Output to Files

To output to .feature files in the test execution directory, ensure that KEKIRI_OUTPUT contains files.

The name of the feature file is based on the containing namespace of the scenario. For example, if Adding_two_numbers was defined in UnitTests.Features.Addition.Adding_two_numbers, the output would be written to Addition.feature.


Wiki

More detailed documentation can be found on the wiki.

Other common use cases

Expected Exceptions

    class Divide_by_zero : Scenarios
    {
        readonly Calculator _calculator = new Calculator();

        [Scenario]
        public Divide_by_zero()
        {
            Given(a_denominator_of_0);
            When(dividing).Throws();
            Then(an_exception_is_raised);
        }

        void a_denominator_of_0()
        {
            _calculator.Operand2 = 0;
        }

        void dividing()
        {
            _calculator.Divide();
        }

        void an_exception_is_raised()
        {
            Catch<DivideByZeroException>();
        }
    }

Notice, here we've used the Throws() method to inform that throwing an exception is the expected behavior. In 1 or more Then methods, the thrown type of exception must be caught (using the templated method Catch<>).

Examples (aka tabular tests)

    public class Subtracting_two_numbers : Scenarios
    {
        readonly Calculator _calculator = new Calculator();

        [Example(12, 5, 7)]
        [Example(20, 5, 15)]
        [ScenarioOutline]
        public Subtracting_two_numbers(double operand1, double operand2, double expectedResult)
        {
            Given(the_user_enters_OPERAND1, operand1)
                .And(the_user_enters_OPERAND2, operand2);
            When(subtracting);
            Then(the_result_is_EXPECTED, expectedResult);
        }

        void the_user_enters_OPERAND1(double operand1)
        {
            _calculator.Operand1 = operand1;
        }

        void the_user_enters_OPERAND2(double operand2)
        {
            _calculator.Operand2 = operand2;
        }

        void subtracting()
        {
            _calculator.Subtract();
        }

        void the_result_is_EXPECTED(double expected)
        {
            Assert.AreEqual(expected, _calculator.Result);
        }
    }
        Given the user enters 12
          And the user enters 5
        When subtracting
        Then the result is 7

Note: step method parameter names can be used as substitution macros by mentioning them in CAPS.

For more advanced topics, check out the wiki.

Acknowledgements

Kekiri uses and is influenced by the following open source projects:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].