skip to Main Content

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:

enter image description here

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.

enter image description here

enter image description here

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


  1. Chosen as BEST ANSWER

    It is caused by syntax problem. Every paremeter should be one element as follows:

        "taskArgs": [
            "--trace", "--warnings-as-errors", "--only", "external"
        ],
    

    enter image description here


  2. 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.

    Commands for Elixir Test

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search