The purpose is to debug only one unit test in the exs
file, therefore it is necessary to ignore other unit tests in the same exs
file.
My previous solution is comment out the other unit test, but the bad side of this solution is I can’t find other unit tests easily through vscode’s outline view as follows:
From the mix doc, it is found that mix command has --include
and --only
option.
I have adjusted launch.json
file as follows, update task args as --trace --only :external
, and update the exs
file, but when runing mix test
, it gives the error message.
Remember to keep good posture and stay hydrated!
helloworld
(Debugger) Task failed because an exception was raised:
** (Mix.Error) Could not invoke task "test": 1 error found!
--trace --only :external : Unknown option
(mix 1.13.4) lib/mix.ex:515: Mix.raise/2
(elixir_ls_debugger 0.10.0) lib/debugger/server.ex:1119: ElixirLS.Debugger.Server.launch_task/2
Then I changed launch.json to "--trace --only :external"
, similar error message as follows:
(Debugger) Task failed because an exception was raised:
** (Mix.Error) Could not invoke task "test": 1 error found!
--trace --only :external : Unknown option
(mix 1.13.4) lib/mix.ex:515: Mix.raise/2
(elixir_ls_debugger 0.10.0) lib/debugger/server.ex:1119: ElixirLS.Debugger.Server.launch_task/2
2
Answers
It is caused by syntax problem. Every paremeter should be one element as follows:
I use a plugin called Elixir Test. It has a few nice features including what you are asking for.
To run a single test place your cursor within the code of the test, then select "Elixir Test: Run test at cursor" from the command palette.
Another helpful command is: "Elixir Test: Jump". If you are editing a module file, this command will jump to the test file corresponding to the module. It will optionally create the skeleton for the test file if you haven’t created it yet.