About LightBDD 

lightbdd-logo

LightBDD is a lightweight BDD testing framework. We use it to be able to mix the pros of the behavior driven development (testing), and the purity of the NUnit framework. It contains the beneficial things of BDD, like making the test more reusable and readable, helping the junior colleagues or manual testers identify what is being tested in that code block; and also letting us use all of the native features of NUnit and C# (very lightweight). We can use LightBDD attributes and functionalities alongside with NUnit features, so this is giving us great flexibility in our code. 

How we use it and for what 

It is mainly used to organize our code, and allow better readability. It also allow us to generate descriptive reports. We separate our LightBDD code base from other parts of our code by putting it in a separate (example: Tests) folder. 

We are also using different coding approach when we write LightBDD code (trying to separate the test files from the actual logic as much as possible.

Installation 

install

You only need to download the LightBDD.NUnit3  By Wojciech Kotlarski) nuget package (it’ll download the Core and Framework packages also). You can also install the LightBDD.NUnit 3 Visual Studio Extension, but that’s not a necessity, it just helps you generating LightBDD files. 

Implementation details 

nunit-logo

We’re using LightBDD.NUnit 3 extension in Visual Studio. It helps by generating a general skeleton for the LightBDD files. 

The LightBDD works with two files for every feature file. The main is the blueprint (handles the BDD part of the tests with Scenarios, step names and order, etc), and the sub-part is the implementation for the steps. 

You can easily generate the skeleton by right clicking on a project or a folder, select Add –> New Item… and select LightBDD.NUnit3: Feature Test Class item from the list. Give it a name that represents the tested feature/part of your application/website and it will generate some general code. 

It’ll set the implementation part (which could named like: MainFileName.Steps.cs) dependent to the Blueprint file, and you can see it, by clicking on the arrow icon before the Blueprint file in the Solution Explorer Window. 

The implementation files must derive from the FeatureFixture class (or from a child of the FeatureFixture class). The Blueprint file and the Implementation file basically are the same class, because it’s using partial classes. 

In the Blueprint file we can set different labels for the feature (which is the class itself) and the scenarios. This can help to identify which is a specific test. 

You can also add FeatureDescription, which is a short description of the tested feature of the site. 

The scenario methods are marked with the Scenario attribute. 

More Information about the LighBDD  

If you’d like to read a more hands on manual with code and step by step implementation of the framework, please check out this link (the Setting up your test part and every other after it are about LightBDD, and how to implement it):