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?
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"
}
]
}
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" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With