Skip to content

Commit 7e39eea

Browse files
author
José Valim
committed
Improve error message from wrong test invocation
1 parent 9f03c38 commit 7e39eea

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/mix/lib/mix/tasks/test.ex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,18 @@ defmodule Mix.Tasks.Test do
377377
end
378378

379379
unless System.get_env("MIX_ENV") || Mix.env() == :test do
380-
Mix.raise(
381-
"\"mix test\" is running in the \"#{Mix.env()}\" environment. If you are " <>
382-
"running tests alongside another task, please set MIX_ENV explicitly"
383-
)
380+
Mix.raise("""
381+
"mix test" is running in the \"#{Mix.env()}\" environment. If you are \
382+
running tests from within another command, you can either:
383+
384+
1. set MIX_ENV explicitly:
385+
386+
MIX_ENV=test mix test.another
387+
388+
2. set the :preferred_cli_env for a command inside "def project" in your mix.exs:
389+
390+
preferred_cli_env: ["test.another": :test]
391+
""")
384392
end
385393

386394
Mix.Task.run("loadpaths", args)

0 commit comments

Comments
 (0)