I do use wallaby for acceptance/integration testing. These tests are somewhat longrunning (3 to 5 seconds each, depending on the machine) and I want to exclude them during regular testruns or at least exclude them explicitely easily for each run.
Therefore I have tagged them all explicitely with @tag :wallaby in code and are running my tests using mix test --exclude wallaby.
But this explicit annotation of the tests, clutters them:
test "Foo", do: assert true
test "the Truth", do: assert 1 == 1
vs.
@tag :wallaby
test "Foo", do: assert true
@tag :wallaby
test "the Truth", do: assert 1 == 1
So I am searching for a way in the corresponding Case-Template (which is used in all the testing modules) to tag all of these tests implicitely.
Is there an easy way to achieve this implicit tagging?
I don’t recommend it, but you can mimic RSpec’s xit [1]
defmodule XTest do
defmacro xtest(message, var \\ quote(do: _), contents) do
quote do
@tag :skip
test(unquote(message), unquote(var), unquote(contents))
end
end
end
defmodule FooTest do
use ExUnit.Case
import XTest
test "a" do
assert 1 + 1 == 2
end
xtest "b" do
assert 1 + 1 == 3
end
end
I wanted to avoid to introduce a new macro for such tests, as you can easily forget to use that macro and use the default one instead, as you can forget to add @tag-annotations, and these ways to forget are the things I want to avoid.
are you using wallaby with use YourApp.AcceptanceCase [1]? If so, you can probably add @moduletag :wallaby just below that line. This should work unless you mix other test types (e.g. non-acceptance) in the same module. I don’t know if there’s a way to put @moduletagintoAcceptanceCase module to further DRY it up.