defmodule MyTest do
use ExUnit.Case
@contexts [
"my_value_1",
%{my_value: 2},
3
]
describe "my test case" do
@data_provider @contexts
test "my object tests", %{context: %{my_value: value}} do
# It will match once
assert value == 2
end
@data_provider @contexts
test "", %{context: item} do
# It will run this function tree times,
# for each item in @contexts. item value on each loop execution:
#
# - "my_value"
# - %{my_value: 2}
# - 3
end
endend
describe "my test case" do
test_cases_for ["should do something with users", "should do something else with users"], do:
[
%{username: "Foobar1", likes_to: ["play soccer"]},
%{username: "Foobar2", likes_to: ["play basketball", "go on a trip"]},
%{username: "Foobar3", likes_to: []},
]
#Loops into test_cases
test "should do something with users", cases: %{username: username, likes_to: likes_to} do
#Do something with those params
end
test "should do something else with users", cases: %{username: username, likes_to: likes_to} do
#Do something with those params
end
end
--
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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/36931be4-2d15-435b-8d64-f9829f6a0dac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.