SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.25k stars 754 forks source link

Specflow will not run with specrun #1475

Closed Nagendracv closed 5 years ago

Nagendracv commented 5 years ago

SpecFlow Version:

Used Test Runner

Version number: 3.0.255

Visual Studio Version

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

  <ConfigSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </ConfigSections>
...
  <specFlow>
    <unitTestProvider name="SpecRun" />
    <plugins>
      <add name="SpecRun" />
    </plugins>
  </specFlow>

Repro Project

Dont have one yet

Issue Description

On build, I get this below error Severity Code Description Project File Line Suppression State Error [SpecFlow] System.Configuration.ConfigurationErrorsException: Unrecognized element 'unitTestProvider'. at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey) at System.Configuration.ConfigurationSection.DeserializeSection(XmlReader reader) at TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler.CreateFromXml(String xmlContent) at TechTalk.SpecFlow.Configuration.ConfigurationLoader.Load(SpecFlowConfiguration specFlowConfiguration, ISpecFlowConfigurationHolder specFlowConfigurationHolder) at TechTalk.SpecFlow.Generator.Configuration.GeneratorConfigurationProvider.LoadConfiguration(SpecFlowConfiguration specFlowConfiguration, SpecFlowConfigurationHolder specFlowConfigurationHolder) at TechTalk.SpecFlow.Generator.Configuration.GeneratorConfigurationProviderExtensions.LoadConfiguration(IGeneratorConfigurationProvider configurationProvider, SpecFlowConfigurationHolder configurationHolder) at TechTalk.SpecFlow.Generator.Project.ProjectReader.ReadSpecFlowProject(String projectFilePath, String rootNamespace) SpecflowHeadless

Steps to Reproduce

Just build the project

Also Rt Click Regenerate Feature files does not generate any files.

Reinstalled specflow extension and packages. Same problem.

.Net Framework 4.6.2 adding a new feature file results in the following error in the generated feature file We could not find a data exchange file at the path TechTalk.SpecFlow.SpecFlowException: Unable to find plugin in the plugin search path: SpecRun. Please check http://go.specflow.org/doc-plugins for details.

Please open an issue at https://github.com/techtalk/SpecFlow/issues/ Complete output: TechTalk.SpecFlow.SpecFlowException: Unable to find plugin in the plugin search path: SpecRun. Please check http://go.specflow.org/doc-plugins for details. at TechTalk.SpecFlow.Generator.Plugins.GeneratorPluginLoader.LoadPlugin(PluginDescriptor pluginDescriptor) at TechTalk.SpecFlow.Generator.GeneratorContainerBuilder.<>cDisplayClass3.b1(PluginDescriptor pd) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.<ConcatIterator>d__591.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at TechTalk.SpecFlow.Generator.GeneratorContainerBuilder.CreateContainer(SpecFlowConfigurationHolder configurationHolder, ProjectSettings projectSettings) at TechTalk.SpecFlow.Generator.TestGeneratorFactory.CreateGenerator(ProjectSettings projectSettings) at TechTalk.SpecFlow.VisualStudio.CodeBehindGenerator.Actions.GenerateTestFileAction.GenerateTestFile(GenerateTestFileParameters opts)

Command: c:\users*\appdata\local\microsoft\visualstudio\15.0_1ec7ddd8\extensions\mweoz4iw.hhl\TechTalk.SpecFlow.VisualStudio.CodeBehindGenerator.exe Parameters: GenerateTestFile --featurefile C:\Users*\AppData\Local\Temp\tmpA015.tmp --outputdirectory C:\Users*\AppData\Local\Temp --projectsettingsfile C:\Users*\AppData\Local\Temp\tmpA014.tmp Working Directory:

Csproj Project details:

Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"

  <Import Project="..\..\..\packages\SpecRun.SpecFlow.3-0-0.3.0.255\build\SpecRun.SpecFlow.3-0-0.props" Condition="Exists('..\..\..\packages\SpecRun.SpecFlow.3-0-0.3.0.255\build\SpecRun.SpecFlow.3-0-0.props')" />
  <Import Project="..\..\..\packages\SpecRun.Runner.3.0.255\build\SpecRun.Runner.props" Condition="Exists('..\..\..\packages\SpecRun.Runner.3.0.255\build\SpecRun.Runner.props')" />
  <Import Project="..\..\..\packages\Microsoft.NET.Test.Sdk.15.0.0\build\net45\Microsoft.Net.Test.Sdk.props" Condition="Exists('..\..\..\packages\Microsoft.NET.Test.Sdk.15.0.0\build\net45\Microsoft.Net.Test.Sdk.props')" />
  <Import Project="..\..\..\packages\SpecFlow.Tools.MsBuild.Generation.3.0.188\build\SpecFlow.Tools.MsBuild.Generation.props" Condition="Exists('..\..\..\packages\SpecFlow.Tools.MsBuild.Generation.3.0.188\build\SpecFlow.Tools.MsBuild.Generation.props')" />
  <Import Project="..\..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.2\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.2\build\Microsoft.CodeQuality.Analyzers.props')" />
  <Import Project="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\build\Microsoft.CodeQuality.Analyzers.props')" />
  <Import Project="..\..\packages\xunit.core.2.3.1\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.3.1\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
  <Import Project="..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
  <Import Project="..\..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
Nagendracv commented 5 years ago

I removed xunit from the list above. And now I get a different error.:

SpecFlow designer codebehind generation is not compatible with MSBuild codebehind generation. The custom tool must be removed from the file. See http://www.specflow.org/documentation/Generate-Tests-from-MsBuild SpecflowHeadless C:***\Tests\Specflow\SpecFlowFeature1.feature

Nagendracv commented 5 years ago

Followed the steps to remove singlefilegenerator and I'm back to square one...

Error [SpecFlow] System.Configuration.ConfigurationErrorsException: Unrecognized element 'unitTestProvider'. at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey) at System.Configuration.ConfigurationSection.DeserializeSection(XmlReader reader) at TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler.CreateFromXml(String xmlContent) at TechTalk.SpecFlow.Configuration.ConfigurationLoader.Load(SpecFlowConfiguration specFlowConfiguration, ISpecFlowConfigurationHolder specFlowConfigurationHolder) at TechTalk.SpecFlow.Generator.Configuration.GeneratorConfigurationProvider.LoadConfiguration(SpecFlowConfiguration specFlowConfiguration, SpecFlowConfigurationHolder specFlowConfigurationHolder) at TechTalk.SpecFlow.Generator.Configuration.GeneratorConfigurationProviderExtensions.LoadConfiguration(IGeneratorConfigurationProvider configurationProvider, SpecFlowConfigurationHolder configurationHolder) at TechTalk.SpecFlow.Generator.Project.ProjectReader.ReadSpecFlowProject(String projectFilePath, String rootNamespace) SpecflowHeadless

SabotageAndi commented 5 years ago

With SpecFlow 3 you don't configure the unitTestProvider in the config anymore. This is done by the individual NuGet packages (see https://specflow.org/2019/updating-to-specflow-3/). You need to add https://www.nuget.org/packages/SpecRun.SpecFlow.3-0-0/ to your project and don't have SpecFlow.xUnit, SpecFlow.NUnit or SpecFlow.MsTest in your project, as you can only have one unit test provider.

Normally the update of the packages removes the entries in the app.config. In your case, this didn't happen. Simple remove the unit test provider and plugin setting from the app.config.

Nagendracv commented 5 years ago

The following documentations are then misleading. Please have it updated. https://specflow.org/plus/documentation/Migrating-to-SpecFlow-Runner/

also in https://specflow.org/2019/updating-to-specflow-3/ It needs to be updated that if the elements in app.config are not removed, it needs to be removed manually.

Nagendracv commented 5 years ago

Now I get the following erroe on running the runtests.cmd... 'SpecRun.exe' is not recognized as an internal or external command Which means specrun path has not got installed properly as well. Im using VS command prompt

Also tests are not showing up in test explorer. Clicking on run all tests (even though there are no tests) gives following error SpecFlow designer codebehind generation is not compatible with MSBuild codebehind generation. The custom tool must be removed from the file. See http://www.specflow.org/documentation/Generate-Tests-from-MsBuild Petpoint.SpecflowHeadless

Stephen-Mc commented 5 years ago

You need to remove the Custom Tool entry from your feature files, as described in the link in the error when using the MSBuild integration.

You are right, the migrating chapter in the documentation is out of date and no longer applies to SpecFlow 3. You need to install just one of the unit test provider packages (in this case SpecRun.Runner) to determine which unit test provider to use, rather than configuring the unit test provider in the config file.

Nagendracv commented 5 years ago

Thanks All! Finally managed to compile and restart the work on my project with specflow+ using Specflow 3.0. Though I still get the error... which is still fine as i know the path of specrun.exe 'SpecRun.exe' is not recognized as an internal or external command

SabotageAndi commented 5 years ago

@Nagendracv If you use <PackageReference> runtests.cmd can not work, as there is no local package folder.

vstest.console.exe and dotnet test are working for command line execution.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.