SpecFlow.VS
SpecFlow.VS copied to clipboard
The project bindings (e.g. step definitions) could not be discovered.
Used Visual Studio
Visual Studio 2022
Are the latest Visual Studio updates installed?
Yes
SpecFlow Section in app.config or content of specflow.json
Issue Description
I have created an Unit Test Project in visual studio the required references also added to the project level (NUnit, SpecFlow, BaseClass.Contrib.SpecFlow.Selenium.Nunit, SpecRun.Runner,Autofac, Autofac Configuration, SpecFlow.Assist.Dynamic etc.,). after creating a feature file when i try to create step definition by right clicking, it is showing the popup saying all steps are define already
Note: it is only happening with the Unit test Project structure.
Steps to Reproduce
- Create a Unit Test Project
- Create a feature folder and add the specflow feature file
- Write the gherkin scenario for the created feature file
- Install following packages (NUnit, SpecFlow, BaseClass.Contrib.SpecFlow.Selenium.Nunit, SpecRun.Runner,Autofac, Autofac Configuration, SpecFlow.Assist.Dynamic etc.,).
- Create a step definition file and move it to the step definition folder.
- save all and build the project.
- right click on scenario, select Define steps.
- and issue will arise (all steps are define already)
Link to Repository Project
https://github.com/gauravi555/SpecFlowUnitTestProject.git
I have the same situation. This is my log with some personal stuff scrubbed:
Info: OnActivityStarted: Starting Visual Studio Extension... Info: CreateProjectScope: Initializing project: APIAutomation Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v8.0,SpecFlow:3.9.74 Warning: AndDiscoveryProviderSucceed: Error during binding discovery. Command executed: C:\Users\USER\source\repos\Automation\APIAutomation\bin\Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\USER\appdata\local\microsoft\visualstudio\17.0_05a50cd2\extensions\4uipj3jo.qlj\Connectors\Generic-net7.0\specflow-vs.dll discovery C:\Users\USER\source\repos\BUNNAutomation\APIAutomation\bin\Debug\net8.0\APIAutomation.dll C:\Users\USER\source\repos\BUNNAutomation\APIAutomation\specflow.json Exit code: 4 Message: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.ModuleHandle.ResolveMethod(QCallModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount) at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, ReadOnlySpan
1 typeInstantiationContext, ReadOnlySpan1 methodInstantiationContext) at System.ModuleHandle.ResolveMethodHandle(Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.RuntimeType.GetMethodBase(RuntimeModule scope, Int32 typeMetadataToken) at System.Reflection.RuntimeCustomAttributeData..ctor(RuntimeModule scope, MetadataToken caCtorToken, ConstArray& blob) at System.Reflection.RuntimeCustomAttributeData.GetCustomAttributes(RuntimeModule module, Int32 tkTarget) at SpecFlowConnector.ReflectionExecutor.Execute(DiscoveryOptions options, Func
3 testAssemblyFactory, ILogger _log, IAnalyticsContainer analytics) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 15
at SpecFlowConnector.Runner.ExecuteDiscovery(DiscoveryOptions options, Func3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 50 at SpecFlowConnector.Runner.<>c__DisplayClass4_0.<Run>b__0(ConnectorOptions options) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 30 at FunctionalExtensions.Map[TSource,TResult](TSource this, Func
2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5
at SpecFlowConnector.Runner.Run(String[] args, Func3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 26 Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: D. Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue() at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at SpecFlow.VisualStudio.Connectors.OutProcSpecFlowConnector.Deserialize(RunProcessResult result, Func
2 formatErrorMessage)
Warning: AndDiscoveryProviderSucceed: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.
Please check the error message above and report to https://github.com/SpecFlowOSS/SpecFlow.VS/issues if you cannot fix.
Warning: AndDiscoveryProviderSucceed: Error during binding discovery. `
I get the same log for each project in the solution. I am not able to navigate to step definitions.
Hi, I have this same issue. Same error. For me - I get this when my specflow project is targeting .net 8.0, but when I switch it back to 7.0 or 6.0 it's fine. Unsure how to get my specflow to work properly with .NET 8. Unless I am missing something?
There is a pre-release version of the extension that is available: https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8
I downloaded and installed it and it is working.
Hi jrbye, thanks so much for responding so quickly. I too can confirm that the pre-release you mention above works for me as well.