testingerlangerlang-otprebarcommon-test

Erlang Testing (Non Exported / Private) function of module using common test


I have a module in Erlang which has functions that are not exported by Erlang. How can I test / call these functions using common test framework?


Solution

  • It is impossible. You can use -ifdef(TEST). preprocessor condition to export those functions only when compiling for testing.

    Depending on your tooling, you might need to explicitly provide that TEST macro while compiling the modules. You can do that by using {d,'TEST'} compiler option or -DTEST compilation flag.