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

Bindings cannot be discovered in .NET 8 application #2726

Closed mrpmorris closed 12 months ago

mrpmorris commented 1 year ago

SpecFlow Version

2021.0.200

Which test runner are you using?

xUnit

Test Runner Version Number

N/A

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

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

There isn't one

Issue Description

Warning: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.

Steps to Reproduce

  1. Create a new SpecFlow project
  2. Select xUnit
  3. Select .Net 6.0
  4. Right-click project and change the framework to .Net 8
  5. Save, Clean solution, Rebuild
  6. Close VS, reopen VS

Link to Repro Project

No response

renegadexx commented 1 year ago

We also have the same problem with NUnit

ThomasHeijtink commented 1 year ago

I thought I saw a PR for this issue. But now I can't seem to find it any more. Did I hallucinate, or is the PR removed?

OwendB1 commented 1 year ago

Experiencing the same issues sadly

bneumann commented 12 months ago

I thought I saw a PR for this issue. But now I can't seem to find it any more. Did I hallucinate, or is the PR removed?

Nope, I saw it too. Would be cool to have a fix, manually searching the bindings is a pain.

clrudolphi commented 12 months ago

Using SpecFlow's VisualStudio extension version 2022.1.91.26832, which pulls in SpecFlow.NUnit version 3.9.40, I cannot duplicate this problem. Is there a repro project you can post? I'll take a look to at least try to debug the source of the problem. (Can't promise any solutions until the SpecFlow projects gets back up and running).

bneumann commented 12 months ago

Hi, I tried these versions without success. But when right clicking on a step and then "Define Steps..." I saw this error:

Warning: AndDiscoveryProviderSucceed: Error during binding discovery. Command executed: D:\git\Test_Repo\Output/Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\z001syay\appdata\local\microsoft\visualstudio\17.0_502fdb4c\extensions\qa3k3flr.ote\Connectors\Generic-net7.0\specflow-vs.dll discovery D:\git\Test_Repo\Output/Debug/net8.0\AcceptanceTests.dll "" 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, ReadOnlySpan1 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, Func3 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.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, Func2 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: ShowProblem: User Notification: All steps have been defined in this file already.

I will try to setup a mini project that I can share. Maybe I can reproduce the error there.

bneumann commented 12 months ago

Browsing through the code I found that this issue is not specflow in general but the VS integration and the issue is tracked here: https://github.com/SpecFlowOSS/SpecFlow.VS/issues/145

There is also the missing PR ;) https://github.com/SpecFlowOSS/SpecFlow.VS/pull/146

gasparnagy commented 12 months ago

Until it will be published to the marketplace, you can install this version from the VSIX file attached to the release: https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8

bneumann commented 12 months ago

Did that and it works like a charme. I think we can close this here?

dcdraper commented 11 months ago

The new VSIX file works for me too. Thanks @gasparnagy!

stigc commented 10 months ago

Thanks @gasparnagy

github-actions[bot] commented 9 months 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.