specflow generate step definitions missing from context menu - specflow

I followed the getting started instructions and the "generate step definitions" is missing from context menu.
I tried adding the additional specflow packages from nuget for mstest and still nothing.

I had the same problem. I was looking for this option in contextual menu of the feature file, but this option exists in the contextual menu of the content of the feature file. So, try open the feature file (*.feature) in the Visual Studio text editor and click right button of the mouse inside text editor. Example of the file:
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen

Assuming you are bringing up the correct context menu by right clicking in the .feature file as opposed to anywhere else then you may find that the issue is actually caused by the TechTalk.SpecFlow.dll not being referenced in your project.
To add the reference manually (NuGet didn't do it for me) right-click on the References folder of your project and find the TechTalk.SpecFlow.dll which will likely be in '[project]/packages/SpecFlow.X.X.X/lib/netXX/' (X's are version numbers).
Here is the context menu when I don't have the correct reference in place:
And here it is once I do:
This was SpecFlow.2.1.0 and VS2010 which led me to another issue with incompatible .Net versions so I ended up using SpecFlow.1.9.0.

Try to install SpecRun.SpecFlow from the Nuget Packages, after installation completes you'll get the "Generate Step Definitions" on the context menu.
It worked for me.

Install specflow from Extensions and updates and then restart the visual studio, clean and rebuild the solution

I had the same problem. maybe it was related with fresh IDE installation or maybe it was something new... here is just short note about this issue and possible solution:
At the beginning of IDE/project configuration check or install packages for SpecFlow in the NuGet manager.
Check twice what exactly you will use in the project Xunit or Nunit and then install the related package Xunit or Nunit. In my case, I was working with Xunit and install it.
After installation, you will see new items in the References
and pop about re-generation feature files
After that Generation steps will be available

This is because you may not have the simply installing the Extension for SpecFlow at Solution level is not enough.
SpecRun.SpecFlow is an evaluation version unless you are prepared to play for a license key.
I added the NuGet package SpecFlow.xUnit to the Unit test Project within my solution where I held my feature files. This resolved the issue, I now see Generate step definitions.
This is achieved by Right-clicking on your feature file in the code editor and select Generate Step Definitions from the popup menu. A dialogue is then displayed.

This happened to me when I migrated an existing project to a new PC.
Turns out I need to do: Visual Studio 2019 > Extensions > Manage Extensions > select 'Online' in the left hand nav > then search for 'Specflow' in the search box > then download it and close Visual Studio. It auto installs then.
Finally reopen VS and it should work.

In Visual studio 2022 the context menu item "generate step definitions" renamed to "Define steps" as per below specflow documentation.
https://docs.specflow.org/projects/specflow/en/latest/visualstudio/Generating-Skeleton-Code.html

Related

All the project files showing as Miscellaneous Files. Visual Studio 2017

I moved my Asp.net-mvc project from desktop to F drive and all the files are showing as miscellaneous files.
I've tried running the visual studio installer and modify to make sure that "Nuget targets and build tasks" are ticked.
I've also tried :
excluding the file
add existing member(adding the file again)
but nothing's working.
Same thing happened with my asp.net core web api when I moved it, it's working fine tho, getting data from server.
Hope you will solve your problem
Solution 1:
Create new project then paste all project contents in new created project.Restore Nuget packages then Build it.
Solution 2 :
Go to the file which are Miscellaneous inside Solution Explorer.
Right click those file'(s) and select Exclude from project.
Add Existing Item to project, you just excluded.
Probably your file property configuration is wrong.
Try this:
Right click over the File that has this problem
Click on Properties
Under Advanced -> Build Action, check if other than "Compile" is selected.
If so, change it to "Compile".
Properties Window

Rider treats freshly checked out Projekt as "All files are new"

I am using the TFS Integration Plugin, as the built in TFS Connection somehow is not able to connect to our TFS. With the same login/path I am able to check out projects from our TFS but then Rider treets the freshly checked out project as "not under version control" and does not recognize any changes.
I can add them all to version control and after that Rider recognizes changes in files. But it also still thinks that all other files are new, which is really not the case. In this picture, I added all files and changed one.
Am I doing something wrong here, as I am used to VS/TFS Version Control or might this be a bug? I asked the same thing in the community forum, but there is no real activity...
Have tested installing riderRS-171.4456.902.exe (Windows), the TFS Integration plugin has been bundled with Rider and enabled VCS-TFVC successfully. And it can detect the changes correctly. Please follow below requirements:
You must have the TF command line tool installed to be able to use
TFVC features. The minimum version supported by the plugin is 14.0.3.
To install the tool, download the latest "TEE-CLC-14...zip" file and
extract it to a known location. After extracting the files, you must
accept the license agreement. To do so, open a Command Prompt/Terminal
window, navigate to the extracted directory, and run tf eula. After
reading the EULA, enter y enter code hereto accept it. NOTE: If you
forget to do this, the plugin may fail to load with a
RuntimeException.
For the tool to be detected by the plugin, you must set the location of the executable in the Settings/Preferences menu by following these instructions:
Go to RD Settings Version Control -TFVC
In the Path to tf executable text field, navigate to the location of
the tf executable.
Click Test to test that the executable has been found and is working
as expected.
Click Apply then OK to save and exit.
Also check below things:
If TFVC does not come up as your version control system (VCS) then it
can be set manually. Go to the VCS dropdown menu in the toolbar and
select Enable Version Control Integration. Select TFVC from the
dropdown menu and click OK.
More details please refer this tutorial.
Please try to setup a new created project or select another project when you are using Rider with TFS. To narrow down if the issue is related to that special project.

How can I force file ordering in F# projects using vscode?

I'm trying to work with vscode in my WebSharper project (Ionide plugin seems... Whoah!) but when I load the fsproj into vscode, files in the explorer are ordered by name, not by "F# precedence". How can I configure vscode so that files are correctly ordered? Thank you.
The VS-like project explorer has been added to Ionide recently. It includes assembly references, project references, and ordered files (including folder supports). We've also added several commands to manipulate project and file order, you can access them with right-click context menu on this new project explorer
In Visual Studio Code you press Ctrl + Shift + P, then enter "F#: Move File Up".
If you have activated the great ionide plugin you can navigate to the F# symbol on the activity bar. This will open the project explorer which allows you to reorder files using the arrow icons:
This will change the order of the files (<Compile Include="xyz.fs" /> statements) in your .fsproj file (which is what you would have to do manually if you're not using the ionide plugin).
Without any plugin, VSCode 1.66 (March 2022) should support a better order support.
See issue 32592:
ordering of files is really important for the F# projects, and we provide couple of helper commands to manage it (move file up/down etc).
Those commands work more or less, but I don't think it's best UX.
I think it would be super nice if users had ability to use normal drag and drop to manipulate the order - just as they are able to manipulate files in normal file explorer (drag and drop files to move them to subfolder for example)
It is currently released in VSCode insider, with commit c468903 ("Finalize tree drag and drop API").

BuildActivity ignores ToolsVersion

I have a Continuous Integration Build Running on a BuildAgent which I can not get working properly. I recently changed our codebase to C# 6.0 and changed the projects to ToolsVersion 14.
I did install Visual Studio 2015 on the Build Server (TFS 2012). If I do now check in the C# 6.0 code the build fails on the first project ("$" is unexpected or something")
The BuildTemplate is "DefaultTemplate.11.1"
If I check the log files the build calls the wrong csc.exe (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe)
if I do start the MSBuild/14.0/Bin/MSBuild executable with the project without any switches the Build succeeds. Why does the TFS BuildAgent not use the ToolsVersion and how can I get TFS 2012 to build my Visual Studio 2015 solution
If I add the MSBuildArgument /tv:14.0 it still fails. As it calls th Version 12 of MSBuild which is part of the .NET 4.6 RC Framework which ships with Visual Studio 2015.
Changing the ToolsPath of the MSBuild Activity does get the Build working but spits bullets if I try to run my UnitTest. I get aMissing dlls "Microsoft.VisualStudio.TestPlatform.Utilities.dll" exception. (VS2012 is installed as well on the Build Server).
UPDATE:
I do now get a different error with my unit tests:
TF900548: An error occurred publishing the Visual Studio test results.
Details: 'Method not found:
'System.Collections.Generic.IEnumerable<System.String>
Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.MergeRunSettingsAndFindCompatibleSources(Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture
ByRef,
Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion
ByRef, System.String, System.String,
System.Collections.Generic.IDictionary`2<System.String,System.Collections.Generic.KeyValuePair`2<Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture,Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion>>,
System.Xml.XPath.IXPathNavigable, System.String ByRef)'.'
For those of us not living inside build templates every day here's the steps that got it working for me:
First find the template associated with your build (if you already know where to find it skip a couple steps).
Just right click the build definition and select Edit build definition
Select the Process tab and you'll see the name of the template (quite likely to be DefaultTemplate if you haven't customized it). On the far right click Show details to see the path for the template.
Go to the Home tab under Team explorer and click Source control explorer
Find the template file and double click to edit it. It should come up in a graphical view like this. Scroll till you find Run MSBuild for Project
Click on this item which will immediately bring up properties
Click on the little icon on the right - don't try and type it in because it'll probably explode and crash Visual Studio.
Enter IN QUOTES the following "C:\Program Files (x86)\MSBuild\14.0\bin"
NOW FOR THE MOST IMPORTANT PART
For me the Run MSBuild for Project was in TWO places.
So I just repeated the above steps in both places, and then after I checked in the .xaml file my build FINALLY worked fine.
You may need to recycle the agent / controller from within the TFS tool.
Edit template change msbuild activity ToolPath to "MSBuild/14.0/Bin/MSBuild"
See answer by Marson.
Using the TfvcTemplate.12.xaml build process template with the /tv:14.0 Build argument worked for me.
use msbuild aruguments /p:VisualStudioVersion=14.0

Built tests are not added to the Visual Studio Test Explorer window

I set up the SpecFlow plug-in for the Visual Studio 2013.
I created new Feature Item and build it.
Result: built test is not shown in the Test Explorer. Why?
I do it according to this video
in order to configure it to generate MSTest tests you need to add this to your app.config:
<specFlow>
<unitTestProvider name="MSTest"></unitTestProvider>
</specFlow>
I experience this same problem, but the solution was different.
Following the advice on a SpecFlow Github issue, the following worked for me:
Close all Visual Studio instances
Go to %TEMP%\VisualStudioTestExplorerExtensions\
Delete all the folders in here
Try again
if the tests are not showing in the test explorer you need to install NUnit test adapter :
go to Tools->Extensions and updates ->Online->Visual Studio Gallery->Tools->Testing and select NUnit Test Adapter
Visual Studio can change the default processor architecture when it loads. While looking endlessly trying to figure out the issue, I finally figured it out, that it wasn't really Specflow causing the issue.
If you have references that require a special architecture, it will prevent the tests from showing up in the test explorer. Change the architecture to x86 or x64 based on your needs.
Another thing you can do to see the build issues is open the Output window and change the dropdown to Tests during build. It will highlight any information of things taking place during your build.
I felt somebody should mention it just in case.
I'm running SpecFlow tests with SpecRunner and had this same problem, a couple of times as a matter of fact.
Having tried all of the above suggestions, I found that the only solution to the problem was to uninstall and reinstall the SpecRun NuGet package. Next build, tests present in Test Explorer window as expected.
In my case the reason why tests weren't discovered were because I was using Resharper build.
As soon as I went to: Resharper -> Options -> Tools -> Build -> General: "Use ReSharper Build"(untick), then all tests were suddenly discovered.
In my case all the approaches above didn't work. My solution: I don't know why, but - I re-installed "Specflow for Visual Studio 2015" in "Tools => Extensions and Updates", then I've created a new feature file (old still didn't work), and this new feature-file works correctly.
For me, I changed from using direct DLL references to using the NuGet references of version 3.1.7.4 of SpecFlow and this solved the problem.
I needed to reference "SpecFlow", "SpecFlow.NUnit" and "SpecFlow.Tools.MsBuild.Generation".
and then clicked the "Show All Files" button in Visual Studio to see the code behind file at a sibling level to it associated Feature file (this used to be an associated child file of the feature file in older versions).
I also need to use the "Include In Project" context menu item on the code behind file, for tests to show up in Visual Studios "Test Explorer".
NOTE: I did try to unzip the Specflow required files from the NuGet package and reference them directly in my project to be consistent with other direct references in my project (non-NuGet references) but this doesn't seem to work and you have to use the NuGet reference. I found an closed issue in github, which states that we have to use the Nuget reference to get the tests to work in Test Explorer:
https://github.com/techtalk/SpecFlow/issues/1617
For me, the issue was the TestAssemblyPath in my srprofile file. It didn't match my actual dll name.
I tried installing the Nugget package
SpecFlow.Tools.MsBuild.Generation
with the same version than specflow and now I can see the test in TestExplorer, other ways not works for me.
I already had installed 1 from
Nugget Package Specflow
Specflow.NUnit
Nunit
Nunit3TestAdapter
and the extension for Visual Studio for Specflow a NUnitTestAdapter

Resources