View on GitHub


Plugin will replace any substring from your step definition with custom value.

Build status


Create scenario

Given I use macro _today_
Then The value of _today_ shuld be the same

for one test scenario the value will be replaced with body of your function

Given I use macro 20/03/2018
Then The value of 20/03/2018 shuld be the same


Install Macro.SpecFlow NuGet package into your project with scenarios.

PS> Install-Package Macro.SpecFlow

After installing NuGet package your App.config is modified. Macro plugin will be registered in the specFlow section.

    <add name="Macro" type="Runtime" />


All settings are stored in Macro.SpecFlowPlugin.dll.config file which was added into your project by nuget installation.

Property Description
assembly - name name of the library where to search macro
    <section name="macroSpecFlow" type="Macro.SpecFlowPlugin.Config.MacroSpecFlowSection, Macro.SpecFlowPlugin, Version=, Culture=neutral, PublicKeyToken=null" />
      <assembly name="Project.Assembly.dll"/>

Custom macro

You can implement your own macro which will be used for replacing values. Add a class which implement IMacro interface and add attribute Pattern with your custom pattern. Now plugin will use your pattern while eunning.

class TodayMacro : IMacro
    public string Process(Match match)
        return DateTime.Now.ToString("d");

class RandomMacro : IMacro
    public string Process(Match match)
        var input = int.Parse(match.Groups["input"].Value);
        return new Random().Next(input).ToString();