Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define test task

I am using VS Code to develop a simple project. I've created some unit tests (xUnit.net) and I would like create a test task to execute them. The idea is to run tests whenever I hit Ctrl+Shift+T.

However, I am not able to figure out how to define test tasks. What is the correct way to achieve that?

like image 402
Dusan Janosik Avatar asked May 02 '15 08:05

Dusan Janosik


2 Answers

This has changed in the latest version of VS Code (1.47.0)

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Run tests",
      "group": "test", // <-- this will add this task to 'Run test task'
      "type": "shell",
      "command": "npm test"
    }
  ]
}
like image 122
mrsauravsahu Avatar answered Sep 29 '22 21:09

mrsauravsahu


Looks like they changed the default behavior of the Ctrl+Shift+T keybinding in recent versions to reopen the last tab closed (like many browsers support). To view your current Keyboard Bindings, select the following menu option:

File > Preferences > Keyboard Shortcuts

If you want to change the Ctrl+Shift+T keybinding back to issuing your default test task, simply change the value of the command property in the following object:

{ "key": "ctrl+shift+t", "command": "workbench.action.reopenClosedEditor" }

to be: workbench.action.tasks.test, or you can assign the testing task to a different keybinding by adding the following line to your Default Keyboard Shortcuts config file:

{ "key": "<your keybinding here>", "command": "workbench.action.tasks.test" }
like image 25
Joel B Avatar answered Sep 29 '22 22:09

Joel B