Here is my usecase, in ecto_fixtures you can declar via macros the fixture 
state to bring into each test:

    fixture :employee_1
    context :admin
    serialize true
    test "foo bar", %{data: data} do
      ...
    end

Quite often the entire test module would be asserting within an admin 
context. It would be great to do something like:

    context :admin
    describe "Admin" do
      fixture :employee_
      serialize true
      test "foo bar", %{data: data} do
        ...
      end

      fixture :employee_2
      test "foo bar", %{data: data} do
        ...
      end
    end


On Friday, March 31, 2017 at 7:24:12 PM UTC-4, José Valim wrote:
>
> 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] 
> <javascript:>> 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] <javascript:>.
>> 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/69ef3421-a5f6-4b2d-8f90-594ad82083d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to