SpecFlowOSS / SpecFlow.VS

The next version of the Visual Studio extension for SpecFlow
MIT License
36 stars 10 forks source link

"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 #127

Open icnocop opened 1 year ago

icnocop commented 1 year ago

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.

bhugot commented 1 year ago

I have the same issue

jrod567 commented 1 year ago

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

EngSimoes commented 1 year ago

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

gasparnagy commented 1 year ago

@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.

bhugot commented 1 year ago

I use NUnit

EngSimoes commented 1 year ago

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

gasparnagy commented 1 year ago

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

image

gasparnagy commented 1 year ago

@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 commented 1 year ago

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.

bhugot commented 1 year ago

@gasparnagy unchecking is not working

jrod567 commented 1 year ago

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

gasparnagy commented 1 year ago

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

EngSimoes commented 1 year ago

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!