SpecFlow.VisualStudio
SpecFlow.VisualStudio copied to clipboard
Multiple external stepAssemblies - SpecFlow VS IDE cannot find matching steps
I found the issue related to the issue SpecFlowOSS/SpecFlow#220.
If you have 2 external step assemblies MyCompany.Steps.CommonSteps and MyCompany.Steps.OtherSteps and corresponding projects contain 2 files with the same relative paths then the VS integration breaks.
Example: /MyCompany.Steps.CommonSteps/Steps/DashboardSteps.cs:
[When(@"I do something")]
public void WhenIDoSomething()
{
...
}
/MyCompany.Steps.OtherSteps/Steps/DashboardSteps.cs:
[Then(@"I should see something")]
public void ThenIShouldSeeSomething()
{
...
}
/UITests/Features/FeatureExample.cs:
...
Scenario: Defect example
When I do something # one of these steps will be not recognized and Ctrl+Shilt+Alt+S will not work for it
Then I should see something
...
I found also that there is only single project in the %TEMP%/specflow-stepmap-*.cache, but files from all of the projects within VisualStudio are listed in the same single project in the cache.
is it possible to put a repo on github which replicates this issue? this would help a lot in being able to fix it I think.
On Thu, Oct 22, 2015 at 8:30 AM, gerich-home [email protected] wrote:
I found the issue related to the issue SpecFlowOSS/SpecFlow#220 https://github.com/techtalk/SpecFlow/issues/220.
If you have 2 external step assemblies MyCompany.Steps.CommonSteps and MyCompany.Steps.OtherSteps and corresponding projects contain 2 files with the same relative paths then the VS integration breaks.
Example: /MyCompany.Steps.CommonSteps/Steps/DashboardSteps.cs:
[When(@"I do something")] public void WhenIDoSomething() { ... }
/MyCompany.Steps.OtherSteps/Steps/DashboardSteps.cs:
[Then(@"I should see something")] public void ThenIShouldSeeSomething() { ... }
/UITests/Features/FeatureExample.cs:
...Scenario: Defect example When I do something # one of these steps will be not recognized and Ctrl+Shilt+Alt+S will not work for it Then I should see something ...
I found also that there is only single project in the %TEMP%/specflow-stepmap-.cache*, but files from all of the projects within VisualStudio are listed in the same single project in the cache.
— Reply to this email directly or view it on GitHub https://github.com/techtalk/SpecFlow/issues/502.
Please find it here: https://github.com/gerich-home/specflow-issue-502
Hi, Is there any development on fixing this issue?
Hi, any update regarding this issue???
@excalipon No
as a quick note.
Reproduction will be hell; I have encountered this issue in a few different places, the current example is when introducing different step assemblies and it is fine on my machine, and when someone else gets latest it falls apart and everything is purple.
So the problem is the files in the %TEMP% folder
So I decided to compare things a bit (locked all the dated to jan 1 2000, formatted the json using vs code then using WinDiff to compare).
Off the bat my files (working) were a lot bigger than the failing files. 1mb to 800kb
the difference is all tied to the "StepDefinitions" element in the json, in the failing one it is all []
For example
Working
{ "FileName": "Steps\\Stores\\AddressSteps.cs", "TimeStamp": "2000-01-01T01:01:01.0000001-00:00", "StepDefinitions": [ { "Method": { "Type": { "Name": "AddressSteps", "FullName": "WebIZ.Test.Specflow.Steps.Stores.AddressSteps" }, "Name": "GivenTheAddress", "Parameters": [ { "Type": { "Name": "Address>", "FullName": "System.Collections.Generic.Dictionary<System.String, WebIZ.Test.Specflow.Stores.Address>" }, "ParameterName": "items" } ], "ReturnType": null }, "StepDefinitionType": 1, "Regex": { "Pattern": "^the Addresss?$", "Options": 520 }, "BindingScope": null }, { "Method": { "Type": { "Name": "AddressSteps", "FullName": "WebIZ.Test.Specflow.Steps.Stores.AddressSteps" }, "Name": "GivenTheNewAddress", "Parameters": [ { "Type": { "Name": "Address>", "FullName": "System.Collections.Generic.Dictionary<System.String, WebIZ.Test.Specflow.Stores.Address>" }, "ParameterName": "items" } ], "ReturnType": null }, "StepDefinitionType": 1, "Regex": { "Pattern": "^the new Addresss?$", "Options": 520 }, "BindingScope": null }, { "Method": { "Type": { "Name": "AddressSteps", "FullName": "WebIZ.Test.Specflow.Steps.Stores.AddressSteps" }, "Name": "GivenTheAddress", "Parameters": [ { "Type": { "Name": "String", "FullName": "System.String" }, "ParameterName": "name" } ], "ReturnType": null }, "StepDefinitionType": 1, "Regex": { "Pattern": "^the Address '(\\w+)'$", "Options": 520 }, "BindingScope": null }, { "Method": { "Type": { "Name": "AddressSteps", "FullName": "WebIZ.Test.Specflow.Steps.Stores.AddressSteps" }, "Name": "GivenTheNewAddress", "Parameters": [ { "Type": { "Name": "String", "FullName": "System.String" }, "ParameterName": "name" } ], "ReturnType": null }, "StepDefinitionType": 1, "Regex": { "Pattern": "^the new Address '(\\w+)'$", "Options": 520 }, "BindingScope": null } ] },
Failing
{ "FileName": "Steps\\Stores\\AddressSteps.cs", "TimeStamp": "2000-01-01T01:01:01.0000001-00:00", "StepDefinitions": [] },
That is litterally all the differences between the two files (after date normalization).
these were the original dates Good "Steps\Stores\AddressSteps.cs","TimeStamp":"2018-04-10T13:17:35.5243075-06:00" Bad "Steps\Stores\AddressSteps.cs","TimeStamp":"2018-04-10T16:02:57.9328881-06:00"
So What happened for these two computers; Working: Project A has features and steps Project B is created and feature files are moved into that, with steps staying in project A check in
Failing: Project A has features and steps Get latest and get the changes from the Working machine.
Hi, another possible solution: https://github.com/techtalk/SpecFlow/issues/838#issuecomment-479868784
To solve this:
- Create a Gherkin project (this should only have .feature files)
- Create Step definition project (this should only have step definitions)
- Use those step definition using External assembly binding (https://specflow.org/documentation/Use-Bindings-from-External-Assemblies/). For specflow3 this has to be go to specflow.json file
{
"language": {
"feature": "en-US"
},
"stepAssemblies": [
{
"assembly": "Com.Organization.Product.StepDefinition"
}
]
}
In my case Com.Organization.Product.StepDefinition.dll
generated from Step definition project
- Make sure specflow.json should set to copy always in you output directory
- If still not working, close visual studio then open %TEMP% and delete specflow related .cache file
- Open visual studio build the solution
Hope above step works!