Closed hisapy closed 7 years ago
You can do it in ExUnit which seems to be what Cabbage uses under the hood.
I know I can use @tag in ExUnit, but how do I tag a single scenario if what I have in my _test.exs
files are just the step definitions?. In other words, I have a feature with 3 scenarios but I'm only want to run the tests for one of them, without commenting out the other 2.
This isn't yet a supported feature, but its definitely something we should support! As you can see here: https://github.com/cabbage-ex/cabbage/blob/master/lib/cabbage/feature.ex#L187 cabbage does tag all tests as :integration
, but since tag processing occurs in the setup
block, I don't think ExUnit will pick up on it if you were to define it inside a tag.
Any suggestions on how you'd like this to work?
By the way this is the same topic as https://github.com/cabbage-ex/cabbage/issues/29 and we should close one of them.
I'm not sure about the implementation details but here's the expected behavior
Feature: Tag Scenario
As a Product Manager/Developer
I want to add tags to a scenario in a feature file
So I can do stuff with the steps implementation based on tags
Scenario: Run test for a scenario tagged as @wip
Given a some.feature file describing multiple scenarios
When I put the @wip tag above an scenario
And run mix test --only wip some_test.exs
Then only the steps for the scenario tagged as @wip should be executed
Scenario: Run test for more than one scenario tagged as @wip
# add some steps/behavior here
Notice that it might be useful to combine multiple tags or tag more than one scenario. If each scenario is a test
in a test case then perhaps, it might be possible to put the @tag :wip
above the corresponding test
. It might be also possible to tag the whole feature by adding @wip
at the top of the .feature file and then use @moduletag :wip
.
So what we can do is take all @whatever
you mark in the scenario with and add a @tag :whatever
for each of them... That'd be a simple solution.
Related to that: is it possible to overwrite the timeout for a scenario? I have scenarios that run longer than a minute.
All that sort of stuff falls back to exunit (which is why this project did not build its own unit test framework but built on top of exunit instead).
See their docs here: https://hexdocs.pm/mix/Mix.Tasks.Test.html
Implementing in #34 ... see comment in #35
In cucumber, you can tag an scenario, for example as
@wip
and run only the steps corresponding to such scenario. Is this possible with Cabbage?