In one of my test files, I found that on the top there is a use MyProject.DataCase
statement. Inside of MyProject.DataCase
there is a using
macro where there are some import/alias
. One of them is to import a factory module and I’m wondering if there is a way to define which factory to use depending on a key passed to use MyProject.DataCase
, something like:
defmodule MyProject.SomeTest do
use MyProject.DataCase, async: true, factory: MyProject.FactoryTwo
...
On the DataCase
defmodule MyProject.DataCase do
use ExUnit.CaseTemplate
using do
quote do
alias MyProject.Repo
import Keyword.get(opts, :factory, MyProject.FactoryOne) # <-- I don't know if I can get the argument passed
...
Some refs:
Thanks in advance!