SpecFlow.VS icon indicating copy to clipboard operation
SpecFlow.VS copied to clipboard

"Go To Test" navigates to the generated code-behind file and not the scenario in the feature file in Visual Studio 2022 17.5.0

Open icnocop opened this issue 2 years ago • 13 comments

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

Issue Description

After updating Visual Studio 2022 to v17.5.0, the "Go To Test" feature in "Test Explorer" no longer works as expected.

Visual Studio jumps to the generated code-behind file instead of the feature file.

Steps to Reproduce

  1. Launch Visual Studio 2022 17.5.0
  2. File > New Project > SpecFlow Project > Next
  3. Create
  4. Framework: .NET Framework 4.7.2
  5. Test Framework: MSTest
  6. Uncheck "Add FluentAssertions library"
  7. Create
  8. Edit the generated project file and add the following within <PropertyGroup> <LangVersion>latest</LangVersion>
  9. Build the solution
  10. In the "Test Explorer" window, right-click on the test and select "Go To Test"

Notice Visual Studio jumps to the generated code-behind file ".\Features\Calculator.feature.cs" on line 70.

I expected Visual Studio to jump to ".\Features\Calculator.feature" line 9.

SpecFlow for Visual Studio 2022 v2022.1.91.26832 - 2022-12-20

It worked without issues in Visual Studio 2022 v17.4.

icnocop avatar Feb 21 '23 21:02 icnocop

I have the same issue

bhugot avatar Feb 23 '23 23:02 bhugot

@gasparnagy I also have the same issue after upgrading to v17.5.0; this is a big issue for us.

jrod567 avatar Feb 24 '23 21:02 jrod567

I'm facing the same issue. Test project using .NET Core 3.1 Visual Studio Professional 2022 (64-bit) - Version 17.5.0

EngSimoes avatar Feb 27 '23 09:02 EngSimoes

@jrod567 @EngSimoes @icnocop @bhugot This is really bad... Unfortunately I don't think we can fix that on SpecFlow side.

This is not something that the SpecFlow VS extension or SpecFlow does. SpecFlow does not add the test items to the test case explorer, but generates MsTest (or NUnit or xUnit) C# methods that have the C# line pragmas to tell the compiler where the source line is. All the rest is done by the the test runners VS integration and VS itself.

Could you please try if it works with NUnit or xUnit?

If yes: please submit an issue to the MsTest team, if not: please submit an issue to the VS team.

gasparnagy avatar Feb 27 '23 11:02 gasparnagy

I use NUnit

bhugot avatar Feb 27 '23 12:02 bhugot

The same issue occurs for NUnit, MsTest and xUnit.

There is already an open issue on VS feedback forum, but they will likely close as it is related to "Other Product". https://developercommunity.visualstudio.com/t/Test-Explorer-SpecFlow-tests:-goes-to/10291227?q=specflow&sort=newest

There is an open discussion on the Specflow community, but there is no action occurring. https://support.specflow.org/hc/en-us/community/posts/9366318388893

I do understand that the issue may not be related to Specflow itself, but this has a big effect on the day-to-day use of the tool.

https://user-images.githubusercontent.com/5269989/221570113-9cfe6850-f84f-4236-b48a-f0af1a9dac82.mp4

EngSimoes avatar Feb 27 '23 13:02 EngSimoes

Have you tried to disable source-code based test discovery in VS? (Uncheck the box below)

image

gasparnagy avatar Feb 27 '23 13:02 gasparnagy

@EngSimoes If you can, try to make a repro with a standard MsTest test (without SpecFlow) that has a pragma like

#line 1 "MyFile.txt"

before the test. You should be able to reproduce the issue with that and submit it to the VS support case, so that they will not close it as "other product" issue.

gasparnagy avatar Feb 27 '23 13:02 gasparnagy

And of course all of you should add votes to https://developercommunity.visualstudio.com/t/Test-Explorer-SpecFlow-tests:-goes-to/10291227 otherwise it is not taken seriously.

gasparnagy avatar Feb 27 '23 13:02 gasparnagy

@gasparnagy unchecking is not working

bhugot avatar Feb 27 '23 13:02 bhugot

NUnit here as well - I've commented/voted on the VS issue for good measure.

jrod567 avatar Feb 27 '23 17:02 jrod567

Good news! Fix is coming... https://developercommunity.visualstudio.com/t/Test-Explorer-SpecFlow-tests:-goes-to-/10291227#T-N10296634

gasparnagy avatar Mar 02 '23 19:03 gasparnagy

Hi, it is fixed now on version 17.5.2.

https://developercommunity.visualstudio.com/t/Test-Explorer-SpecFlow-tests:-goes-to-/10291227

Thanks for the help @gasparnagy!

EngSimoes avatar Mar 15 '23 08:03 EngSimoes