Factoring steps #95
vincent-lg
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm new to Cabbage and really like the tool. Using BDD alone never seemed that useful, until now, and doing so in Elixir with Cabbage doesn't sound too complicated, for which I am grateful.
I'm considering the possibility of using (or re-using) the same operations in different steps. I like to keep things organized and well delimited. My specific use case is to create a TCP server, connects to it and send commands. This is a common use case, but I have many sub-cases where I want to apply different files, connect, enter a command, see the result, test its output. In other words, I might have different features and different files, but I'd like to keep some common operations (connect, send a command, watch output).
As far as I can tell, for the time being, a feature (
.exs
) requires one and only one feature file. So this idea doesn't seem possible at the time. I could, of course, easily replicate it with helper functions to do what I want and copy/paste these 3 lines for each feature file. It won't be too hard. But it doesn't feel that great either.Possible solutions
The first and perhaps the most simple: remove the link between test files (
.exs
) and the feature file (.feature
). Upon executing a.exs
file, all features matching the keywords in this file should execute. But I realize that, sinceCabbage
compiles each.exs
file to a test, this might not work.An alternative would be to allow to specify several files. Something like:
In short, we don't specify the feature file. We can define keywords as usual. And then define several files in blocks (allowing for additional keywords for each). This would indeed create something quite powerful where the central definition can easily be found, but several feature files can still exist without duplicating definitions.
I'm a bit uncertain about this: the first solution has the advantage of simplicity. Think "extract all keywords from every step, then apply the features regardless". It's easy to explain. The second situation, while closer to the expected behavior of Cabbage, has the downsides of pushing generic features in a central place. The single step file might become quite huge and hard to manage, while the feature files could be spread in many files (and directories?).
Looking forward to feedback,
Beta Was this translation helpful? Give feedback.
All reactions