Discussion:
[specflow] Ambiguous step definition with step inheritance in new version of SpecFlow
Alex S.
2016-04-20 18:48:30 UTC
Permalink
Hi guys!
I have a problem with step inheritance in my project.

The structure is: I have a base test library which I use as a NuGet
package, and I have 3 other test projects in which I use it.
Base library has BasicSteps.cs marked with [Binding] attribute, all project
step files are inherited from this file. In this file I have a step which
allows me to refresh webpage, and I was using it in all projects without
any problems until v.2.0.0.
Now whenever I try to use this step, it gives me "Ambiguous step
definition" and lists "BasicSteps.RefreshPage()" several times - basically,
once per each step file inherited from BasicSteps.

I guess something has changed in SpecFlow that pushes the idea of NOT using
step inheritance even further. Ok, if that's the way it is now, what other
options do I have to use common steps (refresh the page, go to URL) across
several projects without creating them more than once? What makes it harder
in my case, all my 3 projects may be used together, as in:

BaseTestLibrary
Project1 references BaseTestLibrary
Project2 references BaseTestLibrary
Project3 references BaseTestLibrary, Project1 and Project2

So even if I specify step "When I refresh the page" in each of them, I'll
still get that "ambiguous step definition" problem.

Any ideas?

Thanks,
Alex.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andreas Willich
2016-04-20 19:57:26 UTC
Permalink
Hi Alex

In the app.config you can specific in which assemblies SpecFlow is looking
for steps.
Look at: http://www.specflow.org/documentation/Configuration/
It is <specflow><stepAssemblies>

Add the assembly from your NuGet for you common steps and your actual
assembly for the custom steps of your testproject.
That could help you with your problem.

Using inheritance for steps could already be in 1.9 a problem.
Gaspar wrote an article about it:
http://gasparnagy.com/2015/05/specflow-tips-problems-with-placing-step-definitions-to-base-classes/

best regards
Andreas
Post by Alex S.
Hi guys!
I have a problem with step inheritance in my project.
The structure is: I have a base test library which I use as a NuGet
package, and I have 3 other test projects in which I use it.
Base library has BasicSteps.cs marked with [Binding] attribute, all
project step files are inherited from this file. In this file I have a step
which allows me to refresh webpage, and I was using it in all projects
without any problems until v.2.0.0.
Now whenever I try to use this step, it gives me "Ambiguous step
definition" and lists "BasicSteps.RefreshPage()" several times - basically,
once per each step file inherited from BasicSteps.
I guess something has changed in SpecFlow that pushes the idea of NOT
using step inheritance even further. Ok, if that's the way it is now, what
other options do I have to use common steps (refresh the page, go to URL)
across several projects without creating them more than once? What makes it
BaseTestLibrary
Project1 references BaseTestLibrary
Project2 references BaseTestLibrary
Project3 references BaseTestLibrary, Project1 and Project2
So even if I specify step "When I refresh the page" in each of them, I'll
still get that "ambiguous step definition" problem.
Any ideas?
Thanks,
Alex.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex S.
2016-04-22 16:39:26 UTC
Permalink
My bad, it started in 1.9.0 indeed. As per your suggestion, I already have
assemblies included in App.config, and it does not help at all.
I also read this article you've mentioned, and the bottom line is: try
using partial step classes. I guess I'll try this and see what happens.

Thanks!
Post by Andreas Willich
Hi Alex
In the app.config you can specific in which assemblies SpecFlow is looking
for steps.
Look at: http://www.specflow.org/documentation/Configuration/
It is <specflow><stepAssemblies>
Add the assembly from your NuGet for you common steps and your actual
assembly for the custom steps of your testproject.
That could help you with your problem.
Using inheritance for steps could already be in 1.9 a problem.
http://gasparnagy.com/2015/05/specflow-tips-problems-with-placing-step-definitions-to-base-classes/
best regards
Andreas
Post by Alex S.
Hi guys!
I have a problem with step inheritance in my project.
The structure is: I have a base test library which I use as a NuGet
package, and I have 3 other test projects in which I use it.
Base library has BasicSteps.cs marked with [Binding] attribute, all
project step files are inherited from this file. In this file I have a step
which allows me to refresh webpage, and I was using it in all projects
without any problems until v.2.0.0.
Now whenever I try to use this step, it gives me "Ambiguous step
definition" and lists "BasicSteps.RefreshPage()" several times - basically,
once per each step file inherited from BasicSteps.
I guess something has changed in SpecFlow that pushes the idea of NOT
using step inheritance even further. Ok, if that's the way it is now, what
other options do I have to use common steps (refresh the page, go to URL)
across several projects without creating them more than once? What makes it
BaseTestLibrary
Project1 references BaseTestLibrary
Project2 references BaseTestLibrary
Project3 references BaseTestLibrary, Project1 and Project2
So even if I specify step "When I refresh the page" in each of them, I'll
still get that "ambiguous step definition" problem.
Any ideas?
Thanks,
Alex.
--
You received this message because you are subscribed to the Google Groups
"SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ravi Raju
2016-04-25 12:00:06 UTC
Permalink
Hi Guys,
I have problem, After creating scenario If I click the "Generate Step
Definition" ,
In scenario if I have "And" part,It's creating only skeleton for *Given*
but not for "AND" part. Could any one help me on this.

Ravi
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex S.
2016-04-25 17:45:06 UTC
Permalink
This is kinda off-topic, but I don't think "And" works well with "Given".
Hi Guys,
I have problem, After creating scenario If I click the "Generate Step
Definition" ,
In scenario if I have "And" part,It's creating only skeleton for *Given*
but not for "AND" part. Could any one help me on this.
Ravi
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sam Holder
2016-04-26 10:29:08 UTC
Permalink
there is no such step type as 'And' (or 'But') on 'Given', 'When' and
'Then'. Please see this answer <http://stackoverflow.com/a/25116098/97614>for
more information
Post by Alex S.
This is kinda off-topic, but I don't think "And" works well with "Given".
Hi Guys,
I have problem, After creating scenario If I click the "Generate Step
Definition" ,
In scenario if I have "And" part,It's creating only skeleton for *Given*
but not for "AND" part. Could any one help me on this.
Ravi
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...