How to use mix profile with tests

I’d like to find out what function calls are taking the most time in my tests. I feel like I should be able to do

mix profile.fprof -e "Mix.Tasks.Test.run([])"

but this generates an error:

** (Mix) “mix test” is running in the “dev” environment. If you are running tests from within another command, you can either:

  1. set MIX_ENV explicitly:
    MIX_ENV=test mix test.another
  2. set the :preferred_cli_env for a command inside “def project” in your mix.exs:
    preferred_cli_env: [“test.another”: :test]

When I include preferred_cli_env: [“test.another”: :test] in the mix.exs I get the same erro. Same with setting the env variable. Any suggestions?

====================
Nevermind, ban user. Typo in setting the env variable. Corrected that and it worked.

2 Likes