Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute SpecFlow specs (.feature files) without compilation

Tags:

specflow

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.

like image 257
THX-1138 Avatar asked Dec 14 '11 14:12

THX-1138


People also ask

What are the 2 files required to execute a SpecFlow test scenario?

In order to execute your SpecFlow tests, you need to define the tests as Gherkin feature files, bind the steps defined in your feature files to your code, and configure a unit test provider to execute the tests.

How do you regenerate SpecFlow feature files?

The only way to regenerate it is to right-click on the project containing specs and choose "Regenerate Feature Files". This action regenerates all feature files, which becomes slow when a project has many feature files.

How do I ignore scenario in SpecFlow?

Just like with normal unit tests, you can also ignore SpecFlow tests. To do so, tag the feature or scenario with the @ignore tag.


1 Answers

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

like image 151
Marcus Hammarberg Avatar answered Sep 22 '22 06:09

Marcus Hammarberg