-
Notifications
You must be signed in to change notification settings - Fork 36
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
RFC: DSL to ExUnit #79
Comments
@mgwidmann I definitely don't have time at the moment to do this but I do really like it as an idea. It feels like it'd be easier to run this up from scratch as a new project (obviously stealing any ideas from whitebread as needed). If it works well I'd happily redirect people to this new tool and write some tools to help with migration from whitebread. What do you think? |
Let me see if I can come up with something... |
So I have the above example working in a separate project... I've extracted out But anyway, heres the new project thus far: |
I've extracted gherkin to a separate project. Since you and the contributors to this project wrote it, I can transfer the repository to you if you'd like and post it to hex under your name. |
Looks really good so far. Love how much less code it needs. Regarding gherkin the other alternative is to create a cabbagex org and put both projects there. I'm happy with either really. The important thing for me is that we credit the people who made pull requests. |
1 similar comment
Looks really good so far. Love how much less code it needs. Regarding gherkin the other alternative is to create a cabbagex org and put both projects there. I'm happy with either really. The important thing for me is that we credit the people who made pull requests. |
Yeah so I managed (not without difficulty though) to keep the history behind all the commits in Gherkin, so everyone who contributed to the gherkin parsing is still listed as a contributor. I can make an organization to keep it all together. |
Started an organization and published the initial version to hex. 🎉 🎈 🥂 🎊 |
Amazing work! |
I'll do a point release of white bread to use the gherkin lib so we don't have any duplication. And add a mention of cabbage to the readme here. |
I've linked to cabbage from this README and whitebread is now using the cabbage gherkin lib. There's still an outstanding question of how/who should and what migration should happen from whitebread to cabbage . I'm looking for new maintainers to help out with this project (#88) so that would be something to discuss with the group that picks this up. |
Awesome, I still have a few features to support, namely scenario outlines aren't supported yet. I'll try to put together a small road map. |
First of all I'm an Elixir newly, but I am very experienced with Cucumber. My gut tells me that this approach of converting scenarios directly into ex tests via macros has fundamental problems. For a start its a completely different approach to the other Cucumber implementations as I understand them. These leverage the platform code to create a test environment and then work within that to execute code against the environment. My extremely limited understanding of Elixir would suggest that an Elixir cucumber should use the environment that is created for an Ex test, but that is very different from actually creating a test itself for each scenario. The fundamental purpose of Cucumber is to create a pipeline from a natural language statement to a call that runs some code. The problems I see with this macro approach is that now you have an additional step in this pipeline. With Ruby Cucumber this pipeline is
If you do this with some elegance you get
so you get out of the Cucumber space as fast as possible. What this macro approach is doing is
with the elegant version still having an extra step
These extra steps and the physical entities they produce (files) have to be navigated to for every individual scenario, and all this is just so we can execute our calls in an environment that is test friendly. This macro approach seems very focused on the scenario being the key structure in Cucumber. But the real key to Cucumber is the translation to a call, and the way to implement features effectively is to manage the API of the calls you can make, using your context to control their naming, and working at higher levels of abstraction . This is quite different from the usual Unit testing experience. To conclude the short term benefits of reducing the amount of code to setup the environment are just not sufficient to justify the extra work required to understand how each individual scenario works. |
I'm not sure what you're suggesting, but the macro conversion happens unknowingly to the user who is writing all the features/tests. Basically all https://github.com/cabbage-ex/cabbage is doing is utilizing the standard test environment in Elixir so that we're not writing a testing framework twice and having people learn two different frameworks to test their code. If you have an idea on how things should change, please feel free to submit an issue. |
I have to agree with @diabolo. This approach is far from what cucumber is (afaik). It breaks the pattern found across cucumber implementations. In SpecFlow (the .Net version of cucumber), for example, I am able to run my SpecFlow Scenarios with MSTests, Nunit, xUnit. In Ruby you have minitest, rspec... In javascript once was possible to work with jasmine to make the assertions (I did it couple of years ago as a pet project - if my memory is not fooling me) - today you can use assertion, chai and others. What if the dev like/need/prefer/ more ESpec over ExUnit? To me, it would need to be something like: That brings flexibility and simplicity. Right? |
I think if you'd like to support other frameworks like |
I agree with @mgwidmann ^ . I disagree that this is "far from what cucumber is" but cabbage is definitely a neat approach for fitting in with existing tools |
The primary purpose of this tool is to provide a way to execute Gherkin files as code. This needs to be done so transparently and as simply as possible. The best way to do this is to leverage all the capabilities provided by
ExUnit
.The major issues with this project:
As discussed here: #67 and issues like #74 and #80 will be resolved by this proposal
config.exs
, which is required because they are mentioned in theconfig.exs
filedev
by default (this can be fixed though by setting@preferred_cli_env
)scenario_starting_state
callback, which is awkward since this callback is intended to return the beginning state of a scenariohound
orex_machina
or any other test dependency occurs here since they're not started bymix
. Similar to the first pointApplication.ensure_all_started(:hound)
typically)ExUnit
setup_all
==scenario_starting_state
,setup
==feature_starting_state
,on_exit
==scenario_finalize
To resolve this, users need a clear and transparent understanding of how feature files become tests. Elixir's macro system is powerful enough to provide this translation at compile time.
Example
The feature file from the README, unchanged. Notice its moved under the
test/features
directory to show closer integration withExUnit
.test/features/coffee.feature
The feature file is ignored by
ExUnit
while the test below is executed. No need to provide suite setup callbacks as everything is provided byExUnit
.test/features/coffee_test.exs
or anywhere you want reallyThis can all work by using macros, to compile to the following:
This is now run via
mix test
. If a user wants to run them all the time, they can, or they can either via the command line domix test --exclude white_bread
or in theirtest/test_helper.exs
putExUnit.configure exclude: [:integration]
to exclude it by default. The end user has control, and all the heavy lifting is done byExUnit
.This project then only handles translating
feature
files to tests. It doesn't have callbacks, or handle setting up the test environment (with or without starting the application). Theres a clear starting point (defined byExUnit
in thetest/test_helper.exs
). Output is handled by ExUnit based upon the assertions the user writes (though it may be a nice to have to add anExUnit
formatter).In the end this DSL will result in fewer bugs and a clearer understanding & full transparency of what is running at test time. Any additional features surrounding the lifecycle and/or setup and teardown can and should be provided by
ExUnit
, which means this project won't have to develop them, it'll just inherit these future additions and features. Why try to keep up and build your own testing framework when we can just leverageExUnit
?If you're too busy, I'd like to see if what I can come up with when I get a moment.
The text was updated successfully, but these errors were encountered: