Skip to content

Launch CTest

To debug a specific test in the Testing tab of VS Code, it needs a configuration in launch.json that supports running a specific test. Since I often can't find the documentation for it, I added the config here. "args": [ "${cmake.testArgs}" ] really does the magic here. If you want to use GDB, replace cppvsdbg with cppdbg.

See also Debugging Tests (permalink).

vscode/launch-ctest.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(ctest) Launch",
      "type": "cppvsdbg",
      "request": "launch",
      "program": "${cmake.testProgram}",
      "args": ["${cmake.testArgs}"],
      "stopAtEntry": false,
      "cwd": "${command:cmake.getLaunchTargetDirectory}"
    }
  ]
}

Source