Refer Step Definitions from external package
I have a specflow package in which the StepDefinitions are present with other code.
Now I am referring that package in a new solution/project and trying to write my code with reference to the external package.
I did added the assembly(MyNewProject.dll) present in my package in specflow.json file but it is not working. The code is showing in purple color.
"stepAssemblies": [
{ "assembly": "Allure.SpecFlowPlugin" },
{ "assembly": "MyNewProject.dll" }
]
I tried clearing cache but it also didn't work.
Please suggest.
-
Hello!)
I use external package with StepDef in my solutions. And I can advise:
- remove the dll in specflow.json.
{ "assembly": "MyNewProject" }
- check the value of the BindingAttribute in the step class.
- check that you have added a reference to the project with steps.0 -
--- check the value of the BindingAttribute in the step class.
I cannot change anything in the step class as that is coming from the package itself.
--- check that you have added a reference to the project with steps.
The stepdefinition class is part of the package so ideally my new feature files in new project should pick up them as i have added the package reference in my new project.
0 -
Binding attribute is also present in the step definition class in the package code...
[Binding]
public class CommonSteps0 -
As I remember, specflow works with assemblies that have steps. That is, to use both your own and external steps, you need to add assembly to specflow.json. In your case MyNewProject and external package
1 -
How can I add package? Adding assembly is known to me but not sure how to add package in specflow.json file. I have added Package in dependencies in project.
0 -
Using the nuget package name
As example, I will install a package named "Example.nupkg" and I will create specflow.json
"stepAssemblies": [
{ "assembly": "Example" },
]0 -
Ok I will try this tomorrow and keep you posted.
0 -
I again tried today but same issue. Below is my specflow.json file having an entry of Assembly with package name fhirr4specflow.
I also tried adding a new class with [Binding] attribute and inherited that class from my base class which comes from the above package. But that too is not working. All the test cases are displaying in purple color.
Please suggest.
0 -
Mandviwala, Abdeali please check if the assembly with your external step bindings is in the output folder.
If it is not there, it doesn't matter what you have configured in the specflow.json.
0 -
Yes it is there in the Output folder of my new project (bin\debug). My package name which i am referring is fhirr4specflow and it has a dll fhirr4specflow.dll. This dll is present in the output folder.
Below is what i have in specflow.json. Not sure what am i missing. I did cleared the temp cache, restarted VS, rebuild the solution.
"stepAssemblies": [
{ "assembly": "Allure.SpecFlowPlugin" },
{ "assembly": "fhirr4specflow" },
{ "assembly": "fhirr4specflow.dll" }
]0 -
Not sure what exactly the issue was but now with presence of the package it is working fine. Thanks.
0
Please sign in to leave a comment.
Comments
11 comments