0

I been working on creating tests for API's. I wanted to write tests in both Java and .Net and I started of with Java using Cucumber and Rest Assured Library. Now when I am trying to write the same tests with .Net using Specflow, But I want to reuse the same feature files that the Java Project is using and write step definitions for it.

Is it possible that I can define the location of the feature files for a Specflow project? Something like Glue with Cucumber wherein I can specify my feature files location?

My Project has the following three folders,

JavaTestCases FeatureFiles DotnetTestCases

Tests in the JavaTestCases are able to refer to the feature files from FeatureFiles folder using glue but I am unable to do so for the DotnetTestCases.

Tried researching for alternatives on Google but seems like I did not find anything as an equivalent of glue in Specflow

1 Answers1

0

Yes you can, but SpecFlow requires entries in the .csproj file for your test project. It will likely be a manual copy and paste operation in Visual Studio.

Being that you have multiple APIs or applications, I find it hard to believe that the feature files are truly reusable. If they are, how can the other components be justified?

The fact you can reuse feature files now may be coincidence only. I think this is one of the cases where copy and paste might actually prevent headaches later on.

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
  • I am just trying to compare the functioning of the two languages namely C# and Java. Thereby, I have written the same API tests in both Dotnet and Java. Which is why I just want to drive the step definitions from a single feature file for both of them. Replicating them would be my least preferred option here. – Vishal Mangwani Jun 20 '19 at 06:19
  • SpecFlow will only generate the C# code-behind files for feature files referenced in a project. This might sound crazy, but maybe you could create a NuGet package of your feature files. Installing the NuGet package would certainly put references to those files in your project, and then you can use the SpecFlow.exe command in `packages/SpecFlow-VERSION/tools` to regenerate the code behind files. I'm actually wondering if you could write a "post-install" PowerShell script for the NuGet package that does this automatically. – Greg Burghardt Jun 20 '19 at 11:30
  • 1
    Here is an old Google Groups thread about a feature request to regenerate the code behind files in SpecFlow on individual files: https://groups.google.com/forum/#!topic/specflow/CVfBDP9nxdw – Greg Burghardt Jun 20 '19 at 11:30