There is @describetag that can be used inside the describe block.

    describe "outer" do
     @describetag foo :bar
      test "inner 1", %{registered: %{foo: foo}} do
        IO.inspect(foo)
      end

      test "inner 2", %{registered: %{foo: foo}} do
        IO.inspect(foo)
      end
    end

Wouldn't that be enough?



*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Sat, Apr 1, 2017 at 5:45 AM, Brian Cardarella <[email protected]> wrote:

> Currently if you do:
>
>     ExUnit.Case.register_attribute(__MODULE__, :foo)
>
>     @foo :bar
>     describe "outer" do
>       test "inner 1", %{registered: %{foo: foo}} do
>         IO.inspect(foo)
>       end
>
>       test "inner 2", %{registered: %{foo: foo}} do
>         IO.inspect(foo)
>       end
>     end
>
> The result will print `:bar` when "outer inner 1" runs and `nil` when
> "outer inner 2" runs because the test module attribute values reset after
> each `test/2`
>
> It would be great if the test module attributes declared above a
> `describe` could be inherited by all tested `test/2`s.
>
> If there isn't opposition to this idea I can work on implementing it.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/elixir-lang-core/db59da0f-64bd-4079-aeb0-
> 0249ddc54066%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/db59da0f-64bd-4079-aeb0-0249ddc54066%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4L%2BxUXS5KaMcUTHfMWo-J5rHsCUk%3De05gekewZyBvfGyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to