8
votes

I want to be able to execute given SpecFlow (Gherkin) .feature file locally without doing compilation.

So workflow would be (as a Business Analyst or a QA engineer):
1. modify .feature file (using predefined vocabulary of steps)
2. run

SpecFlowSuperTool.exe
    /feature:.\FoobarprojectSpecs.feature
    /assembly:Foobarproject.dll,Foobarproject.Core.dll
  1. get a report

Goal is to be able to execute feature on-demand without having to recompile the code if only features have changed.

It feels like it should be a pretty straight-forward task to implement such a tool since Gherkin steps binding happens at run-time (judging by the NUnit code generated by SpecFlow).

I do understand that generate->compile->run scenario is supported already, but compile step seems unnecessary in some cases.

UPDATE I ended up coding the tool myself. SpecFlow API is very simple, it was pretty easy to build a specflowrunner.exe that would take a directory or a file + configuration file, and execute .feature files directly, without creating a unit tests first.

1
I don't see how this can be possible. A new scenario requires a new NUnit test to be generated, so compilation is required. A change to an existing scenario requires the existing test to run statements in a different order so a change to the code and so compilation. How exactly do you imagine this working?Sam Holder
Generating unit tests is not necessary. It was pretty straightforward do build a console app that consumes .feature files and executes them directly, rather than taking a unit-test-generation detour.THX-1138
@THX-1138, Can you share the code? I would like SpecFlow to pick up the .feature files from a directory, directly without generating a feature.cs file. I have a similar question on SO herestamhaney
@THX-1138 I very much would like to use your tool. I have thought of the same and searching for possible implementation. Is this on Github?rdagumampan
I was able to do this by xUnitAdapter and its documented here rdagumampan.com/post/2018/06/…rdagumampan

1 Answers

3
votes

You're talking about SpecFlow.exe ;)

Actually there's a few steps involved and I blogged about it using MsTest about a year ago.

The basic steps are:

  1. Use SpecFlow.exe (with switch generateall) to generate tests from the .feature files.
  2. Run tests and create a report. In my example i'm using MsTest but NUnit will work just fine.
  3. Use SpecFlow.exe again (with switch mstestexecutionreport in my case) to generate the report.

You are more than welcome to use my batfiles if you want

Good luck