Welcome Guest, Not a member yet? Register   Sign In
Testing with vscode + xdebug
#1

Hello, 
I need help to setup my launch.json for debug tests using vscode + xdebug.

All works fine when launching debug via http request, but when I tried to debug test files It always stop with this error:

Class 'CodeIgniter\Test\CIUnitTestCase' not found

This is the related portion fo my launch.json file:

Code:
// --- this works fine ---
{
      "name": "Xdebug in Browser",
      "type": "php",
      "request": "launch",
      "hostname": "localhost",
      "port": 9000,
      "serverReadyAction": {
          "action": "openExternally"
      },
      "stopOnEntry": true,
      "xdebugSettings":{
        "show_hidden": 1
      }
    },
// --- this run into: Class 'CodeIgniter\Test\CIUnitTestCase' not found ---
    {
      "name": "Xdebug in Console",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${workspaceFolder}",
      "externalConsole": false,
      "port": 9000
    }

Can anyone please help me to solve this issue?

Many thanks in advance.
Reply
#2

Well, 
I've solved. However the approach is completely different when the debugging process is launched by running the browser.

Fundamental information are published here (details for *nix box): https://tighten.co/blog/configure-vscode...th-xdebug/

In my case (win box) the related steps are:

  • change launch.json like this:
Code:
   {
      "name": "Xdebug in Console",
      "type": "php",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "externalConsole": false,
      "port": 9000,
      "stopOnEntry": true,
      "xdebugSettings":{
        "show_hidden": 1
      }
    }
  • in vscode terminal run: $env:XDEBUG_CONFIG = "idekey=VSCODE"
  • after this run "Xdebug in Console", so you should see the step toolbar
  • at this point, perform the desired test in the terminal, for example: .\vendor\bin\phpunit --testdox .\tests\app\Models\UserModelTest.php

And debug session works like a charms Tongue Big Grin Cool

I hope it will help someone.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB