Wednesday, December 3, 2014

SpecFlow: Visual Studio does not recognize steps in another assembly

On my current project we are using SpecFlow to create our BDD style tests. I really like the experience so far. One of the things that you have to understand when using SpecFlow is that the end goal is a set of re-usable steps that allow you to specify new scenario’s (and tests) fast.

specflow_logo

In our case we already have a set of steps that we want to re-use in multiple test projects. Therefore I created a separate assembly where I put some of my shared steps classes.This is a supported scenario inside Specflow, the only thing you need to do is to specify the assembly name inside your app.config:

<specFlow>
    <!-- For additional details on SpecFlow configuration options see
http://go.specflow.org/doc-config -->
    <stepAssemblies>
      <stepAssembly assembly="Tests.SharedSteps" />
    </stepAssemblies>
    <unitTestProvider name="MsTest" />
  </specFlow>

However when I opened a SpecFlow feature file that should use one of the shared steps, the steps showed up purple (which means that SpecFlow is unable to find the step).

SpecFlowFeature

It took me some time to figure out a solution. Here is how I did it:

  • Close all your .feature documents in Visual Studio.
  • Close Visual Studio.
  • Go to the %TEMP% folder. Delete the SpecFlow cache files.
  • Open Visual Studio again.
  • Open your .feature files again.

That did the trick for me…

No comments: