Popularity
3.7
Growing
Activity
2.5
Growing
234
12
37

Description

LightBDD is a behaviour-driven development test framework offering ability to write tests that are easy to read, easy to track during execution and summarize in user friendly report, while allowing developers to use all of the standard development tools to maintain them.

Programming language: C#
License: GNU General Public License v3.0 or later
Tags: Test     Testing     TDD     xUnit2     NUnit     BDD     MSTest2    
Latest version: v3.2.0

LightBDD alternatives and similar packages

Based on the "Testing" category.
Alternatively, view LightBDD alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of LightBDD or a related project?

Add another 'Testing' Package

README

logo LightBDD The Lightweight Behavior Driven Development test framework

Category Badge Platforms
Build Build status
Chat (gitter) Join the chat at https://gitter.im/LightBDD/LightBDD
LightBDD.NUnit3 NuGet Badge .NET Standard >= 2.0 .NET Framework >= 4.6.1 .NET Core >= 2.0
LightBDD.XUnit2 NuGet Badge .NET Standard >= 2.0 .NET Framework >= 4.6.1 .NET Core >= 2.0
LightBDD.MsTest2 NuGet Badge .NET Standard >= 2.0 .NET Framework >= 4.6.1 .NET Core >= 2.0 UWP >= 10.0.16299
LightBDD.Fixie2 NuGet Badge .NET Framework >= 4.6.1 .NET Core >= 2.0
LightBDD.Autofac NuGet Badge .NET Standard >= 2.0 .NET Framework >= 4.6.1
LightBDD.Extensions.DependencyInjection NuGet Badge .NET Standard >= 2.0

Project description

LightBDD is a behaviour-driven development test framework offering ability to write tests that are easy to read, easy to track during execution and summarize in user friendly report, while allowing developers to use all of the standard development tools to maintain them.

Features

  • Native support for refactoring, code analysis (like finding unused methods), test running and all features that Visual Studio / Intellisense / Resharper offer during code development,
  • Easy to read scenario definitions,
  • Scenario steps execution tracking and time measurement, usable during longer test execution,
  • Support for parameterized steps with smart rules of inserting argument values to formatted step name,
  • Support for advanced in-line and tabular verifiable parameters,
  • Support for contextual scenario execution where steps shares dedicated context,
  • Support for DI containers,
  • Feature report generation in HTML, XML or Plain text format,
  • In-code LightBDD configuration allowing to customize all LightBDD features,
  • Productivity extensions for VisualStudio with Feature Class Templates, Project Templates and Code Snippets,
  • Integration with NUnit, xUnit, MsTest.TestFramework and Fixie frameworks,
  • Async scenario and steps execution support,
  • Cross-platform support (.NET Framework / .NET Standard / .NET Core / UWP).

Tests structure and conventions

LightBDD runs on top of NUnit, xUnit, MsTest.TestFramework and Fixie, allowing to leverage the well known test frameworks and their features in writing the behavioral style scenarios, which makes it very easy to learn, adapt and use.

To learn more, please see LightBDD wiki page, or jump straight to:

  • Quick Start and followup documentation pages,
  • What Is New section with the newest features introduced in the library,
  • Examples demonstrating features and integrations of LightBDD,
  • Tutorials with complete sample projects using LightBDD features.

Example

[FeatureDescription(
@"In order to access personal data
As an user
I want to login into system")] //feature description
[Label("Story-1")]
public partial class Login_feature //feature name
{
   [Scenario]
   [Label("Ticket-1")]
   public void Successful_login() //scenario name
   {
      Runner.RunScenario(

         Given_the_user_is_about_to_login, //steps
         Given_the_user_entered_valid_login,
         Given_the_user_entered_valid_password,
         When_the_user_clicks_login_button,
         Then_the_login_operation_should_be_successful,
         Then_a_welcome_message_containing_user_name_should_be_returned);
   }
}

[FeatureDescription(
@"In order to pay for products
As a customer
I want to receive invoice for bought items")] //feature description
[Label("Story-2")]
public partial class Invoice_feature //feature name
{
   [Scenario]
   [Label("Ticket-2")]
   public void Receiving_invoice_for_products() //scenario name
   {
      Runner.RunScenario(

         _ => Given_product_is_available_in_product_storage("wooden desk"), //steps
         _ => Given_product_is_available_in_product_storage("wooden shelf"),
         _ => When_customer_buys_product("wooden desk"),
         _ => When_customer_buys_product("wooden shelf"),
         _ => Then_an_invoice_should_be_sent_to_the_customer(),
         _ => Then_the_invoice_should_contain_product_with_price_of_AMOUNT("wooden desk", 62),
         _ => Then_the_invoice_should_contain_product_with_price_of_AMOUNT("wooden shelf", 37));
   }
}

The above example shows feature partial classes containing scenario definitions only, which makes it easier to read.
The Login_feature class uses basic scenario format for defining scenario steps.
The Invoice_feature class uses extended scenario format allowing to use parameterized steps.
LightBDD offers multiple scenario formats and flavors suitable for various use cases - for details, please check Scenario Steps Definition page.

The implementation of step methods is located in other part of the class, in separate file and leverages standard features of the underlying test framwork (such as assert mechanisms) empowered by LightBDD features such as:

Example console output during tests execution:

What LightBDD offers for free is the scenario output provided in Visual Studio/Resharper test screens and/or Console window.
Where possible, the output is provided as the test executes, allowing to track the progress of the scenarios.

FEATURE: [Story-1] Login feature
  In order to access personal data
  As an user
  I want to login into system

SCENARIO: [Ticket-1] Successful login
  STEP 1/6: GIVEN the user is about to login...
  STEP 1/6: GIVEN the user is about to login (Passed after 2ms)
  STEP 2/6: AND the user entered valid login...
  STEP 2/6: AND the user entered valid login (Passed after <1ms)
  STEP 3/6: AND the user entered valid password...
  STEP 3/6: AND the user entered valid password (Passed after <1ms)
  STEP 4/6: WHEN the user clicks login button...
  STEP 4/6: WHEN the user clicks login button (Passed after 125ms)
  STEP 5/6: THEN the login operation should be successful...
  STEP 5/6: THEN the login operation should be successful (Passed after 4ms)
  STEP 6/6: AND a welcome message containing user name should be returned...
  STEP 6/6: AND a welcome message containing user name should be returned (Passed after 9ms)
  SCENARIO RESULT: Passed after 164ms


FEATURE: [Story-2] Invoice feature
  In order to pay for products
  As a customer
  I want to receive invoice for bought items

SCENARIO: [Ticket-4] Receiving invoice for products
  STEP 1/7: GIVEN product "wooden desk" is available in product storage...
  STEP 1/7: GIVEN product "wooden desk" is available in product storage (Passed after 2ms)
  STEP 2/7: AND product "wooden shelf" is available in product storage...
  STEP 2/7: AND product "wooden shelf" is available in product storage (Passed after <1ms)
  STEP 3/7: WHEN customer buys product "wooden desk"...
  STEP 3/7: WHEN customer buys product "wooden desk" (Passed after <1ms)
  STEP 4/7: AND customer buys product "wooden shelf"...
  STEP 4/7: AND customer buys product "wooden shelf" (Passed after <1ms)
  STEP 5/7: THEN an invoice should be sent to the customer...
  STEP 5/7: THEN an invoice should be sent to the customer (Passed after <1ms)
  STEP 6/7: AND the invoice should contain product "wooden desk" with price of "£62.00"...
  STEP 6/7: AND the invoice should contain product "wooden desk" with price of "£62.00" (Passed after <1ms)
  STEP 7/7: AND the invoice should contain product "wooden shelf" with price of "£37.00"...
  STEP 7/7: AND the invoice should contain product "wooden shelf" with price of "£37.00" (Passed after <1ms)
  SCENARIO RESULT: Passed after 30ms

For more information, please visit Test Progress Notification page.

Example HTML report generated after test execution:

When all tests are finished, LightBDD generates the HTML report file, providing the summary and the details of the executed scenarios - the fragment of the report is presented below.

To read more, please see Generating Reports wiki page.

Installation

The LightBDD is available on NuGet:

  • PM> Install-Package LightBDD.NUnit3 for package using NUnit 3x
  • PM> Install-Package LightBDD.XUnit2 for package using xUnit 2x
  • PM> Install-Package LightBDD.MsTest2 for package using MsTest.TestFramework
  • PM> Install-Package LightBDD.Fixie2 for package using Fixie 2x

Productivity Extensions for Visual Studio

LightBDD project offers also a VSIX extension for Visual Studio, containing:

The VSIX extension can be downloaded from: Visual Studio Gallery (Visual Studio 2012 and newer versions supported).

Migrating LightBDD

The current LightBDD version series is 3.X. To find out how to migrate from previous versions, please visit Migrating LightBDD Versions wiki page.

Debugging LightBDD from NuGet packages

LightBDD provides debug symbols helping with diagnostics - please check Debugging LightBDD Scenarios for details.

More information about LightBDD

If you are interested about background of LightBDD creation or getting insight into what is driving it's evolution, please feel free to take a look at my blog posts.