[proposal] ExUnit: A use case for specifying setup callback as MF(A)

28 views
Skip to first unread message

Nikola Begedin

unread,
Feb 5, 2023, 6:21:13 AM2/5/23
to elixir-lang-core
Hello everyone. 1st time writing here. I scanned through the repo docs, etc, and I'm not finding a guideline on how to do it. Apologies if I'm making a mistake here.

I have a proposal, or at least a question about a potential proposal.

You can always import a function from a module and then use `setup :function_name` in a test module. This allows you to reuse setup functions across the codebase.

However, at least in the environment I work in, I have a fair amount of colleagues who dislike importing things.

So my question is, would a version of setup that allows specifying a setup callback via a [module, function], {module, function}, etc, be a worthy addition?

Including the arity would be more conventional, of course, but it's a bit redundant here.

At quick glance, it does seem feasible, but it changes the API and I might be missing other caveats, so I'm not sure.

eksperimental

unread,
Feb 5, 2023, 6:47:37 AM2/5/23
to elixir-l...@googlegroups.com
Hi Nikola

Have you tried?
`setup(context), do: Module.function_name(context)`

Cheers.

Nikola Begedin

unread,
Feb 5, 2023, 7:16:22 AM2/5/23
to elixir-l...@googlegroups.com
> Have you tried?
> `setup(context), do: Module.function_name(context)`

Oh how

Yes, of course, that works perfectly well! I can't believe I never considered it.

Cheers!

--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/Y6xxU64jtUc/unsubscribe.
To unsubscribe from this group and all its topics, 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/63df9755.050a0220.aefc6.fd42SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
Reply all
Reply to author
Forward
0 new messages