---
title: 'Other BDD Frameworks: Behave and Reqnroll | TestingBot'
description: Gherkin is a shared format, so the same feature file can be executed
  in many languages. This chapter runs the &quot;wrong credentials&quot; outline from…
source_url:
  html: https://testingbot.com/resources/courses/cucumber-bdd/behave-and-reqnroll
  md: https://testingbot.com/resources/courses/cucumber-bdd/behave-and-reqnroll.md
---

Course

[BDD with Cucumber: Gherkin to CI](https://testingbot.com/resources/courses/cucumber-bdd)

Chapter 10 of 12

1. [1 Cucumber BDD Tutorial: From Gherkin to CI](https://testingbot.com/resources/courses/cucumber-bdd)
2. [2 BDD Testing Starts Before the Code: Three Amigos](https://testingbot.com/resources/courses/cucumber-bdd/bdd-collaboration)
3. [3 Writing Good Gherkin: Declarative Scenarios](https://testingbot.com/resources/courses/cucumber-bdd/writing-good-gherkin)
4. [4 Cucumber with Java and Selenium: First Scenario](https://testingbot.com/resources/courses/cucumber-bdd/cucumber-java-selenium)
5. [5 Step Definitions, Cucumber Expressions, Parameter Types](https://testingbot.com/resources/courses/cucumber-bdd/step-definitions)
6. [6 Hooks and Sharing State with PicoContainer](https://testingbot.com/resources/courses/cucumber-bdd/hooks-and-shared-state)
7. [7 Scenario Outlines, Tags and Background](https://testingbot.com/resources/courses/cucumber-bdd/outlines-tags-background)
8. [8 Cucumber-JS with Playwright](https://testingbot.com/resources/courses/cucumber-bdd/cucumber-js-playwright)
9. [9 Parallel Runs, Reports and CI on TestingBot](https://testingbot.com/resources/courses/cucumber-bdd/parallel-reports-ci)
10. [10 Other BDD Frameworks: Behave and Reqnroll](https://testingbot.com/resources/courses/cucumber-bdd/behave-and-reqnroll)
11. [11 BDD Anti-Patterns and How to Fix Them](https://testingbot.com/resources/courses/cucumber-bdd/bdd-anti-patterns)
12. [12 Knowledge check](https://testingbot.com/resources/courses/cucumber-bdd/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 10 of 12 Intermediate 7 min read 2 quick checks Updated Nov 2026 

# Other BDD Frameworks: Behave and Reqnroll
On this page
1. [Behave (Python)](https://testingbot.com#behave-python)
2. [SpecFlow and Reqnroll (.NET)](https://testingbot.com#specflow-and-reqnroll-net)
3. [What carried over](https://testingbot.com#what-carried-over)

Gherkin is a shared format, so the same feature file can be executed in many languages. This chapter runs the "wrong credentials" outline from chapter 6 with two popular alternatives to Cucumber itself: **Behave** for Python and **Reqnroll** for .NET. Both are separate open-source projects that read Gherkin; neither is maintained by the Cucumber team. The point is to show what stays the same (almost everything) and what changes (how steps get their arguments and their state).

The feature file is identical for both:

```gherkin
Feature: Signing in to the secure area

  Scenario Outline: Wrong credentials are rejected
    When someone signs in as "<username>" with password "<password>"
    Then the sign-in is rejected because the <field> is invalid

    Examples:
      | username | password | field |
      | tomsmith | not-his-password | password |
      | tomjones | SuperSecretPassword! | username |
```

## Behave (Python)[#](https://testingbot.com#behave-python)

Behave expects `features/` with the `.feature` files, `features/steps/` with step modules, and an optional `features/environment.py` for hooks.

```bash
python3 -m venv .venv
.venv/bin/pip install behave==1.3.3 selenium==4.52.0
```

### Hooks and state: `environment.py`[#](https://testingbot.com#hooks-and-state-environment-py)

Behave's hooks are plain functions with fixed names (`before_all`, `before_feature`, `before_scenario`, `after_step` and so on). Shared state goes on the `context` object, which Behave passes to every hook and step. Attributes you set during a scenario are removed when the scenario ends, which gives you the same per-scenario isolation as the World in Cucumber-JS.

```python
import os

from selenium import webdriver

def before_scenario(context, scenario):
    if os.environ.get("GRID") == "testingbot":
        options = webdriver.ChromeOptions()
        options.browser_version = "latest"
        options.platform_name = os.environ.get("TB_PLATFORM", "WIN11")
        options.set_capability("tb:options", {
            "name": scenario.name,
            "build": os.environ.get("TB_BUILD", "local"),
        })
        hub = f"https://{os.environ['TB_KEY']}:{os.environ['TB_SECRET']}@hub.testingbot.com/wd/hub"
        context.driver = webdriver.Remote(command_executor=hub, options=options)
    else:
        options = webdriver.ChromeOptions()
        options.add_argument("--headless=new")
        context.driver = webdriver.Chrome(options=options)

def after_scenario(context, scenario):
    try:
        if os.environ.get("GRID") == "testingbot":
            status = "passed" if scenario.status.name == "passed" else "failed"
            context.driver.execute_script(f"tb:test-result={status}")
    finally:
        context.driver.quit()
```

Only an explicit `passed` is reported as passed: a scenario that ended `undefined`, `skipped` or `untested` checked nothing, so it must not show up green on the dashboard.

### Steps: `features/steps/sign_in_steps.py`[#](https://testingbot.com#steps-features-steps-sign_in_steps-py)

Behave's default step matcher uses `parse`-style patterns: `{username}` captures text, and quotes in the pattern are matched literally. The decorators are `@given`, `@when` and `@then`.

```python
from behave import then, when
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

MESSAGES = {
    "username": "Your username is invalid!",
    "password": "Your password is invalid!",
}

@when('someone signs in as "{username}" with password "{password}"')
def step_sign_in(context, username, password):
    driver = context.driver
    driver.get("https://the-internet.herokuapp.com/login")
    driver.find_element(By.ID, "username").send_keys(username)
    driver.find_element(By.ID, "password").send_keys(password)
    driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click()

@then("the sign-in is rejected because the {field} is invalid")
def step_rejected(context, field):
    flash = WebDriverWait(context.driver, 10).until(
        EC.visibility_of_element_located((By.ID, "flash"))
    )
    assert MESSAGES[field] in flash.text, flash.text
```

Run it locally with `.venv/bin/behave`, and on the grid with:

```bash
GRID=testingbot TB_BUILD=behave-course .venv/bin/behave
```

```
1 feature passed, 0 failed, 0 skipped
2 scenarios passed, 0 failed, 0 skipped
4 steps passed, 0 failed, 0 skipped
```

On TestingBot the two rows ran as `fbaf9ee65502-b237cd7c19eb-a1cc8477e669-179455818250-38612372` and `56716aa15b1f-4035d7368858-325a50656a00-179455819132-72286370`, both marked as passed. Behave names outline rows after the outline plus the row, for example "Wrong credentials are rejected -- @1.1", so the dashboard shows which row a session ran. The [Behave docs page](https://testingbot.com/support/web-automate/selenium/python/behave) has more capabilities and a parallel example repository. If your team writes Python but does not need Gherkin, the [Selenium Python course](https://testingbot.com/resources/courses/selenium-python) with pytest is the simpler route; `pytest-bdd` is a third option that runs Gherkin scenarios as pytest tests.

In Behave, where does the WebDriver created in `before_scenario` live so that steps can use it?

 In a module-level global in `environment.py` In a dependency injection container In the step function's default arguments On the `context` object that Behave passes to every hook and step

The `context` is Behave's per-run state object; attributes set during a scenario are cleaned up when it ends. A module global would leak between scenarios.

## SpecFlow and Reqnroll (.NET)[#](https://testingbot.com#specflow-and-reqnroll-net)

For years the .NET BDD tool was **SpecFlow**. Its owner, Tricentis, announced in December 2024 that SpecFlow reached end of life on **31 December 2024** ; specflow.org stated that "SpecFlow will no longer be available after December 31, 2024", and the SpecFlow GitHub projects were removed in January 2025 ([Reqnroll's announcement, 9 January 2025](https://reqnroll.net/news/2025/01/specflow-end-of-life-has-been-announced/)). Existing NuGet packages still install, but receive no fixes.

**Reqnroll** is the community fork of the SpecFlow codebase, started in early 2024 by people from the original SpecFlow team and renamed because Tricentis holds the SpecFlow trademark. It is very close to SpecFlow, so migration is mostly a package and namespace change; the [Reqnroll docs page](https://testingbot.com/support/web-automate/selenium/csharp/reqnroll) has a migration section, and the [SpecFlow page](https://testingbot.com/support/web-automate/selenium/csharp/specflow) remains for existing projects. Start new projects on Reqnroll.

### Project[#](https://testingbot.com#project)

A test project with Reqnroll on NUnit (xUnit and MSTest packages exist too):

```xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <IsPackable>false</IsPackable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
    <PackageReference Include="NUnit" Version="4.6.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="6.3.1" />
    <PackageReference Include="Reqnroll.NUnit" Version="3.3.4" />
    <PackageReference Include="Selenium.WebDriver" Version="4.52.0" />
    <PackageReference Include="Selenium.Support" Version="4.52.0" />
  </ItemGroup>
</Project>
```

Reqnroll generates an NUnit test for every scenario at build time, so `dotnet test` runs the feature files like any other tests.

### Hooks and state[#](https://testingbot.com#hooks-and-state)

Reqnroll has a built-in dependency injection container, so it works like PicoContainer in chapter 5: classes marked `[Binding]` receive what they need in their constructor, one instance per scenario. A hook can also register an object it created, so that step classes can ask for it:

```csharp
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
using Reqnroll;
using Reqnroll.BoDi;

namespace SignIn.Specs.Support;

[Binding]
public class BrowserHooks(IObjectContainer container, ScenarioContext scenario)
{
    private static bool OnTestingBot => Environment.GetEnvironmentVariable("GRID") == "testingbot";

    [BeforeScenario]
    public void StartBrowser()
    {
        var options = new ChromeOptions();
        IWebDriver driver;
        if (OnTestingBot)
        {
            options.BrowserVersion = "latest";
            options.PlatformName = Environment.GetEnvironmentVariable("TB_PLATFORM") ?? "WIN11";
            options.AddAdditionalOption("tb:options", new Dictionary<string, object>
            {
                ["key"] = Environment.GetEnvironmentVariable("TB_KEY")!,
                ["secret"] = Environment.GetEnvironmentVariable("TB_SECRET")!,
                ["name"] = scenario.ScenarioInfo.Title,
                ["build"] = Environment.GetEnvironmentVariable("TB_BUILD") ?? "local",
            });
            driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"), options);
        }
        else
        {
            options.AddArgument("--headless=new");
            driver = new ChromeDriver(options);
        }
        container.RegisterInstanceAs(driver);
    }

    [AfterScenario]
    public void StopBrowser(IWebDriver driver)
    {
        try
        {
            if (OnTestingBot)
            {
                var status = scenario.TestError == null ? "passed" : "failed";
                ((IJavaScriptExecutor)driver).ExecuteScript($"tb:test-result={status}");
            }
        }
        finally
        {
            driver.Quit();
        }
    }
}
```

Here the key and secret travel in `tb:options` instead of the hub URL; TestingBot accepts both. `ScenarioContext.TestError` is set when any step threw, which is how the hook knows the result.

### Steps[#](https://testingbot.com#steps)

Reqnroll supports Cucumber expressions, so the patterns look exactly like the Java ones. `{word}` captures a single word:

```csharp
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using Reqnroll;

namespace SignIn.Specs.StepDefinitions;

[Binding]
public class SignInSteps(IWebDriver driver)
{
    [When("someone signs in as {string} with password {string}")]
    public void WhenSomeoneSignsIn(string username, string password)
    {
        driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/login");
        driver.FindElement(By.Id("username")).SendKeys(username);
        driver.FindElement(By.Id("password")).SendKeys(password);
        driver.FindElement(By.CssSelector("button[type=submit]")).Click();
    }

    [Then("the sign-in is rejected because the {word} is invalid")]
    public void ThenRejected(string field)
    {
        var flash = new WebDriverWait(driver, TimeSpan.FromSeconds(10))
            .Until(d => d.FindElement(By.Id("flash")));
        Assert.That(flash.Text, Does.Contain($"Your {field} is invalid!"));
    }
}
```

Run it with `dotnet test` locally, and on the grid with:

```bash
GRID=testingbot TB_BUILD=reqnroll-course dotnet test
```

```
Passed! - Failed: 0, Passed: 2, Skipped: 0, Total: 2
```

On TestingBot: `5c7e26c142c2-72fb58488648-e43eff9ea3d4-179455822460-97054822` and `abbcac9c0329-b8af0a4a4ea7-c6f3ca48770d-179455823205-47512111`, both passed. Reqnroll gives both rows the outline title, which is one more reason to put a placeholder in it (chapter 6).

A team is starting a new .NET project and wants Gherkin scenarios. What should they use?

 SpecFlow, because most tutorials still use it Reqnroll, the maintained fork; SpecFlow reached end of life on 31 December 2024 Cucumber-JVM through a .NET bridge

SpecFlow packages still install but get no fixes. Reqnroll continues the same codebase under a new name and accepts SpecFlow-style projects with small changes.

## What carried over[#](https://testingbot.com#what-carried-over)

| Concept | Cucumber-JVM | Cucumber-JS | Behave | Reqnroll |
| --- | --- | --- | --- | --- |
| Per-scenario state | PicoContainer (DI) | World (`this`) | `context` | Built-in DI |
| Step patterns | Cucumber expressions | Cucumber expressions | `parse` patterns | Cucumber expressions |
| Before/after scenario | `@Before` / `@After` | `Before` / `After` | `before_scenario` / `after_scenario` | `[BeforeScenario]` / `[AfterScenario]` |
| Result for the hook | `Scenario.isFailed()` | `result.status` | `scenario.status` | `ScenarioContext.TestError` |

The skills that matter most, discovery and writing good Gherkin, do not depend on the tool at all.

[Previous · Chapter 9 Parallel Runs, Reports and CI on TestingBot](https://testingbot.com/resources/courses/cucumber-bdd/parallel-reports-ci) [Next · Chapter 11 BDD Anti-Patterns and How to Fix Them](https://testingbot.com/resources/courses/cucumber-bdd/bdd-anti-patterns)

On this page

1. [Behave (Python)](https://testingbot.com#behave-python)
2. [SpecFlow and Reqnroll (.NET)](https://testingbot.com#specflow-and-reqnroll-net)
3. [What carried over](https://testingbot.com#what-carried-over)

Certification

Earn the free, resume-worthy TestingBot Cucumber BDD Certification for this course.

[How it works](https://testingbot.com/resources/courses/cucumber-bdd/certification)
