Find all modules with eunit tests

Is there a function in eunit that would return all modules containing tests? E.g. something like:

$ rebar3 as test shell
1> eunit:list_of_modules_with_tests().
[ ... ]

Or the way to do this would be to get a list of all modules found in the known path, load each, and test each for the M:test/0 function?

2 Likes

You can find all loaded modules with erlang:loaded/0 and call eunit:test/1 on them - they won’t throw an error, but would print something like “no test to run”. You can also filter them based on erlang:function_exported/3 so you don’t get unnecessary output.

But if you’re using rebar3, why don’t you just call rebar3 eunit?

2 Likes