manzoor md
manzoor md

Reputation: 21

BDD with Specflow in Visual Studio 2017 -featurefile Error CS1029

I am trying out BDD with Specflow in Visual Studio 2017. Previously I had created a new project and added Specflow and Nunit using NuGet Package Manager. From the Solution Explorer, I right click and select Add New Item. From the Add New Item window, I could see SpecFlow feature File and Feature.cs file

But I open the Feature.cs it's showing empty with the message

<#error Generation error: The element may only appear once in this section.>

Then I try to build the solution then I'm getting error on Output

Error CS1029

error: 'Generation error: The element may only appear once in this section.'

The references I can see from Solution Explorer are: SpecRun.SpecFlowPlugin TechTalk.SpecFlow TechTalk.SpecRun NUnit.VisualStudio.TestAdapter

Am I missing something?

Thanks, Mohammed

Upvotes: 1

Views: 1414

Answers (2)

manzoor md
manzoor md

Reputation: 21

If you have a scenario outline, but you for get to write the Examples-Keyword, you will get the following error during the build process:

CS1029 #error: 'Generation error: Sequence contains no elements' in Line 1 of MyFeature.feature

It took me some hours in my large created feature file to locate my error. I deleted the temp files, restarted visual studio several times, but it was difficult to figure out why it occurs.

Could you somehow improve the error messages e.g. with a better location, a simple syntax check before or something similar?

As far as I understand, the ScenarioOutline, followed by a will allways need at least an Examples keyword and a table with this varname, before an other Tag like Scenario, etc. is allowed again. I would appreciate to have such markup

Upvotes: 1

manzoor md
manzoor md

Reputation: 21

?xml version="1.0" encoding="utf-8"?>
configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
  <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --><!-- use unit test provider SpecRun+NUnit or SpecRun+MsTest for being able to execute the tests with SpecRun and another provider --><unitTestProvider name="SpecRun" /><plugins>
      <add name="SpecRun" />
    </plugins></specFlow>
</configuration>

Upvotes: 0

Related Questions