[erlang-questions] Know if running in CT

Jesper Louis Andersen <>
Thu Dec 10 17:18:44 CET 2015


On Thu, Dec 10, 2015 at 5:10 PM, Roberto Ostinelli <>
wrote:

> Ideally, I would like to define a conditional macro depending on code
> running in tests or not.
>
>
You can probably have a configuration option via application:get_env/2 you
can use to make the discrimination. On the top of my head, this is what I
would do.


> Any ideas welcome!
>

Advice: don't do it. Keep your test artifact equivalent to the deployment
artifact. Make the application such that normal configuration parameters
can be set in order to make the application work in the test environment.
It is safer in the long run because you don't want too many diverging code
paths based on the environment it lives in. It is simply too brittle, and
that would be my advice.


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151210/b37b48c8/attachment.html>


More information about the erlang-questions mailing list