Reqnroll Documentation

repository·main·Indexed 20 days ago

https://github.com/reqnroll/reqnroll

An open-source .NET test automation tool for Behavior Driven Development (BDD) based on the SpecFlow framework and a .NET port of Cucumber. It supports writing executable specifications in Gherkin format and integrates with MsTest, NUnit, xUnit, and TUnit. Key features include asynchronous step definitions, context injection via IObjectContainer, Cucumber Expressions, and support for external binding assemblies. Compatible with .NET Framework 4.6.2+ up to .NET 10.0 across Windows, Linux, and macOS.

Tokens
66.6K
Snippets
179
Records
289
Agent score
73%

What's inside Reqnroll

  1. Overview of Reqnroll BDD capabilities

    main

    Reqnroll is an open-source .NET tool for Behavior Driven Development (BDD). It is a .NET port of Cucumber and is based on the SpecFlow framework.

    Key features include:

    • Gherkin Support: Write executable specifications using .feature files in the Given-When-Then style.
    • Cross-Platform: Works on Windows, Linux, and macOS.
    • Runtime Compatibility: Supports .NET Framework 4.6.2+ up to .NET 10.0.
    • Test Framework Integration: Supports MsTest, NUnit, xUnit, and TUnit.
    • IDE Support: Compatible with Visual Studio 2022, Visual Studio Code, and Rider, though it can be used without an IDE.
  2. What is Reqnroll?

    main

    Reqnroll is an open-source .NET test automation tool designed for Behavior Driven Development (BDD). It allows you to write executable specifications using the Gherkin format (feature files) with a Given-When-Then structure.

    Key characteristics:

    • Compatibility: Works on Windows, Linux, and macOS.
    • Runtime Support: Supports .NET Framework 4.6.2+ and .NET 8.0.
    • Test Runners: Integrates with MsTest, NUnit, TUnit, or xUnit to execute automated scenarios.
    • SpecFlow Heritage: Reqnroll is a .NET port of Cucumber and is based on the SpecFlow framework and codebase, making it easy for SpecFlow users to transition.
  3. Visual Studio Extension Feature Overview

    main

    The Reqnroll Visual Studio extension enhances the development experience for Gherkin feature files and their associated step definitions. Key capabilities include:

    Editing Feature Files

    • Gherkin Syntax Highlighting: Visual cues for syntax, including highlighting unbound steps and parameters.
    • IntelliSense: Auto-completion for Gherkin keywords and existing steps.
    • Outlining: Ability to fold/unfold sections of feature files.
    • Comments: Support for commenting and uncommenting lines within feature files.
    • Formatting: Automatic Gherkin table formatting and general document formatting.
    • Refactoring: Support for renaming steps.
    • Bi-directional Navigation: Jump between steps in scenarios and their corresponding step definition methods in C# code.
    • Hook Navigation: Navigate from scenarios to hook methods.
    • Discovery: Find unused step definitions that are not yet bound to any scenario steps.
    • Project Awareness: The extension detects step definitions within the Reqnroll project to enable navigation and indicate the binding status of steps.

    Productivity & Configuration

    • Code Generation: Generate C# code snippets for step definition methods directly from feature files.
    • Customization: Configurable extension settings and Gherkin formatting via .editorconfig.
  4. What is the Page Object Model (POM)?

    main

    The Page Object Model (POM) is a design pattern used to abstract Web UI automation (typically with Selenium). Instead of calling FindElement or FindElements directly within your test code, you encapsulate these calls inside Page Object classes.

    Advantages of POM:

    • Reusability: Classes can be reused across different test scenarios.
    • Maintainability: If an element's id or selector changes, you only need to update it in one place.
    • Decoupling: Your automation logic becomes less dependent on the specific HTML structure.
  5. What is a Build Metadata Provider?

    main
    Reqnroll uses IBuildMetadataProvider to extract build and source control information (like build URLs, commit hashes, and branch names) from CI/CD environments. While Reqnroll has built-in support for common systems like GitHub Actions, Azure Pipelines, and Jenkins, you can implement your own provider to support custom or unsupported build systems. The extracted data is stored in a BuildMetadata record.
  6. What is the Driver Pattern and when to use it

    main

    The Driver Pattern is an architectural layer placed between your step definitions (bindings) and your automation code (e.g., Page Objects or low-level drivers).

    Instead of putting complex logic, switches, or multiple assertions directly inside a [Binding] class, you move that logic into a dedicated 'Driver' class. The step definition then calls a single, descriptive method on the Driver.

    Benefits include:

    • Easier Maintenance: Splitting code into smaller, specialized parts makes it easier to manage.
    • Reusability: Driver methods can be easily reused across different step definitions or chained together to form new steps.
    • Readability: Step definitions become very short (ideally ~10 lines) and use human-readable method names, making them understandable even to non-technical stakeholders.
  7. What is Dry Run mode in Reqnroll

    main

    Dry Run mode allows you to execute your test suite without actually running the code inside your step handlers. When enabled, Reqnroll validates that every step declared in your .feature files has a corresponding matching step handler in your C# code, but skips the execution of the handler logic itself.

    Common Use Cases:

    • CI/PR Validation: Quickly verify that all feature file steps are correctly bound to step definitions without the time/cost of full execution.
    • Reporting & Analysis: When paired with Formatters, you can generate reports containing feature names, scenario lists, and used/unused step definition bindings.

    Best Practice: Pair Dry Run mode with the runtime configuration option "missingOrPendingStepsOutcome": "Error" to ensure that any unbound (missing) steps are reported as errors rather than being silently ignored.

  8. Understanding FeatureContext vs ScenarioContext

    main

    Reqnroll provides two primary ways to access test context, distinguished by their lifecycle:

    • FeatureContext: Persists for the duration of an entire feature (all scenarios within a single .feature file).
    • ScenarioContext: Persists only for the duration of a single scenario.

    Use FeatureContext when you need to share state or metadata across multiple scenarios within the same feature.

  9. Use the Feature Container for feature-level state

    main

    The Feature Container captures the execution state of a single feature. It is disposed once the feature execution is complete. Its parent is the Test Thread Container.

    Key services available in the Feature Container:

    • FeatureContext (Note: This is also accessible from the Test Thread Container via IContextManager)

    Extension Points:

    • CustomizeFeatureDependencies (Event)
  10. How Step Argument Conversions work

    main

    Reqnroll automatically converts step arguments (strings or Reqnroll.DataTable instances) into the specific parameter types defined in your step binding methods. This prevents the need for manual parsing inside your step definitions.

    Conversions are performed using the culture of the feature file, unless a specific binding setting is defined in your reqnroll.json configuration file.

    When a conversion is requested, Reqnroll follows this precedence order:

    1. No conversion: If the argument is already an instance of the parameter type (e.g., string or object).
    2. Step argument transformation: Custom logic defined via the [StepArgumentTransformation] attribute.
    3. Standard conversion: Built-in Reqnroll conversion logic.
  11. How Reqnroll detects Cucumber Expressions vs Regular Expressions

    main

    Reqnroll uses heuristics to automatically determine if a step definition attribute uses a Cucumber Expression or a Regular Expression. The detection order is:

    1. Force Regular Expression: If the string starts with ^ or ends with $.
    2. Force Cucumber Expression: If the string contains parameter placeholders like {int}, {string}, etc.
    3. Regular Expression patterns: If the string contains common regex patterns like (.*), (a+), \d+, or \..
    4. Default: If none of the above match, it is treated as a Cucumber Expression.