-
-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tag scoped step definitions #1949
Comments
Moving this to common. This would affect more then one implementation. |
Hi, I am from the SpecFlow Team. This feature increases the complexity of navigation in editors a lot. A lot more code needs to be parsed to find the right location to jump to. |
@SabotageAndi I can't follow your reasoning. Checking the tag list yourself sounds like a hack, not a feature. It would require coordination between developers, centralizing the implementation of a step that is profoundly different between areas, just to read a tag and then re-route the method call. THAT is messy regarding "go to source". Guess what will happen next? A developer will say "can't this be automated"? SpecFlow right now has this beautifully implemented, as the steps and the implementation is loosely coupled, and different areas do not interfere with each other. Gherkin/SpecFlow saved us from test coupling hell. If a person wants to navigate to the source, and multiple implementations exist, and it is hard to find the right one, I don't expect the IDE to be smart. Simply show a list of all implementing methods and let the user choose. For what it is worth, most IDEs can't even resolve overloads when navigating statically typed source code, and we are all fine with it. |
My reasoning is from how often I see tag scoping used and how much work it is to support it everywhere. Not from a user perspective, simply from a maintainer perspective.
I have other experience with .NET developers and our users. MS is setting the bar with Visual Studio very high and so our users expect that this is working. And I have no say if this gets implemented in Cucumber or not. @mattwynne asked me yesterday, that I write a comment about my experience with this in SpecFlow here. |
@derSchtefan
NOTE: |
Although I have found the tag-scoping useful is some specific case, I agree to @SabotageAndi that the maintenance complexity probably outweighs the benefits, especially because there are workarounds. |
We've always resisted adding this kind of functionality to Cucumber. As @richardlawrence has pointed out many times before, there's a great power in Cucumber's adherence to a ubiquitous language: wherever you see the same phrase in the Gherkin, you know it always means the same thing. I'm really not convinced by the examples given that it would be a good idea to break this axiom. If you really need this, you can built it yourself using polymorphism in your support code: wrap the code that interacts with each page in an object with a common |
@mattwynne While I agree to your conclusion, I would like to highlight that ubiquitous language is not about this. Ubiquitous language is about a language that everyone understands. This is what we also call the business language, because that describes the requirements in a way that they are understood by everyone. The scoped step definitions do not change the meaning of the steps! They only provide different automation solution to achieve the same. From this point of view, they are a simple implementation of the hexagonal architecture, where you just use different adapters for the same thing. So with the same argument you would need to sacrifice the hexagonal architecture as well. When I used tag scoped steps, I have used it to achieve a test automation pyramid like shape in a way that a few "happy path" scenario of a feature have been automated on the outside interface of the app, but the most of them have been automated on the domain level. But the scenarios used the same steps as they were describing the same: the requirements. I'm not saying that I could not have solved it with the workarounds you mention, but it was clean and useful. |
@gasparnagy I don't think ubiquitous language is only about the ubiquity of who uses it - although that's an important aspect. In it's essence, for me, it's about "using the same words for stuff" wherever you are in the stack - from user guides to the database schema (at least, within one bounded context). This includes being specific about distinct domain concepts. Perhaps what I missed in my mention of ubiquitous language is my experience is that the constraint of having to use unique terms in your Gherkin steps for unique actions against the system in your step definitions can help force you to think about what your ubiquitous language is. For example, if you can just say So for example, Gaspar your example of using tagged scopes to run scenarios at different levels is really interesting (and sounds much more valuable than the OP's suggested use case to me) but I'd prefer to see that implemented in something like Behat's suites rather than being mixed up in a single test run. |
@mattwynne I agree, but unfortunately the test runs are (usually) managed by the execution platform (in SpecFlow's case that would be the .NET xUnit runner, for example), where the possibilities might be limited or not in our control. In our case there is no easy way to define such suites there. |
@gasparnagy interesting, but probably a separate discussion! |
Hi, I am in support of the feature: tags at step level but with a different reason. I am automating a highly dynamic application. Hence, I decided test each fields in separate scenario so that I can skip tests using tags(scenario level) for those fields which need not be covered for current screen.
However, there are some tests(scenarios) which test for all fields in the page. The test would not be meaningful if I segregated them field wise. Hence I thought, if I could skip steps inside a scenario then it would have been very flexible to impl. such case.
Otherwise, my coverage would be less. Let me know if this helps. Note: I am not looking to reverse target scenarios/features using tags applied in steps I hope this helps. Ref: behave/behave#1057 |
Have added details in the above comment. Please let me know the way forward. |
🤔 What's the problem you're trying to solve?
Bind step definition to tags (e.g. 'When I press "Save"' multiple definitions for different tags).
Many steps are worded identical, but refer to different operations of the system. Consider a web interface, where multiple ways to display the interface exist, multiple pages, or dialogs, all with a "Save" button. They might need different implementation on how the save action is triggered in the test glue code, but right now you would always need to specify something clumsy like
When I press "Save" (on page X)
, which is not only odd to read but raises questions.In the glue code you would have multiple implementations, all with slightly different wordings, making it a huge mess to come up with variants on how you write the same action.
Another very common occurrence is the "Then I expect no error to be shown" steps. This is usually easily scopeable with a tag in a feature file talking about whatever way errors are displayed or returned in that particular part of the system. However we find ourselves always having to write the error validations absurdly verbose.
✨ What's your proposed solution?
SpecFLOW (for .NET) has solved this quite elegantly: A step definition can be bound to one or multiple tags. It is then only relevant for Scenarios or features with that specific tag. This way the wording can be sharper and shorter, and the glue logic is more readable.
⛏ Have you considered any alternatives or workarounds?
Right now we have to pre or postfix steps that are worded the same but have to trigger two different actions in the test implementation, and it does actually work against the idea of Cucumber: to make the specification independent from the implementation
The text was updated successfully, but these errors were encountered: