Skip to content

Untagged scenarios #94

@vincent-lg

Description

@vincent-lg

Problem

Being new in Cabbage, I followed the documentation step-by-step to create my first scenario.

When running though came a surprise. The documentation in the README.md file states:

The resulting compiled test will be logically equivalent to:

```elixir
defmodule MyApp.Features.CoffeeTest do
  use ExUnit.Case, async: false

  setup do
    on_exit fn ->
      IO.puts "Scenario completed, cleanup stuff"
    end
    {:ok, %{my_starting: :state, user: %User{}}}
  end

  # Each scenario would generate a single test case
  @tag :integration

```

This might be the case, but my scenarios aren't tagged (running mix test --exclude integration will still run the scenarios). I finally found a workaround, by including in my step something like:

defmodule ... do
  use Cabbage.Feature, async: false, file: "..."

  @moduletag :integration
end

This works as expected, I can now exclude the integration tests.

Solutions

The problem is that the documentation is not true at this point (perhaps it was a recent change and this would be true for older versions of Elixir). My suggestion would be to either:

  • Update the documentation: not tagging tests seems acceptable, since the tagging process might be different for everyone, why not let use choose? Especially if it can easily be overridden;
  • Update the macro code to use @moduletag instead of @tag. Might be acceptable, depends on whether this was a recent change or not.

Option 2 seems easiest. Tagging can be useful and, again, it can still be overridden even if there's a default behavior.

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions